akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        int c = 0;
        int d = 0;
        switch (a) {
            case "A":
                c = 10;
                break;
            case "B":
                c = 11;
                break;
            case "C":
                c = 12;
                break;
            case "D":
                c = 13;
                break;
            case "E":
                c = 14;
                break;
            case "F":
                c = 15;
                break;
        }

        switch (b) {
            case "A":
                d = 10;
                break;
            case "B":
                d = 11;
                break;
            case "C":
                d = 12;
                break;
            case "D":
                d = 13;
                break;
            case "E":
                d = 14;
                break;
            case "F":
                d = 15;
                break;
        }

        if (c<d)
            System.out.println('<');
        else if (c>d)
            System.out.println('>');
        else
            System.out.println('=');
    }
}


Measured memory_bytes: 35588
def Prime_Factorization(N):
    if N<0:
        R=[[-1,1]]
    else:
        R=[]

    N=abs(N)
    k=2
    while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=1

    if N!=1:
        R.append([N,1])
    if not R:
        R.append([N,1])

    return R
#============================
from math import gcd
A,B=map(int,input().split())
G=gcd(A,B)

if G==1:
    print(1)
else:
    P=Prime_Factorization(G)
    print(len(P)+1)

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  vector<int> cnt(2);
  rep(i, s.size()) ++cnt[s[i]-'0'];
  int ans = 0;
  ans = min(cnt[0], cnt[1]) * 2;
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"Sunny", "Cloudy", "Rainy"};

int main(){
    int X, A;
    cin >> X >> A;
    cout << (X >= A) * 10 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	char plane[16][16];
	int i, j;

	while(scanf("%s", plane[0]) != EOF) {
		for(i = 1; i < 8; i++)
			scanf("%s", plane[i]);

		for(i = 0; i < 8; i++) {
			for(j = 0; j < 8; j++)
				if(plane[i][j] == '1') break;
			if(plane[i][j] == '1') break;
		}			

		if(plane[i][j + 1] == '1') {
			if(plane[i][j + 2] == '1') printf("C\n");
			else if(plane[i + 1][j] == '0') printf("E\n");
			else if(plane[i + 1][j + 1] == '0') printf("G\n");
			else printf("A\n");
		}

		else if(plane[i + 2][j] == '1') printf("B\n");
		else if(plane[i + 1][j + 1] == '1') printf("F\n");
		else printf("D\n");
	}

	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int main(){
    int n;cin>>n;
    string k;cin>>k;
    int a=k.size();


    rep(i,a){
   
       if(n-1<i)break;
    cout<<k[i]; 
    }

    if(n<a)cout<<"..."<<endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
 
using namespace std;
 
int main()
{
	long long int a;
	int min=10000;
	vector<int> v;
	
	cin >> a;
	for(int i=0;i<10;i++){
		if(a==0)break;
		v.push_back(a%10);
		a=a/10;

		
	}
	
	for(int i=0;i<v.size()-2;i++){
		if(min > abs(753 - v[i] - 10*v[i+1] - 100*v[i+2]) ){
			min = abs(753 - v[i] - 10*v[i+1] - 100*v[i+2]);
		}
	}
	
	cout << min << endl;
    return 0;
}


Measured memory_bytes: 256
/*input
200000 200000 199999
*/

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

// AtCoder
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  // return permutation mod prime
  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
} c(1000005);

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  mint ans = 0;
  mint x = m;
  for (int i = 0; i <= min(k, n-1); ++i) {
    ans += x*c(n-1, i)*(x-1).pow(n-1-i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 18652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
const int INF = 1e9;

int main(){
  int n, t;
  cin >> n >> t;
  int a[n], b[n], c[n], d[n];
  rep(i,n) {
    cin >> a[i] >> b[i];
    c[i] = a[i]; d[i] = b[i];
  }
  reverse(c,c+n); reverse(d,d+n);
  vector<vector<int>> dpl(n+1,vector<int>(t,-INF)); 
  vector<vector<int>> dpr(n+1,vector<int>(t,-INF));
  dpl[0][0] = 0; dpr[0][0] = 0;
  rep(i,n) {
    rep(j,t) {
      dpl[i+1][j] = max(dpl[i+1][j],dpl[i][j]);
      dpr[i+1][j] = max(dpr[i+1][j],dpr[i][j]);
      if(j > 0) {
        dpl[i+1][j] = max(dpl[i+1][j],dpl[i+1][j-1]);
        dpr[i+1][j] = max(dpr[i+1][j],dpr[i+1][j-1]);
      }
      if(j+a[i] < t) dpl[i+1][j+a[i]] = max(dpl[i+1][j+a[i]],dpl[i][j]+b[i]);
      if(j+c[i] < t) dpr[i+1][j+c[i]] = max(dpr[i+1][j+c[i]],dpr[i][j]+d[i]);
    }
  }
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    int res = 0;
    rep(j,t) res = max(res,dpl[i-1][j]+dpr[n-i][t-1-j]);
    ans = max(ans,res+b[i-1]);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

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

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> dp(11 * 11 * 11);
  FOR(i, N) {
    FORIN(j, 1, 11) {
      FORIN(k, 1, 11) {
        dp[j * 121 + k * 11 + S[i] - '0' + 1] |= dp[j * 121 + k * 11];
      }
      dp[j * 121 + (S[i] - '0' + 1) * 11] |= dp[j * 121];
    }
    dp[(S[i] - '0' + 1) * 121] |= 1;
  }
  int ans = 0;
  FORIN(i, 1, 11) {
    FORIN(j, 1, 11) {
      FORIN(k, 1, 11) {
        if (dp[i * 121 + j * 11 + k] == 1) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    ll n;
    cin >> n;
    ll i = 1;
    int cnt = 1;
    while(cnt <= n){
        i *= cnt;
        i%=1000000007;
        cnt++;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;


namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            int[,] l = new int[s.Length, 26];
            int[] count = new int[26];
            for (int j = 0; j < 26; j++)
            {
                count[j] = -1;
                for (int i = 0; i < s.Length; i++)
                {
                    l[i, j] = -1;
                }
            }

            string ss = s + s;
            for (int i = ss.Length - 1; i > 0; i--)
            {
                int charInd = ss[i] - 'a';
                count[charInd] = 1;


                int arrInd = (i-1) % s.Length;

                for (int j = 0; j < 26; j++)
                {
                    if(l[arrInd, j] < 0)
                    {
                        l[arrInd, j] = count[j];
                    }

                    if (count[j] > 0)
                    {
                        count[j]++;
                    }
                }
            }

            int pos = 0;
            long ans = 0;

            if (t[0] != s[0])
            {
                pos = l[0, t[0] - 'a'];
                if(pos < 0)
                {
                    Console.WriteLine(-1);
                    return;
                }

                ans = pos;
            }

            for (int i = 1; i < t.Length; i++)
            {
                int c = t[i] - 'a';

                if (l[pos, c] < 0)
                {
                    Console.WriteLine(-1);
                    return;
                }

                int step = l[pos, c];

                ans += step;
                pos += step;
                pos %= s.Length;
            }

            Console.WriteLine(ans + 1);
        }

    }
}


Measured memory_bytes: 22240
# ALDS1_8_C: Binary Search Tree 3: Delete

class BinaryTree
  def initialize
    @root = NIL
  end

  def insert(key)
    parent = NIL
    node   = @root
    while node != NIL
      parent = node 
      node = key < node.key ? node.left : node.right
    end

    new_node = Node.new key
    if parent == NIL
      @root = new_node
    elsif key < parent.key
      parent.set_left new_node
    else
      parent.set_right new_node
    end
  end

  def find(key)
    node = @root
    while node != NIL
      break if node.key == key
      node = key < node.key ? node.left : node.right
    end
    node
  end

  def delete(key)
    target = find key
    return if target == NIL

    if target.has_children?
      next_node = target.right.minimum_leaf
      target.key = next_node.key
      target = next_node
    end

    child = target.has_left? ? target.left : target.right
    if target.on_left?
      target.parent.set_left child
    else
      target.parent.set_right child
    end
  end

  def has?(key)
    find(key) != NIL
  end

  def keys_by_preorder(node = @root)
    return [] if node == NIL
    left_keys  = keys_by_preorder(node.left)
    right_keys = keys_by_preorder(node.right)
    [node.key] + left_keys + right_keys
  end

  def keys_by_inorder(node = @root)
    return [] if node == NIL
    left_keys  = keys_by_inorder(node.left)
    right_keys = keys_by_inorder(node.right)
    left_keys + [node.key] + right_keys
  end

  private

    class Node
      attr_accessor :key
      attr_reader :parent, :left, :right

      def initialize(key, parent = NIL, left = NIL, right = NIL)
        @key = key
        set_parent parent, nil
        set_left left
        set_right right
      end

      def set_left(node)
        @left = node
        return if node == NIL
        node.set_parent self, :left
      end
      
      def set_right(node)
        @right = node
        return if node == NIL
        node.set_parent self, :right
      end

      def on_left?
        @on == :left
      end

      def has_children?
        has_left? && has_right?
      end

      def has_left?
        @left != NIL
      end

      def has_right?
        @right != NIL
      end
      
      def minimum_leaf
        node = self
        node = node.left while node.left != NIL
        node
      end

      protected
        def set_parent(node, position)
          @parent = node
          @on = position
        end
    end

    NIL = Node.new(nil).tap do |n|
      [:parent, :left, :right].each do |name|
        define_method(name) { self }
      end
    end
end

tree = BinaryTree.new
n_commands = gets.to_i

n_commands.times do
  command = gets.chomp
  case command
  when /insert (-?\d+)/
    key = $1.to_i
    tree.insert key
  when /find (-?\d+)/
    key = $1.to_i
    puts tree.has?(key) ? 'yes' : 'no'
  when /delete (-?\d+)/
    key = $1.to_i
    tree.delete key
  when /print/
    puts ' ' << tree.keys_by_inorder.join(' ')
    puts ' ' << tree.keys_by_preorder.join(' ')
  end
end

Measured memory_bytes: 107544
#include <cassert>
#include <algorithm>
#include <cctype>
#include <complex>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <typeinfo>
#include <unordered_set>
#include <unordered_map>
#include <vector>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REPD(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define PB(e) push_back(e)
#define FOREACH(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define BIT(n, m) (((n) >> (m)) & 1)

typedef long long ll;

template <typename S, typename T> ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  REP(i, v.size()){
    if (i > 0) out << ", ";
    out << v[i];
  }
  out << "]";
  return out;
}

const int MAX = 110;
const ll mod = 1000 * 1000 * 1000 + 7;
int N;
vector<ll> H;
ll memo1[MAX];
ll memo2[MAX][MAX];
ll memo3[MAX][MAX];
ll memo4[MAX][MAX];

ll modpow(ll n, ll p) {
  ll res = 1;
  while (p > 0) {
    if (p & 1) {
      res *= n;
      res %= mod;
    }
    p >>= 1;
    n = n * n % mod;
  }
  return res;
}

pair<ll, ll> rec(int l, int r, int h) {
  assert(r - l > 0);
  if (r - l == 1) {
    const ll c = modpow(2, H[l] - h);
    return {c, c};
  }

  int min_h = *min_element(H.begin() + l, H.begin() + r);
  assert(min_h > h);

  vector<pair<int, int>> v;
  int i = l;
  while (i < r) {
    int j = i;
    while (j < r && (H[i] == min_h) == (H[j] == min_h)) j++;
    v.push_back({i, j});
    i = j;
  }
  
  int w = count(H.begin() + l, H.begin() + r, min_h);
  int x = min_h;

  ll prod1 = 1;
  ll prod2 = 1;
  for (auto& p : v) {
    int x = p.first, y = p.second;
    if (H[x] != min_h) {
      auto g = rec(x, y, min_h);
      prod1 *= g.first;
      prod1 %= mod;
      prod2 *= g.second + g.first;
      prod2 %= mod;
    }
  }
  ll res1 = modpow(2, min_h - h) * prod1 % mod;
  ll res2 = (modpow(2, w) * prod2 + (modpow(2, min_h - h) - 2) * prod1) % mod;
  return {res1, res2 % mod};
}

int main(int argc, char *argv[])
{
  cin >> N;
  H.resize(N);
  REP(i, N) cin >> H[i];
  cout << rec(0, N, 0).second << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int ans = 0;
  vector<int> V(3);
  for(int i = 0; i < 3; i++)cin >> V[i];
  sort(V.begin(), V.end());
  ans = (V[2] - V[1]) / 2 + (V[2] - V[0]) /2;
  V[1] += ((V[2] - V[1]) / 2) * 2;
  V[0] += ((V[2] - V[0]) / 2) * 2;
  if(V[1] == V[0] && V[2] == V[1]) cout << ans;
  else{
    if(V[2] != V[1] && V[2] != V[0]) cout << ans + 1;
    else cout << ans + 2;
  }
}


Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define VI vector<int>
#define VL vector<lint>
#define VB vector<bool>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVL vector<VL>
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    string a, b;
    cin >> a >> b;
    int ans = 1;
    if(a.size() < b.size()){
        ans = 0;
    }else if(a.size() > b.size()){
        ans = 2;
    }else{
        rep(i, a.size()){
            if(a[i] < b[i]){
                ans = 0;
                break;
            }else if(a[i] > b[i]){
                ans = 2;
                break;
            }
        }
    }
    if(ans == 0){
        cout << "LESS" << endl;
    }else if(ans == 1){
        cout << "EQUAL" << endl;
    }else{
        cout << "GREATER" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <math.h>
using namespace std;
int main()
{
  int a=0,b=0,c=0,d=0,e=0,f=0,i=0,j=0;
  int sum=0,num=0,count=0,ans=0,min=0,max=0;
  double d1=0,d2=0,d3=0,d4=0,d5=0,d6=0;
  int a1[999999],a2[999999],a3[999999];
  string s1,s2,s3;
  
  cin>>a>>s1;
  for(i=0;i<s1.size();i++){
    if(b==0){
      if(s1[i]=='A'){
        b++;
      }
    }else if(b==1){
      if(s1[i]=='B'){
        b++;
      }else if(s1[i] != 'A'){
        b=0;
      }
    }else if(b==2){
      if(s1[i]=='C'){
        ans++;
        b=0;
      }else if(s1[i]=='A'){
        b=1;
      }else{
        b=0;
      }
    }
  }
  cout<<ans<<endl;
}
  
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x " = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b)                                                           \
  TRACE(for (auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V)                                                              \
  TRACE({                                                                      \
    cout << #V " = ";                                                          \
    WATCHR(V.begin(), V.end());                                                \
  })
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ss(x) static_cast<int>((x).size())
#define mp make_pair
#define fi first
#define se second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;
constexpr ll MOD = 1e9 + 7;

inline ll pow_mod(ll a, ll b, ll mod = MOD) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1)
      res = (res * a) % mod;
    a = (a * a) % mod;
  }
  return res;
}

template <typename T> inline void remax(T &x, T y) { x = max(x, y); }

template <typename T> inline void remin(T &x, T y) { x = min(x, y); }

template <typename T> struct BIT {
  vector<T> table;
  int sz;
  T id;
  BIT(int _sz, T _id) : sz(_sz + 1), id(_id) { table.resize(sz); }
  void modify(int idx, T delta) {
    ++idx;
    while (idx < sz) {
      table[idx] += delta;
      idx |= (idx + 1);
    }
  }
  T get(int idx) {
    ++idx;
    T resp = id;
    while (idx > 0) {
      resp += table[idx];
      idx = (idx & (idx + 1)) - 1;
    }
    return resp;
  }
  T get(int l, int r) { return get(r) - get(l - 1); }
};

constexpr int ms = 5 * 1e5 + 13;
vector<int> last_visit(ms, -1);

struct qry { 
  int l, r, id;
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, q;
  cin >> n >> q; 
  vector<int> a(n);
  vector<qry> Q(q); 
  for(int i = 0; i < n; ++i) {
    cin >> a[i]; 
  }
  for(int i = 0; i < q; ++i) {
    int l, r;
    cin >> l >> r;
    --l; --r;
    Q[i].l = l; Q[i].r = r; Q[i].id = i;
  }

  sort(all(Q), [&] (const qry& a, const qry& b) { return a.r < b.r; });
  
  int q_count = 0;
  vector<int> ans(q, 0);
  auto bit = BIT<int>(ms, 0);
  
  for(int i = 0; i < n; ++i) {
    if(last_visit[a[i]] != -1) bit.modify(last_visit[a[i]], -1);
    last_visit[a[i]] = i;
    bit.modify(i, 1);
    while(q_count < q && Q[q_count].r == i) {
      ans[Q[q_count].id] = bit.get(Q[q_count].l, Q[q_count].r);
      q_count++; 
    }
  }
  for(const auto& a : ans) cout << a << '\n';
  return 0;
}


Measured memory_bytes: 17428
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int n = sc.nextInt();
		String s = sc.next();
		List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		int count=0;
		for(int i=0;n-1>i;i++) {
			if(list.get(i).equals(list.get(i+1)))
				count++;
		}

		System.out.println(n-count);
	}
}



Measured memory_bytes: 31588
#include <bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int A,B;
  cin>>A>>B;
  cin>>A>>B;
  if(A<=5)cout<<0<<endl;
  else if(A<=12)cout<<B/2<<endl;
  else cout<<B<<endl;
  return 0;
}


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

int main() {
  int a, b;
  scanf("%d", &a);
  scanf("%d", &b);
  if (a == b) {
    printf("Draw");
  }
  else if (a > b && b != 1 || a == 1)
  {
    printf("Alice");
  }
  else
  {
    printf("Bob");
  }
}

Measured memory_bytes: 256
(n,m) = [int(i) for i  in input().split()]
A = []
b = []
for i in range(n):
    A.append([int(j) for j in input().split()])

for i in range(m):
    b.append(int(input()))

for i in range(n):
    s = 0
    for j in range(m):
        s += A[i][j] * b[j]
    print(s)

Measured memory_bytes: 7012
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    n=int(input())
    a=list(map(int,input().split()))
    b=[0 for i in range(n+1)]
    for i in a:
        b[i]+=1
    total=0
    for i in b:
        total+=i*(i-1)//2

    for i in range(1,n+1):
        temp=total
        if b[a[i-1]]>=2:
            temp-=b[a[i-1]]*(b[a[i-1]]-1)//2
            temp+=(b[a[i-1]]-1)*(b[a[i-1]]-2)//2
        print(temp)




if __name__ == "__main__":

    main()

Measured memory_bytes: 84684
import { readFileSync } from "fs";

const main = (input: string[]) => {
  const nums = input[1].split(" ").map(BigInt);
  const max = 10n ** 18n;

  const hasZero = nums.includes(0n);
  if (hasZero) {
    return 0;
  }

  let prod = 1n;

  for (const num of nums) {
    if (prod * num > max) {
      return -1;
    }

    prod *= num;
  }

  return prod.toString();
};

console.log(main(readFileSync("/dev/stdin", "utf8").split("\n")));


Measured memory_bytes: 44124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
ll n, k;
ll ans;
pair<ll,ll> p[100010];
map<ll,ll> mp, mp1, mp2;
vector<ll> v[100010];

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

  cin >> n >> k;
  for (int i = 0; i < n ; i++) {
    cin >> p[i].second >> p[i].first;
  }
  sort(p, p+n);
  reverse(p, p+n);
  ll cnt = 0;
  for (int i = 0; i < n; i++) {
    if (mp.count(p[i].second) == 0) {
      mp[p[i].second] = cnt;
      v[cnt].push_back(p[i].first);
      cnt++;
    } else {
      v[mp[p[i].second]].push_back(p[i].first);
    }
  }
  ll sum = 0;
  queue<ll> heads;
  for (int i = min(k - 1, cnt - 1); i >= 0; i--) {
    sum += v[i][0];
    heads.push(v[i][0]);
  }

  priority_queue<ll> pq;
  for (int i = 0; i < cnt; i++) {
    for (int j = 1; j < v[i].size(); j++) {
      pq.push(v[i][j]);
      mp1[v[i][j]]++;
    }
  }
  ll tmp = sum;
  for (int i = 0; i < max(0LL, k - cnt); i++) {
    tmp += pq.top();
    mp1[pq.top()]--;
    if (mp1[pq.top()] == 0) mp1.erase(pq.top());
    mp2[pq.top()]++;
    pq.pop();
  }
  ans = max(ans, tmp + min(k,cnt) * min(k,cnt));
  for (ll i = min(k, cnt) - 1; i > 0; i--) {
    tmp -= heads.front();
    heads.pop();
    for (int j = 1; j < v[i].size(); j++) {
      ll num = v[i][j];
      if (mp1.count(num)) {
        mp1[num]--;
        if (mp1[num] == 0) mp1.erase(num);
      } else {
        mp2[num]--;
        tmp -= num;
        tmp += pq.top();
        mp1[pq.top()]--;
        if (mp1.count(pq.top()) == 0) mp1.erase(pq.top());
        mp2[pq.top()]++;
        pq.pop();
      }
    }
    if (pq.empty()) break;
    tmp += pq.top();
    mp1[pq.top()]--;
    if (mp1.count(pq.top()) == 0) mp1.erase(pq.top());
    mp2[pq.top()]++;
    pq.pop();
    ans = max(ans, tmp + i * i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15096
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <string>
#include <math.h>
#include <cstdint>

using namespace std;
using ll = long long;
using P = pair<int, int>;


int main() {
	string s, t;
	cin >> s;
	cin >> t;

	int s_size, t_size;
	s_size = s.size();
	t_size = t.size();

	if (!(s_size + 1 == t_size)) {
		cout << "No";
		return 0;
	}

	for (int i = 0; i <= s.size() - 1; i++) {
		if (!(s[i] == t[i])) {
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";
	return 0;
}


Measured memory_bytes: 3624
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define mp make_pair
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front

using namespace __gnu_pbds;
using namespace std;

#define int ll

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

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int M,D;
    cin>>M>>D;
    int ans=0;
    for(int m=4;m<=M;m++)
        for(int d=22;d<=D;d++)
            if(d%10>=2&&d/10>=2&&(d%10)*(d/10)==m)
                ans++;
    cout<<ans;
}


Measured memory_bytes: 764
#include<stdio.h>

int main(void){
  int D,T,S;
  int time=0;
  scanf("%d %d %d",&D,&T,&S);
  
  time=T*S;
  if(time>=D){
    printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<long long> dpfl(200010, -INF), dpc(200010, -INF);
    dpfl[N-1] = 0LL; dpc[N-1] = A[N-1];
    if(N >= 2){
        dpfl[N-2] = max(A[N-2], A[N-1]);
        dpc[N-2] = max(A[N-2], A[N-1]);
    }
    if(N >= 3) {
        dpfl[N-3] = max({A[N-3], A[N-2], A[N-1]});
        dpc[N-3] = A[N-3] + A[N-1];
    }

    for (int i = N - 4; i >= 0; i--)
    {
        if((N-i) % 2 == 0) {
            dpfl[i] = dpc[i] = max(A[i] + dpfl[i+2], A[i+1] + dpc[i+3]);
        }
        else {
            dpfl[i] = max({A[i] + dpfl[i+2], A[i+1] + dpfl[i+3], dpc[i+2]});
            dpc[i] = A[i] + dpc[i+2];
        }
    }

    cout << dpfl[0] << endl;
    return 0;
}


Measured memory_bytes: 8012
#include <iostream>
#include <vector>
#include <algorithm>
#include "math.h"
using namespace std;
int main(){
int n, a;
cin>>n;
vector<int> A(n, 0);
for(int i = 0; i < n; ++i){
cin>>a;
A[i]=a;
}
long long k = 2;
long long ans = A[0] - 1;
for(int i = 1; i <= n; ++i){
    if(A[i] > k){
        long long t = ceil(A[i] / (double) k) - 1;
        ans += t;
    }
    else if(A[i] == k)k++;
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 768
#include <cstdio>
#include <cstring>
#include <vector>
#include <functional>
#include <algorithm>

int main(void){
    int tmp,n,k;
    char s[100001];
    std::vector<int> v0;
    std::vector<int> v1;
    scanf("%d %d\n",&n,&k);
    scanf("%s",s);
    char *tmp1,*tmp2;

    int m=0;
    tmp1=s;

    v1.push_back(0);
    while(*tmp1!='\0'){
        tmp2=tmp1;
        tmp1+=strspn(tmp1,"0");
        tmp = tmp1-tmp2;
        v0.push_back(tmp);

        tmp2=tmp1;
        tmp1+=strspn(tmp1,"1");
        tmp = tmp1-tmp2;
        v1.push_back(tmp);

        m++;
    }

    tmp = v1[0];
    int i = 0;
    for(;i<std::min(k,m);i++){
        tmp += v0[i] + v1[i+1];
    }
    int ans = tmp;
    for(;i<m;i++){
        tmp = tmp -v0[i-k]-v1[i-k]+v0[i]+v1[i+1];
        if(tmp>ans)ans=tmp;
    }
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
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; }

ll dp[100010];

int main() {

    int n, x;
    cin >> n >> x;

    int l;
    int sum = 0;
    int count = 1;

    for (int i = 0; i < n; i++) {
        cin >> l;
        sum = sum + l;
        if (sum <= x) {
            count ++;
        }
    }

    cout << count << endl;

    return 0;
    

}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
	public void run(){
		int K = ni();
		int T = ni();
		int[] a = new int[T];
		for(int i=0;i<T;i++){
			a[i] = ni();
		}
		int idx = -1;
		for(int i=0;i<K;i++){
			int maxA = -1;
			int maxIdx = -1;
			for(int j=0;j<T;j++){
				if(maxA <= a[j] && idx != j){
					maxA = a[j];
					maxIdx = j;
				}
			}
			if(maxA <= 0){
				break;
			}
			a[maxIdx]--;
			idx = maxIdx;
		}
//		debug(a);
		int max = 0;
		for(int j=0;j<T;j++){
			if(max <= a[j]){
				max = a[j];
			}
		}
		out.println(max);
	}

	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().run();
		out.flush();
	}

	public Main(){
	}

	int ni(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;	}

	long nl(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}

	double nd(){
		return Double.parseDouble(next());
	}

	String next(){
		int c;
		while(!isAlNum(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	String nextLine(){
		int c;
		while(!isAlNumOrSpace(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNumOrSpace(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
	private static boolean isAlNumOrSpace(int c){
		return isAlNum(c) || c == ' ' || c == '\t';
	}
	void debug(Object... os){
		out.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 8532
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000

int main(){
    typedef struct TEAM{
        int AC;
        int WA[12];
        int PE;
        int num;
    } team;

    while(1){
        int t, p, r; cin >> t >> p >> r;
        if(t == 0) break;
        team Team[55];
        
        //?????????
        for(int i = 1; i <= t; i++){
            Team[i].num = i;
            Team[i].AC = 0;
            Team[i].PE = 0;
            for(int j = 1; j <= p; j++) Team[i].WA[j] = 0;
        }

        
        //?????°????????????
        for(int i = 0; i < r; i++){
            int tID, pID, ti; cin >> tID >> pID >> ti;
            string message; cin >> message;

            if(message[0] == 'W'){
                Team[tID].WA[pID]++;
            }else{
                Team[tID].AC++;
                Team[tID].PE += Team[tID].WA[pID] * 1200 + ti;
            }
        }

        int flag = 1;
        while(flag == 1){
            flag = 0;
            for(int i = 1; i < t; i++){
                if(Team[i].PE > Team[i + 1].PE){
                    team temp;
                    temp = Team[i];
                    Team[i] = Team[i + 1];
                    Team[i + 1] = temp;
                    flag = 1;
                    //if(Team[i].PE == Team[j].PE) cout << "nuko" << endl;
                }
            }
        }

        flag = 1;
        while(flag == 1){
            flag = 0;
            for(int i = 1; i < t; i++){
                if(Team[i].AC < Team[i + 1].AC){
                    team temp;
                    temp = Team[i];
                    Team[i] = Team[i + 1];
                    Team[i + 1] = temp;
                    flag = 1;
                    //if(Team[i].PE == Team[j].PE) cout << "nuko" << endl;
                }
            }
        }

        for(int i = 1; i <= t; i++){
            cout << Team[i].num << " " << Team[i].AC << " " << Team[i].PE << endl;
        }
    }

    
    return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
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;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll n,m,l,r,h[100005],a[100005],ans;
int main()
{
    //IOS;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>h[i];
    }
    for(int i=1;i<=m;i++)
    {
        cin>>l>>r;
        if(h[l]>h[r])
        {
            a[r]=1;
        }
        else if(h[l]<h[r])
        {
            a[l]=1;
        }
        else
        {
            a[l]=1;
            a[r]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==0)
        {
            ans++;
        }
    }
    cout<<ans;
    return 0;
}
/*

*/


Measured memory_bytes: 5156
a = list(raw_input())
b = list(raw_input())
sign = False
backup = list(a)
ans = '~' * 100
for a_bi in xrange(len(a) - len(b) + 1):
	#TRY TO RESTORE B AT EVERY BYTE OF A
	#a_bi = byte's index in a
	ok = True
	for b_bi in xrange(len(b)):
		if a[a_bi + b_bi] != '?' and a[a_bi + b_bi] != b[b_bi]:
			ok = False
	if ok:
		#MEANING THAT THIS IS RESTORABLE
		a[a_bi:a_bi + len(b)] = b
		a = ''.join(a).replace('?', 'a')
		ans = min(a, ans)
		a = list(backup)
if ans == '~' * 100:
	print 'UNRESTORABLE'
else:
	print ans

Measured memory_bytes: 2692
#define DEBUG 1

#include <iostream>
#include <vector>
#include <tuple>
#include <queue>
using namespace std;

typedef long long ll;

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

typedef tuple<ll, int> Info;

struct Edge
{
  int to;
  ll cap, cost;
  int rev;
};

class MinCostFlow
{
  int N;
  vector<Edge> *G;
  ll *h, *dist;
  int *prev_v, *prev_e;
  ll INFTY = 10000000000000010;

public:
  MinCostFlow() {}

  MinCostFlow(int n) : N(n)
  {
    G = new vector<Edge>[n];
    h = new ll[n];
    dist = new ll[n];
    prev_v = new int[n];
    prev_e = new int[n];
  }

  void add_edge(int from, int to, ll cap, ll cost)
  {
    G[from].push_back((Edge){to, cap, cost, (int)G[to].size()});
    G[to].push_back((Edge){from, 0, -cost, (int)G[from].size() - 1});
  }

  ll min_cost_flow(int s, int t, ll f)
  {
    ll res = 0;
    fill(h, h + N, 0);
    while (f > 0)
    {
      priority_queue<Info, vector<Info>, greater<Info>> Q;
      fill(dist, dist + N, INFTY);
      dist[s] = 0;
      Q.push(Info(0, s));
      while (!Q.empty())
      {
        Info p = Q.top();
        Q.pop();
        int v = get<1>(p);
        if (dist[v] < get<0>(p))
        {
          continue;
        }
        for (auto i = 0; i < (int)G[v].size(); i++)
        {
          Edge &e = G[v][i];
          ll tmp = dist[v] + e.cost + h[v] - h[e.to];
          if (e.cap > 0 && dist[e.to] > tmp)
          {
            dist[e.to] = tmp;
            prev_v[e.to] = v;
            prev_e[e.to] = i;
            Q.push(Info(dist[e.to], e.to));
          }
        }
      }
      if (dist[t] == INFTY)
      {
        return -1;
      }
      for (auto v = 0; v < N; v++)
      {
        h[v] += dist[v];
      }
      ll d = f;
      for (auto v = t; v != s; v = prev_v[v])
      {
        d = min(d, G[prev_v[v]][prev_e[v]].cap);
      }
      f -= d;
      res += d * h[t];
      for (auto v = t; v != s; v = prev_v[v])
      {
        Edge &e = G[prev_v[v]][prev_e[v]];
        e.cap -= d;
        G[v][e.rev].cap += d;
      }
    }
    return res;
  }
};

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

int N, M;
ll F;
MinCostFlow flow;

int main()
{
  cin >> N >> M >> F;
  flow = MinCostFlow(N);
  for (auto i = 0; i < M; i++)
  {
    int u, v;
    ll c, d;
    cin >> u >> v >> c >> d;
    flow.add_edge(u, v, c, d);
  }
  cout << flow.min_cost_flow(0, N - 1, F) << endl;
}


Measured memory_bytes: 3276
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;

using Graph = vector<vector<int> >;

vector<int> seen;

int main()
{
	int N;

	cin >> N;

	int max_h = 0;
	int h;
	for (int ni = 0; ni < N; ni++) {
		cin >> h;
		if (h > max_h) {
			max_h = h;
		}
		if (max_h > h + 1) {
			printf("No");
			return 0;
		}
	}

	//printf("%.9f", ans);
	std::cout << "Yes";

	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
    }
    
    Scanner sc;
    int a;
    int b;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        a =sc.nextInt();
        b = sc.nextInt();
    }
    
    //解答処理
    int solve() {
        int countTakahashi = 0;
        for (int i=1; i<=a; i++){
            countTakahashi++;
        }
        if (a > b){
            countTakahashi--;
        }
        
        return countTakahashi;
    }
    
    //出力
    void show(int answer) {
        System.out.println(answer);
    }
}


Measured memory_bytes: 35816