akhauriyash/Code-Regression huggingface dataset:
type t =
  | Leaf
  | Node of body
and body = { left : t; right : t; data : int; l : int; r : int }

let rec drop n l =
  if n = 0 then l else drop (n - 1) (List.tl l)

let rec init l n xs =
  if n = 1
  then
    (Node
      { left = Leaf;
        right = Leaf;
        data = max_int; l;
        r = List.hd xs }, List.hd xs)
  else
    let (left, m) = init l (n / 2) xs in
    let (right, r) = init m ((n + 1) / 2) (drop (n / 2) xs) in
    (Node { left; right; data = max_int; l; r }, r)
let init (x :: xs) = fst @@ init x (List.length xs) xs

let rec update a b x = function
  | Leaf -> Leaf
  | Node ({ left; right; data; l; r } as t) ->
      if b <= l || r <= a || t.data <= x
      then Node t
      else begin
        if a <= l && r <= b
        then Node { t with data = min x t.data }
        else Node { t with left = update a b x left; right = update a b x right }
      end

let rec query acc i = function
  | Leaf -> acc
  | Node { left; right; data; l; r } ->
      if i < l || r <= i
      then acc
      else query (query (min acc data) i left) i right
let query = query max_int

let () = Scanf.scanf "%d %d\n" @@ fun n q ->
  let stxs =
    Array.init n @@ fun _ ->
      Scanf.scanf "%d %d %d\n" @@ fun s t x -> s, t, x in
  let tr =
    Array.fold_right (fun (s, t, x) -> update (s - x) (t - x) x) stxs @@
    init @@
    List.sort_uniq compare @@
    Array.fold_left (fun acc (s, t, x) -> s - x :: t - x :: acc) [] stxs in
  for i = 0 to q - 1 do
    Printf.printf "%d\n" @@ Scanf.scanf "%d\n" @@ fun d ->
      let ans = query d tr in
      if ans = max_int then -1 else ans
  done


Measured memory_bytes: 115996
import java.util.Scanner;
class Main{


	static char[][] map;

	static long[][] c;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int a = sc.nextInt();

		if(n >= 10 || a >= 10){
			System.out.print(-1);
		}else{
			System.out.print(n*a);

		}


	}

	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}








}






Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

int main(){
    ll n;
    cin >> n;

    ll a[n] = {};
    ll s=1, l=10000000000;

    for(ll i=0; i<n; ++i){
      cin >> a[i];

      s = max(s, a[i]);
      l = min(l, a[i]);
    }
    
      cout << s-l;
      
}

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

const int maxn = 1e5 + 10;

int a[maxn];
int cnt[maxn];

bool cmp(const int &x, const int &y) {
	return x > y;
}

int main() {
	int n, ans = 0, res = 0;
	cin >> n;
	for (int i = 1; i <= n; ++ i) cin >> a[i];
	int s1 = 0, s2 = 0, id1 = 0, id2 = 0;
	for (int i = 1; i <= n; i += 2) {
		ans ++, cnt[a[i]] ++;
		if (cnt[a[i]] > s1) s1 = cnt[a[i]], id1 = a[i];
	}
	sort(cnt, cnt + maxn, cmp);
	int max1 = ans - cnt[0], max2 = ans - cnt[1];
	memset(cnt, 0, sizeof(cnt)); 
	for (int i = 2; i <= n; i += 2) {
		res ++, cnt[a[i]] ++;
		if (cnt[a[i]] > s2) s2 = cnt[a[i]], id2 = a[i];
	}
	sort(cnt, cnt + maxn, cmp);
	int mmx1 = res - cnt[0], mmx2 = res - cnt[1];
	if (id1 == id2) {
		cout << min(mmx1 + max2, mmx2 + max1) << endl;
		return 0;
	} else {
		cout << max1 + mmx1 << endl;
		return 0;
	}
}

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

int main() {
  int n,c = 0;
  cin >> n;
  for(int i = 0;i < n;i++){
    long long a;
    cin >> a;
    if(a%4 == 0){
      c += 2;
    }
    else if(a%2 == 0){
      c++;
    }
  }
  if((n%2 == 0 && c >= n)||(n%2 == 1 && c >= n-1)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n)
    {
        n %= 39;
        if(n == 0) n = 39;
        string s = to_string(n);
        if(s.size() == 1) s = '0' + s;
        cout << "3C" + s << endl;
    }
    return 0;
}




Measured memory_bytes: 3140
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 24 22:10:01 2019

@author: Yamazaki Kenichi
"""
import numpy as np
import bisect

A,B,Q = map(int,input().split())
s = [int(input()) for i in range(A)]
t = [int(input()) for i in range(B)]
x = [int(input()) for i in range(Q)]

def lr(s,c,A):
    si = bisect.bisect(s,c)
    if si == A:
        return [c-s[si-1], 10**11]
    elif si == 0:
        return [10**11, s[0]-c]
    else:
        return [c-s[si-1], s[si]-c]
for c in x:
    ans = 0
    slr = lr(s,c,A)
    tlr = lr(t,c,B)
    ans = min(max(slr[0],tlr[0]),
              max(slr[1],tlr[1]),
              slr[0]*2+ tlr[1],
              slr[0]+ tlr[1]*2,
              slr[1]*2 + tlr[0],
              slr[1]+ tlr[0]*2
              )
    print(ans)
    

Measured memory_bytes: 25372
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<(n);++i)
#define repeq(i,a,n) for(int i=a,i<=(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    ll n;
    cin >> n;
    string ans="";
    while(n){
        n--;
        ans+=char('a'+(n%26));
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
N = int(input())
H = list(map(int, input().split()))

ans = 0
m = 0
for i in range(N-1):
	if H[i]<H[i+1]:
		ans = max(ans, m)
		m = 0
	else:
		m += 1
ans = max(ans, m)

print(ans)

Measured memory_bytes: 14224
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#define INF 1000000007
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> P;


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

	int a[100000] = { 0 };
	int m = 0;
	int mm = 0;
	int mi = INF;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		m = max(m, a[i]);
	}


	for (int i = 0; i < n; i++) {
		if (mi > abs(m - a[i]*2)) {
			mi = abs(m - a[i]*2);
			mm = a[i];
		}
	}
	if (n > 2) {
		cout << m << ' ' << mm << endl;
	}
	else {
		cout << max(a[0], a[1]) << ' ' << min(a[0], a[1]) << endl;
	}

	return 0;
}




Measured memory_bytes: 640
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e,n;
  string s,ss,sss;
  cin>>a>>b>>c;
  if(a+b+c>=22)
    cout<<"bust"<<endl;
  else cout<<"win"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const ll mod = 1000000007;
const int MAX_N = 100010;

Graph G;
vector<int> deg;  // 各頂点の入次数
int dp[MAX_N];

int main() {
    int n, m;
    cin >> n >> m;    

    G.assign(n, vector<int>());
    deg.assign(n, 0);

    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--;  y--;
        G[x].push_back(y);
        deg[y]++;
    }

    queue<int> Q;
    rep(v, n) {
        if(deg[v] == 0) {
            Q.push(v);
        }
    }

    while(!Q.empty()) {

        int v = Q.front();
        Q.pop();

        for(auto u : G[v]) {
            deg[u]--;
            if(deg[u] == 0) {
                Q.push(u);
                dp[u] = max(dp[u], dp[v] + 1);
            }
        }
        
    }

    int ans = 0;
    rep(v, n) {
        ans = max(ans, dp[v]);
    }

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

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

using namespace std;

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

    int A, B, C;
    cin >> A >> B >> C;

    if (A == B)
        cout << C << endl;
    else if (B == C)
        cout << A << endl;
    else
        cout << B << endl;
}


Measured memory_bytes: 256
type t =
  | Leaf
  | Node of body
and body = { left : t; right : t; data : int; l : int; r : int }

let rec drop n l =
  if n = 0 then l else drop (n - 1) (List.tl l)

let rec init l n xs =
  if n = 1
  then
    (Node
      { left = Leaf;
        right = Leaf;
        data = max_int; l;
        r = List.hd xs }, List.hd xs)
  else
    let (left, m) = init l (n / 2) xs in
    let (right, r) = init m ((n + 1) / 2) (drop (n / 2) xs) in
    (Node { left; right; data = max_int; l; r }, r)
let init (x :: xs) = fst @@ init x (List.length xs) xs

let rec update a b x = function
  | Leaf -> Leaf
  | Node ({ left; right; data; l; r } as t) ->
      if b <= l || r <= a
      then Node t
      else begin
        if a <= l && r <= b
        then Node { t with data = min x t.data }
        else Node { t with left = update a b x left; right = update a b x right }
      end

let rec query acc i = function
  | Leaf -> acc
  | Node { left; right; data; l; r } ->
      if i < l || r <= i
      then acc
      else query (query (min acc data) i left) i right
let query = query max_int

let () = Scanf.scanf "%d %d\n" @@ fun n q ->
  let stxs =
    Array.init n @@ fun _ ->
      Scanf.scanf "%d %d %d\n" @@ fun s t x -> s, t, x in
  let tr =
    Array.fold_right (fun (s, t, x) -> update (s - x) (t - x) x) stxs @@
    init @@
    List.sort_uniq compare @@
    Array.fold_left (fun acc (s, t, x) -> s - x :: t - x :: acc) [] stxs in
  for i = 0 to q - 1 do
    Printf.printf "%d\n" @@ Scanf.scanf "%d\n" @@ fun d ->
      let ans = query d tr in
      if ans = max_int then -1 else ans
  done


Measured memory_bytes: 116216
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
const int MAXN = 100001;

/*struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];*/


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

//-----Template---------
int n;
int x;
int kakikomu[200005];
int main(){
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    cin>>n>>x;
    if(x==1 || x==2*n-1){
        cout<<"No"<<endl;
        return 0;
    }
    if(n==2 && x==2){
        cout<<"Yes"<<endl;
        cout<<"1"<<endl;
        cout<<"2"<<endl;
        cout<<"3"<<endl;
        return 0;
    }
    set<int> unused;
    for (int i = 1; i <= 2*n-1; ++i) {
        unused.insert(i);
    }
    
    if(x==2){
        kakikomu[n-2]=x+2;
        unused.erase(x+2);

        kakikomu[n-1]=x-1;
        unused.erase(x-1);

        kakikomu[n]=x;
        unused.erase(x);

        kakikomu[n+1]=x+1;
        unused.erase(x+1);
    }else{
        kakikomu[n-2]=x-1;
        unused.erase(x-1);

        kakikomu[n-1]=x;
        unused.erase(x);

        kakikomu[n]=x+1;
        unused.erase(x+1);

        kakikomu[n+1]=x-2;
        unused.erase(x-2);
    }
    for (int i = 0; i < 2*n-1 ; ++i) {
        if(kakikomu[i]==0) {
            int num=*unused.begin();
            kakikomu[i] = num;
            unused.erase(num);
        }
    }
    cout<<"Yes"<<endl;
    for (int i = 0; i < 2*n-1; ++i) {
        cout<<kakikomu[i]<<endl;
    }
        
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}



int main(void)
{
  string s;
  cin >> s;
  char c;
  ll min_cnt = 1000;
  for(c = 'a'; c <= 'z'; c++) {
    bool ok = false;
    REP(i, s.size()) {
      if(s[i] == c) ok = true;
    }
    if(!ok) continue;
    ll cnt = 0;
    string s1 = s;
    while(1) {
      bool ok = true;
      REP(i, s1.size()) {
	if(s1[i] != c) ok = false;
      }
      if(ok) break;
      REP(i, s1.size()-1) {
	if(s1[i+1] == c) s1[i] = c;
      }
      s1.erase(s1.size()-1);
      cnt ++;
    }
    //    cout << s1 << " " << cnt << endl;
    if(min_cnt > cnt) min_cnt = cnt;
  }

  cout << min_cnt << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
const int MOD = 1000000007;

ll dp[1010][1010];

void _main()
{
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    rep(i, 0, H) cin >> a[i];

    dp[0][0] = 1;
    rep(i, 0, H) rep(j, 0, W)
    {
        if (a[i][j] == '#') continue;
        if (j + 1 < W) if (a[i][j + 1] == '.') dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % MOD;
        if (i + 1 < H) if (a[i + 1][j] == '.') dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
    }
    cout << dp[H - 1][W - 1] << endl;
}


Measured memory_bytes: 9216
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

int main(){
  int N, K; cin >> N >> K;
  int dp[N+1][K+1] = {}; int a[N];
  rep(i, N){
    cin >> a[i];
  }
  dp[0][0] = 1;
  for(int i=1; i<=N; i++){
    int cum[K+1] = {0};
    rep(j, K+1){
      cum[j+1] = (cum[j] + dp[i-1][j]) % mod;
    }
    rep(j, K+1){
      dp[i][j] += (cum[j+1] - cum[max(0, j-a[i-1])] + mod) % mod ;
      dp[i][j] %= mod;
    }
  }
  cout << dp[N][K] << endl; 
}

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

int main(){
  ll N;
  cin >> N;
  for(ll a=1;a<=3500;a++){
    for(ll b=1;b<=3500;b++){
      ll s = N*a*b;
      ll t = 4*a*b - N*(a+b);
      if(s>0&&t>0&&s%t==0){
        //cout << s << " " << t << endl;
        ll c = s/t;
        if(1<=c&&c<=3500){
          cout << a << " " << b << " " << c << endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  ll n, X;
  cin >> n >> X;
  vector<ll> x(n);
  rep(i, n) {
    cin >> x.at(i);
  }

  ll ans = 0;

  sort(x.rbegin(), x.rend());
  vector<ll> sum(n+1);
  sum.at(0) = 0;
  for(int i=1; i<=n; i++) {
    sum.at(i) = sum.at(i-1) + x.at(i-1);
  }

  ll tmp = 0;
  rep(i, n) {
    //debugln(x.at(i));
    if (i < 1) {
      tmp += x.at(i) * 5;
    } else {
      tmp += x.at(i) * (2*i + 3);
    }
    if (tmp > LONG_MAX/2) {
      tmp = LONG_MAX/2;
      break;
    }
    //debugln(tmp);
  }
  ans = tmp + X*(n+1);

  for(int k=2; k<=(n+1)/2; k++) {
    tmp = 0;
    int pos = 0;
    while (pos < n) {
      //debug(pos);
      int e = max(5, (pos/k)*2+3);
      //debug(e);
      if (pos + k <= n) {
        tmp += (sum.at(pos+k) - sum.at(pos))*e;
        pos += k;
      } else {
        tmp += (sum.at(n) - sum.at(pos))*e;
        pos = n;
      }
      if (tmp > LONG_MAX/2) {
        tmp = LONG_MAX/2;
        break;
      }
    }
    tmp += X*(n+k);
    //debug(k); debugln(tmp);
    ans = min(ans, tmp);
  }


  cout << ans << endl;
}


Measured memory_bytes: 3456
#include <iostream>

#include <algorithm>
#include <cassert>
#include <vector>

namespace atcoder {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

}  // namespace atcoder


int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n, q;
	std::cin >> n >> q;
	atcoder::dsu dsu(n);
	while (q--) {
		int t, a, b;
		std::cin >> t >> a >> b;
		if (t == 0)
			dsu.merge(a, b);
		else
			std::cout << dsu.same(a, b) << '\n';
	}
}

Measured memory_bytes: 3924
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val h = intList()
    val array = Array(n) { h[it] }
    var count = 0
    while (true) {
        var s = -1
        var w = false
        0.until(n).forEach {
            if (array[it] != 0) {
                w = true
                array[it]--
            } else {
                if (w) {
                    count++
                    s = it
                    w = false
                }
            }
        }
        if (w) {
            count++
        }
        if (array.sum() == 0) {
            break
        }
    }

    println(count.toString())
}

Measured memory_bytes: 38160
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] h = new double[n];
		int[] x = new int[6];
		for(int i = 0 ; i < n ;i++){
			h[i] = sc.nextDouble();
		}
		for(int i = 0 ; i < n ;i++){
			if(h[i] >= 185.0){
				x[5]++;
			} else if (h[i] >= 180.0){
				x[4]++;
			} else if (h[i] >= 175.0){
				x[3]++;
			} else if (h[i] >= 170.0){
				x[2]++;
			} else if (h[i] >= 165.0){
				x[1]++;
			} else {
				x[0]++;
			}
		}
		for(int i = 1 ; i <= x.length ;i++){
			System.out.print(i +":");
			for(int k = 0 ; k < x[i-1] ; k++){
				System.out.print("*");
			}
			System.out.println();
		}
		sc.close();
	}

}

Measured memory_bytes: 18648
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ld INF = (ld)10000000000000;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
int n, m, c;
int a[20][20];
int b[20];
int main() {
	cin >> n >> m >> c;
	rep(i, m)cin >> b[i];
	rep(i, n) {
		rep(j, m)cin >> a[i][j];
	}
	int ans = 0;
	rep(i, n) {
		int sum = 0;
		rep(j, m) {
			sum += a[i][j] * b[j];
		}
		sum += c;
		if (sum > 0)ans++;
	}
	cout << ans << endl;
	//stop
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;
#include <string>
typedef long long int ll;

int main(){
  string S;
  string T;
  cin >> S;
  cin >> T;

  int count = 0;

  for(int i=0;i<3;i++){
    if(S[i]==T[i]) count++;
  }


  cout << count;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

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

    int H,W,K; cin>>H>>W>>K;
    vector<string> s(H);
    for(int i=0;i<H;i++) cin>>s[i];

    vector<vector<int>> ans(H,vector<int>(W));
    int id=1;
    for(int i=0;i<H;i++){
        int c=0;
        for(int j=0;j<W;j++) c+=(s[i][j]=='#');
        if(c==0) continue;

        int cnt=0;
        for(int j=0;j<W;j++){
            cnt+=(s[i][j]=='#');
            if(cnt<=1){
                ans[i][j]=id;
            }else{
                ans[i][j]=++id;
                cnt=1;
            }
        }
        id++;
    }
    for(int i=1;i<H;i++){
        for(int j=0;j<W;j++) if(ans[i][j]==0) ans[i][j]=ans[i-1][j];
    }
    for(int i=H-2;i>=0;i--){
        for(int j=0;j<W;j++) if(ans[i][j]==0) ans[i][j]=ans[i+1][j];
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout<<ans[i][j]<<(j==W-1? '\n':' ');
        }
    }
    return 0;
}

Measured memory_bytes: 1280
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int n, m;
  readf("%s %s\n", &n, &m);
  writeln((n-1) * (m-1));
}


Measured memory_bytes: 256
def check():
	N = int(input())
	W = []
	for i in range(N):
		W.append(input())

	for i, word in enumerate(W):
		if i != 0:
			if word[:1] != W[i-1][-1:]:
				return False
	if len(W) != len(set(W)):
		return False

	return True


if check():
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC optimize("Ofast")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T1, typename T2>
T2 sum_mod(T1 x, T2 MOD) {
	if (x < 0)
		x += MOD;
	if (x >= MOD)
		x -= MOD;
	return x;
}

template <typename T1, typename T2>
T2 mul_mod(T1 x, T2 MOD) {
	if (x < 0)
		return (abs(x) % MOD == 0 ? 0 : MOD - abs(x) % MOD);
	return x % MOD;
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

const int LOG = 18;
const int N = (int)2e5 + 7;
const int MAXN = (int)2e3 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 300;
const LL LINF = (i64)2e15;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

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

vector <LL> get_div(LL x) {
	vector <LL> res;
	for (int i = 1; 1LL * i * i <= x; i++) {
		if (x % i != 0)
			continue;
		res.push_back(i);
		if (i != x / i)
			res.push_back(x / i);
	}
	sort(all(res));
	return res;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
#endif

	LL n; cin >> n;
	auto dn = get_div(n), dm = get_div(n - 1);
	int ans = size(dm) - 1;
	for (LL x : dn) {
		if (x == 1)
			continue;
		LL val = n;
		while (val % x == 0)
			val /= x;
		if (val % x == 1)
			ans++;
	}
	cout << ans;

	
#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

func main() {
	n := getInt()
	m := getInt()

	broken := make([]bool, n+1)
	for i := 0; i < m; i++ {
		broken[getInt()] = true
	}

	dp := make([]int, n+1)
	dp[0] = 1
	if !broken[1] {
		dp[1] = 1
	}

	for i := 2; i <= n; i++ {
		if !broken[i] {
			dp[i] = dp[i-1] + dp[i-2]
			dp[i] %= mod
		}
	}

	fmt.Println(dp[n])
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


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

const int MAX_N = 50000;
bool isPrime[MAX_N + 1];

void setup() {
    fill_n(isPrime, MAX_N, true);
    isPrime[0] = isPrime[1] = false;
    for (int i = 4; i <= MAX_N; i += 2) {
        isPrime[i] = false;
    }
    for (int i = 3; i * i <= MAX_N; i += 2) {
        if (isPrime[i]) {
            for (int j = i + i; j <= MAX_N; j += i) {
                isPrime[j] = false;
            }
        }
    }
}

int main() {
    setup();
    int n;
    while (cin >> n, n) {
        int result = 0;
        if (isPrime[n - 2]) {
            result++;
        }
        for (int i = 3; i * 2 <= n; i += 2) {
            if (isPrime[i] && isPrime[n - i]) {
                result++;
            }
        }
        cout << result << endl;
    }
}

Measured memory_bytes: 1208
import java.util.Scanner;

class Main{
      public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	Dice[] dice;

    	int dice_num = scan.nextInt();
    	dice = new Dice[dice_num];

    	for(int i = 0; i < dice_num; i++){
    		dice[i] = new Dice();
    	}

    	for(int i = 0; i < dice_num; i++){
    		for(int j = 0; j < 6; j++){
    			dice[i].S[j] = scan.nextInt();
    		}
    	}

    	for(int n = 0; n < dice_num - 1; n++){
    		for(int m = n + 1; m < dice_num; m++){
				for(int i = 0; i < 4; i++){
					for(int j = 0; j < 4; j++){
			    		for(int k = 0; k < 4; k++){
			    			dice[m].vRoll();
			    			//System.out.println(String.format("n:%d m:%d i:%d j:%d k:%d", n, m, i, j, k));
			    			//System.out.println(String.format("dice[%d] = %d, %d, %d, %d, %d, %d", n, dice[n].S[0], dice[n].S[1], dice[n].S[2], dice[n].S[3], dice[n].S[4], dice[n].S[5]));
			    			//System.out.println(String.format("dice[%d] = %d, %d, %d, %d, %d, %d", m, dice[m].S[0], dice[m].S[1], dice[m].S[2], dice[m].S[3], dice[m].S[4], dice[m].S[5]));
			    			if(dice[n].S[0] == dice[m].S[0] && dice[n].S[1] == dice[m].S[1] && dice[n].S[2] == dice[m].S[2] && dice[n].S[3] == dice[m].S[3] && dice[n].S[4] == dice[m].S[4] && dice[n].S[5] == dice[m].S[5]) {
			    				System.out.println("No");
			    				return;
			    			}
			        	}
			    		dice[m].yRoll();
		    		}
		    		dice[m].v2Roll();
				}
    		}
		}
    	System.out.println("Yes");
     }
}

class Dice{
	int[] S = new int[6];
	
	public void vRoll(){
		int temp3 = S[0];
		S[0] = S[1];
		S[1] = S[5];
		S[5] = S[4];
		S[4] = temp3;
	}
	
	public void yRoll(){
		int temp2 = S[0];
		S[0] = S[3];
		S[3] = S[5];
		S[5] = S[2];
		S[2] = temp2;
	}
	
	public void v2Roll(){
		int temp = S[0];
		S[0] = S[1];
		S[1] = S[5];
		S[5] = S[4];
		S[4] = temp;
	}
}

Measured memory_bytes: 29600
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(i64 i = 0; i < N; i++)
#define Rep(i, k, N) for(i64 i = k; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

bool binary_search(int& x, int &y, int& n){
    int R = n - x*x- y*y - x*y;

    int ok = R, ng = 0;
    while(ok - ng > 1){
        int z = (ok + ng) / 2;
        int L = z*(x + y + z);
        if(L < R)  ng = z;
        if(L > R) ok = z;
        if(L == R && z != 0) {
            return true;
        }
    }
    return false;
}

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

    for(int n = 1; n <= N; n++){
        int ans = 0;
        for(int x = 1; x*x <= N; x++){
            for(int y = 1; x*x+y*y <= N; y++){
                ans += binary_search(x, y, n);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3592
from collections import deque

n=int(input()) 
#S = []
#for _ in range(n-1):
#    S.append(list(map(int, input().split())))

edges= [[0]*0 for i in range(n)] 
l = {}
for i in range(n-1):
    a,b=map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
    l[(a-1,b-1)] = i
    l[(b-1,a-1)] = i

#print(max([len(p) for p in pt]))
ans=[0]*(n-1)
visit=[-1]*n
q=deque([0])
visit[0]=0

while q:
    v=q.popleft()
    count=1
    for x in edges[v]:
        if visit[x]<0:
            if count==visit[v]:
                count+=1
            q.append(x)
            visit[x]=count
            ans[l[(v,x)]]=count
            count+=1
            
print(max(ans))
for i in range(n-1):
    print(ans[i])            


Measured memory_bytes: 99744
#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 ll long long int
#define ld long double
#define pii 3.14
#define mod (ll)(1e9 + 7)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(1e5+5)

void solve()
{
    ll h,w;
    cin>>h>>w;

    string arr[h];
    for(int i=0;i<h;i++)
        cin>>arr[i];

    ll dp[h][w];
    memset(dp,0,sizeof dp);

    for(int i=0;i<w;i++)
    {
        if(arr[0][i]=='#')
            break;
        dp[0][i] = 1;
    }

    for(int i=0;i<h;i++)
    {
        if(arr[i][0]=='#')
            break;
        dp[i][0] = 1;
    }

    for(int i=1;i<h;i++)
    {
        for(int j=1;j<w;j++)
        {
            if(arr[i][j] == '#')
                continue;
            dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
        }
    }

    cout<<dp[h-1][w-1]<<"\n";
}

int main()
{
    fio;
    ll tc = 1;
   // cin>>tc;
    while(tc--)
    {
        solve();
    }
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 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;
}
signed main() {
    rep(i,365)cout<<1<<endl;
}



Measured memory_bytes: 3628
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int A, B;
    cin >> A >> B;
    if (A == B) {
        cout << "Draw" << endl;
    } else if (A == 1) {
        cout << "Alice" << endl;
    } else if (B == 1) {
        cout << "Bob" << endl;
    } else if (A > B) {
        cout << "Alice" << endl;
    } else {
        cout << "Bob" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
sum_a=[0]*(n+1)
b=[max(0,a[i]) for i in range(n)]
sum_b=[0]*(n+1)
sum_a[1]=a[0]
sum_b[1]=b[0]
for i in range(1,n):
  sum_a[i+1]=sum_a[i]+a[i]
  sum_b[i+1]=sum_b[i]+b[i]
ans=-10**18
for i in range(n-k+1):
  l,r=i,i+k
  cnt=sum_b[l]-sum_b[0]
  cnt+=max(0,sum_a[r]-sum_a[l])
  cnt+=sum_b[n]-sum_b[r]
  ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 17608
import math
a, b, h, m = map(int, input().split())

hour = (h + m / 60) / 12 * math.pi * 2
minute = m / 60 * math.pi * 2

x = a * math.sin(hour) - b * math.sin(minute)
y = a * math.cos(hour) - b * math.cos(minute)
print(math.hypot(x, y))

Measured memory_bytes: 9512
#include<iostream>
#include<string>
#include<vector>
#include <utility>

int main(){
	int x[99999],y[99999],i=0;
	std::cin>>x[i]>>y[i];
	i++;
	while(x[i-1]!=0||y[i-1]!=0){
		std::cin>>x[i]>>y[i];
		i++;
	}
	i=0;
	while(x[i]!=0||y[i]!=0){
		if(x[i]>y[i]){
			std::swap(x[i],y[i]);
		}
		std::cout<<x[i]<<" "<<y[i]<<std::endl;
		i++;
	}
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    long A, B, C, cnt = 0;
    int tmp1 = 0, tmp2 = 0, tmp3 = 0;
    cin >> A >> B >> C;
    /*if(A == B && A == C && B == C){
        cout << -1 << endl;
        return 0;
    }*/
    for(int i = 0; i < 1e9; i++){
        if(A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
            cnt++;
            A /= 2;
            B /= 2;
            C /= 2;
            tmp1 = B + C;
            tmp2 = C + A;
            tmp3 = A + B;
            A = tmp1;
            B = tmp2;
            C = tmp3;
            //cout << A << " " << B << " " << C << endl;
            //cout << cnt << endl;
        }
        else
            break;
        
        if(A == B && B == C && A == C){
            cout<< -1 << endl;
            return 0;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C;
    C.resize(N);
    vector<vector<int> > A;
    A.resize(N);
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
        for (int j = 0; j < M; j++)
        {
            A[i].resize(M);
            cin >> A[i][j];
        }
        
    }
    
    int ans = INT_MAX;
    for (int i = 1; i < (1 << N); i++)
    {
        int cost = 0;
        int skill[12] = {};

        for (int j = 0; j < N; j++)
        {
            if (i & (1 << j))
            {
                cost += C[j];
                for (int k = 0; k < M; k++)
                {
                    skill[k] += A[j][k];
                }
                
            }
            
        }

        bool ok = true;
        for (int i = 0; i < M; i++)
        {
            if (skill[i] < X)
            {
                ok = false;
            }
            
        }

        if (ok)
        {
            ans = min(ans, cost);
        }
        
    }
    
    if (ans == INT_MAX) ans = -1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3180
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	string s;
	cin >> s;
	int zero = 0, one = 0;
	bool current = true;
	for(auto &c : s)
	{
		zero += (current ? c == '0' : c == '1');
		one += (current ? c == '1' : c == '0');
		current ^= 1;
	}
	cout << min(zero, one) << '\n';
}

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

using namespace std;

struct Snum
{
	int num,sum;//数 个数 
};

bool cmp(Snum sn1,Snum sn2)
{
	return sn1.sum<sn2.sum;
}

int n,k,cnt;
int a[200005];
Snum b[200005];

void outb()
{
	for(int i=0;i<=cnt;i++)
	{
		printf("%d:%d个\n",b[i].num,b[i].sum);
	}
}

int main()
{
	//freopen("inp.txt","r",stdin);
	for(int i=0;i<n;i++)
		b[i].sum=0;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	int nn=a[0];
	cnt=0;
	b[cnt].num=nn;
	for(int i=0;i<n;i++)
	{
		if(a[i]==b[cnt].num)
		{
			b[cnt].sum++;
		}
		else
		{
			cnt++;
			b[cnt].num=a[i];
			b[cnt].sum++;
		}
	}
	//outb();
	sort(b,b+cnt+1,cmp);
	//outb();
	int ans=0;
	for(int i=0;i<cnt+1-k;i++)
		ans+=b[i].sum;
	printf("%d",ans);
	return 0;
}



















Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int k,dis[100005];
int main() {
    cin>>k;
    priority_queue<pair<int,int> > pq;
    for(int i=0;i<k;i++) dis[i]=1000000007;
    dis[1]=1;
    pq.push(make_pair(-1,1));
    while (!pq.empty()) {
        pair<int,int> p=pq.top();pq.pop();
        if (-p.first!=dis[p.second]) continue;
        int x=p.second;
        if (dis[x]<dis[(x*10)%k]) {
            dis[(x*10)%k]=dis[x];
            pq.push(make_pair(-dis[(x*10)%k],(x*10)%k));
        }
        if (dis[x]+1<dis[(x+1)%k]) {
            dis[(x+1)%k]=dis[x]+1;
            pq.push(make_pair(-dis[(x+1)%k],(x+1)%k));
        }
    }
    printf("%d\n",dis[0]);
    return 0;
}

Measured memory_bytes: 1276
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

istream& operator>>(istream& in, vector<int>& a) {
  rep(i, 0, a.size()) in >> a[i];
  return in;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  cin >> a;
  int s = accumulate(a.begin(), a.end(), 0);
  sort(a.rbegin(), a.rend());
  cout << (a[m - 1] * 4 * m < s ? "No" : "Yes");
  return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main() {

    int n, x, y;

    cin >> n >> x >> y;
    x--;
    y--;

    vector<int> distance(n, 0);

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

        for(int j = i + 1; j < n; ++j) {

            int d = min(j - i, min(abs(x - i) + 1 + abs(y - j), abs(y - i) + 1 + abs(x - j)));

           // cout << i << ":" << j << " = " << d << endl;

            
            distance[d]++;

        }

    }

    for(int i = 1; i < n; ++i)
        cout << distance[i] << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
    //OJ;
    ll n;
    cin>>n;
    string s;
    while(n){
        int rem=n%26;
        if(rem==0){
            s.PB('z');
            n/=26;
            n--;
            continue;
        }
        char c=rem+96;
        s.PB(c);
        n/=26;
    }
    reverse(s.begin(),s.end());
    cout<<s;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void)
{
  long Ganpon = 100;
  long Target;
  long i = 0;
  scanf("%ld",&Target);

  if(101 <= Target && Target <= 1000000000000000000)
  {
    while(Target > Ganpon)
    {
      Ganpon += Ganpon / 100;
      i++;
    }
    printf("%ld",i);
  }

  return 0;
}

Measured memory_bytes: 1696
def main():
    A = []
    for _ in range(3):
        A.append([int(s) for s in input().strip().split()])
    n = int(input().strip())
    B = []
    for _ in range(n):
        B.append(int(input().strip()))
    
    for row in A:
        for i, x in enumerate(row):
            if x in B:
                row[i] = "*"
    for i in range(3):
        if A[i][0] == A[i][1] == A[i][2] == "*" or A[0][i] == A[1][i] == A[2][i] == "*":
            print("Yes")
            return
    if A[0][0] == A[1][1] == A[2][2] == "*" or A[0][2] == A[1][1] == A[2][0] == "*":
        print("Yes")
        return
    print("No")


main()


Measured memory_bytes: 38460
#include<bits/stdc++.h>
using namespace std;
#define int 		  long long
#define	pb 			  push_back
#define all(a)		  (a).begin(),(a).end()
#define sz(x)		  (int)x.size()
#define endl	 	  "\n"
#define inf 		  1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
//int dp[1000001] = {0};
void solve(){
	int a, b, c;
	cin>>a>>b>>c;
	if(a+b+c>=22){
		cout<<"bust";
	}
	else{
		cout<<"win";
	}
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	return 0;
 
}


Measured memory_bytes: 256