akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H==0&&W==0) break;
        for(int j=0;j<H;j++){
            for(int k=0;k<W;k++){
                cout << "#";
            }
            cout << endl;
        }
            cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3100
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

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

		Scanner in = new Scanner(System.in);

		int h = in.nextInt();
		Queue<Long> a = new ArrayDeque<Long>();
		for (int i = 0; i < h; i++) {
			a.add(in.nextLong());
		}

		// solve
		Node nFirst = new Node(++id, a.remove(), Long.MAX_VALUE, null, null);
		Queue<Node> q = new ArrayDeque<>();
		q.add(nFirst);

		for (int i = 1; i < h; i++) {
			while (!q.isEmpty()) {
				Node n = q.peek();
				if (n.left != null) {
					q.add(n.left);
				} else {
					if (!a.isEmpty()) {
						Node newLeftNode = new Node(++id, a.remove(), n.nodeNum, null, null);
						n.left = newLeftNode;
						q.add(newLeftNode);
					}
				}

				if (n.right != null) {
					q.add(n.right);
				} else {
					if (!a.isEmpty()) {
						Node newRightNode = new Node(++id, a.remove(), n.nodeNum, null, null);
						n.right = newRightNode;
						q.add(newRightNode);
					}
					q.remove();
				}
			}
		}

		q.clear();
		q.add(nFirst);

		StringBuffer sb = new StringBuffer();
		for (int i = 1; i < h; i++) {
			while (!q.isEmpty()) {
				Node n = q.remove();
				sb.append("node "+n.id+": key = "+n.nodeNum);
				if (n.parentNodeNum != Long.MAX_VALUE) {
					sb.append(", parent key = "+n.parentNodeNum);
				}
				if (n.left != null) {
					q.add(n.left);
					sb.append(", left key = "+n.left.nodeNum);
				}
				if (n.right != null) {
					q.add(n.right);
					sb.append(", right key = "+n.right.nodeNum);
				}
				sb.append(", \n");
			}
		}

		System.out.print(sb.toString());

	}
	static class Node {
		int id;
		long nodeNum;
		long parentNodeNum;
		Node left;
		Node right;

		public Node(int id, long nodeNum, long parentNodeNum, Node left, Node right) {
			this.id = id;
			this.nodeNum = nodeNum;
			this.parentNodeNum = parentNodeNum;
			this.left = left;
			this.right = right;
		}
	}

}



Measured memory_bytes: 26408
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> >v[57];
long long dp[1<<20];
int x[57];
bool dfs(int now,int fa,int root,int pos){//当前结点，父节点，终结点，所在边编号
    if(now==root)
        return 1;
    for(auto it:v[now]){
        if(it.first!=fa&&dfs(it.first,now,root,pos)){
            x[it.second]^=1<<pos;
            return 1;
        }
    }
    return 0;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    for(int i=1;i<n;++i){
        int a,b;
        cin>>a>>b;
        v[a].emplace_back(b,i);
        v[b].emplace_back(a,i);
    }
    int m;
    cin>>m;
    for(int i=0;i<m;++i){
        int a,b;
        cin>>a>>b;
        dfs(a,0,b,i);//遍历a和b中间的所有结点，即遍历两点之间所有边
    }
    dp[0]=1;//所有的边全白
    for(int i=1;i<n;++i)//每次添加一条边
        for(int j=(1<<m)-1;j>=0;--j)//状压DP，从后往前是为了避免重复加
            dp[j|x[i]]+=dp[j];//dp【j状态|加入第i条边变黑能满足的状态x[i]】+=dp【第i条边加入之前的状态j】
    cout<<dp[(1<<m)-1];//全状态
    return 0;
}

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

using namespace std;

int main(){
  int A,B,C,D,E,F; cin>>A>>B>>C>>D>>E>>F;

  vector<int> x,y;
  
  for(int i=0;100*A*i<=F;i++){
    for(int j=0;100*B*j<=F;j++){
      int temp=0;
      temp=100*(A*i+B*j);
      if(temp<=F){
        x.push_back(temp);
      }
    }
  }
  for(int i=0;100*C*i<=F*E;i++){
    for(int j=0;100*D*j<=F*E;j++){
      int temp=C*i+D*j;
      if(temp*100<=F*E){
        y.push_back(temp);
      }
    }
  }
  
  int w=0,s=0,n=-1;
  for(int i=0;i<x.size();i++){
    for(int j=0;j<y.size();j++){
      int temp_n=0;
      if(x[i]==0&&y[i]==0) temp_n=0;
      else temp_n=10000*y[j]/(x[i]+y[j]);
      if(x[i]+y[j]<=F&&y[j]*100<=x[i]*E&&temp_n>=n){
        n=temp_n; w=x[i]; s=y[j];
      }
    }
  }

  cout<<w+s<<" "<<s<<endl;

  return 0;
}


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

using namespace std;

int cost[33][33];
int cnt[3][33];

void solve() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> cost[i][j];
        }
    }
    memset(cnt, 0, sizeof cnt);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            int x; cin >> x;
            cnt[(i+j)%3][x]++;
        }
    }
    int res = 1e9;
#define rep(x) for(int x=1;x<=m;x++)
    rep(x)rep(y)rep(z){
        if (x==y || x==z || y==z) continue;
        int sum = 0;
        rep(i) sum += cnt[0][i] * cost[i][x];
        rep(i) sum += cnt[1][i] * cost[i][y];
        rep(i) sum += cnt[2][i] * cost[i][z];
        res = min(res, sum);
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

struct Node {
        Node *l, *r, *par;
        int size;
        ll value;
        Node(){
            l = nullptr;
            r = nullptr;
            par = nullptr;
            size = 1;
        }
        bool is_root(){
            return !par or (par->l != this and par->r != this);
        }
    };
//
struct SplayTree{
    
    Node *dat, *root;
    SplayTree(int n){
        dat = new Node[n];
    }
    void connect(int n){
        REP(i, n){
            dat[i + 1].l = &dat[i];
            dat[i].par = &dat[i + 1];
        }
        root = &dat[n];
    }
    void update(Node *me){
        me->size = 1;
        if (me->l) me->size += me->l->size;
        if (me->r) me->size += me->r->size;
    };
    void rotate(Node* me){
        Node *p, *pp, *c;
        p = me->par;
        pp = p->par;
        if(p->l == me){
            c = me->r; p->l = c; me->r = p;
        }
        else{
            c = me->l; p->r = c; me->l = p;
        }
        if (pp and pp->l == p) pp->l = me;
        if (pp and pp->r == p) pp->r = me;
        me->par = pp; p->par = me;
        if (c) c->par = p;
        update(p); update(me);
    };
    int state(Node *me){
    if (!me->par) return 0;
    if (me->par->l == me) return 1;
    if (me->par->r == me) return -1;
    return 0;
    }
    void splay(Node *me){
        while(state(me) != 0){
            if (state(me->par) == 0) {
                rotate(me);
            }
            else if (state(me) == state(me->par)){
                rotate(me->par); rotate(me);
            }
            else{
                rotate(me); rotate(me);
            }
        }
    };
    Node* get(int index){
            Node *now = root;
            while(1){
                int lsize = (now->l ? now->l->size : 0);
                if (index == lsize) {
                    splay(now);
                    root = now;
                    return now;
                }
                if (index < lsize) {
                    now = now->l;
                }
                if (index > lsize) {
                    now = now->r;
                    index -= lsize + 1;
                }
            }
    }
};

SplayTree s(210000);
int main() {
    ll q;
    cin >> q;
    s.connect(q);
    ll sz = 0;
    REP(i, q){
        ll t;
        cin >> t;
        if(t == 0){
            ll a;
            cin >> a;
             Node *now = s.get(sz);
            now->value = a;
            sz++;
        }
        if(t == 1){
            ll a;
            cin >> a;
             Node *now = s.get(a);
            cout << now->value << endl;
        }
        if(t == 2){
            sz--;
        }
    }
}


Measured memory_bytes: 11300
h,w=map(int,input().split())
s=[input() for i in range(h)]
for i in range(h):
    s[i]=[t.replace(".","0") for t in s[i]]
    s[i]=[t.replace("#","-9") for t in s[i]]
    s[i]=[int(t) for t in s[i]]
for i in range(h):
    for j in range(w):
        if s[i][j]<0:
            if i>0:
                s[i-1][j]+=1
                if j>0:
                    s[i-1][j-1]+=1
                if j<w-1:
                    s[i-1][j+1]+=1
            if i<h-1:
                s[i+1][j]+=1
                if j>0:
                    s[i+1][j-1]+=1
                if j<w-1:
                    s[i+1][j+1]+=1
            if j>0:
                s[i][j-1]+=1
            if j<w-1:
                s[i][j+1]+=1

for i in range(h):
    s[i]=["#" if t<0 else t for t in s[i]]
    s[i]=[str(t) for t in s[i]]
    print("".join(s[i]))


Measured memory_bytes: 9296
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main(){
  string s,ans = "";
 
  cin >> s;
  int len = (int)s.size();
  for(int i = 0 ; i < len ; i++){
    string str = "";
    for(int j = 0 ; j < 8 ; j++){
      if(i + j > len) break;
      str += s[i+j];
    }   
    sort(str.begin(),str.end());
    if(str == "AADINNUY"){
      ans += "AIZUNYAN";
      i += 7;
    }else{
      ans += s[i];
    }
  }
  cout << ans << endl;
 
  return 0;
}

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

int main(){
  int n,x,t; cin >>n >>x >>t;
  cout << (n+x-1)/x*t << endl;
  return 0;
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 100 + 5;
const int MAX_N = 1e6;

int main() {
    int k,x;
    cin >> k >> x;
    if (x - k + 1 < -MAX_N) {
        rep(i, k) {
            cout << -MAX_N + i << " ";
        }
        cout << endl;
    } else if (x + k - 1 > MAX_N) {
        revrep(i, k) {
            cout << MAX_N - i << " ";
        }
        cout << endl;

    } else {
        repeat(i, x - k + 1, x + k) {
            cout << i << " ";
        }
        cout << endl;

    }

}

Measured memory_bytes: 256
// Problem : D - Flat Subsequence
// Contest : AtCoder - ACL Beginner Contest
// URL : https://atcoder.jp/contests/abl/tasks/abl_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
    T f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 300003, M = N << 1;

int n, k, a[N];
int tr[N << 2];

inline int ls(int p) {return p << 1;}
inline int rs(int p) {return p << 1 | 1;}

inline void pushup(int p) {tr[p] = max(tr[ls(p)], tr[rs(p)]);}

void modify(int x, int val, int l, int r, int p)
{
	if (l == r) {tr[p] = max(tr[p], val); return;}
	int mid = (l + r) >> 1;
	if (x <= mid) modify(x, val, l, mid, ls(p));
	else modify(x, val, mid + 1, r, rs(p));
	pushup(p);
}

int getans(int ql, int qr, int l, int r, int p)
{
	if (ql <= l && r <= qr) return tr[p];
	int mid = (l + r) >> 1, mx = 0;
	if (ql <= mid) mx = getans(ql, qr, l, mid, ls(p));
	if (qr > mid) mx = max(mx, getans(ql, qr, mid + 1, r, rs(p)));
	return mx;
}

int main()
{
    //File("");
    n = gi <int> (), k = gi <int> ();
    for (int i = 1; i <= n; i+=1) a[i] = gi <int> () + 1;
    for (int i = 1; i <= n; i+=1)
    {
    	int x = getans(max(1, a[i] - k), min(300001, a[i] + k), 1, 300001, 1) + 1;
    	//cout << i << ' ' << x << endl;
    	modify(a[i], x, 1, 300001, 1);
    }
    printf("%d\n", getans(1, 300001, 1, 300001, 1));
    return 0;
}

Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;
const int MOD = 998244353;

struct Combination{
  vector<int> fact; //　fact[i] = iの階乗
  Combination(int n) : fact(n+1){
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= n; i++){
      fact[i] = fact[i-1] * i % MOD;
    }
  }

  int nCr(int n, int r){ // nCr = n!/r!(n-r)!
    if(n < r) return 0;
    return fact[n] * inv(fact[r]*fact[n-r]%MOD) % MOD;
  }

  int inv(int n, int p = MOD-2){ // a/n ≡ a*n^(p-2) nとpは互いに素
    int r = 1;
    for(; p > 0; p >>= 1){
      if(p & 1LL) r = r * n % MOD;
      n = n * n % MOD;
    }
    return r; // r = n^p % MOD
  }
};

signed main(){

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

  Combination c(n+m+k);
  int ans = 0;
  for(int i = 0; i <= k; i++){
    ans = (ans + m * c.inv(m-1, (n - i - 1)) % MOD * c.nCr(n-1, i) ) % MOD;
  }
  cout << ans << endl;

  return 0;
}

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


int main() {

  string s,t;
  cin >> s;
  
  for (auto i : s){
    if (i == '1')
      t += '1';
    
    else if (i == '0')
      t += '0';
    
    else if (t.size())
      t.pop_back();
    
  }
  cout << t;
    
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  rep(i,3) {if(s[i]=='1') s[i]='9';else s[i]='1';}
  print(s);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  int first;
  first = a/100;
  int second;
  second = a/2;
  second = second/5;
  second = second%10;
  
  int halfthird;
  halfthird = a/2;
  double HALFTHIRD;
  HALFTHIRD = a;
  HALFTHIRD = HALFTHIRD/2;
  double different;
  different = (HALFTHIRD - halfthird)*2;
  int third;
  third = different;
  
  int answer;
  answer = first + second + third;  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

int main(){
  int n;cin>>n;
  vector<ll> x(n+1);rep(i,n)cin>>x[i];
  x[n]=1e18+1;
  int l;cin>>l;
  vector<vector<int>> db(18,vector<int>(n,0));
  rep(i,n){
    int idx=upper_bound(all(x),x[i]+l)-x.begin();
    db[0][i]=--idx;
  }
  rep(i,1,18){
    rep(j,n){
      db[i][j]=db[i-1][db[i-1][j]];
    }
  }
  int q;cin>>q;
  rep(_,q){
    int a,b;cin>>a>>b;
    if(a>b)swap(a,b);
    --a;--b;
    int ctr=0;
    for(int i=17;i>=0;--i){
      int p=db[i][a];
      if(p<b){
        a=p;ctr+=(1<<i);
      }
    }
    cout<<ctr+1<<endl;
  }
}

Measured memory_bytes: 8696
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, k;
  cin >> a >> b >> k;
  if (a >= k)
    a -= k;
  else {
    k -= a;
    a = 0;
    b = max(b-k, 0LL);
  }
  cout << a << ' ' << b << endl;
  return 0;
}

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

using namespace std;

using ll = long long;

struct Line {
  ll a, b;

  ll val(ll x) {
    return a * x + b;
  }

  pair<ll, ll> inter(const Line& other) const {
    ll x = other.b - b;
    ll y = a - other.a;

    if (y < 0) {
      x *= -1;
      y *= -1;
    }

    ll g = __gcd(abs(x), y);

    x /= g;
    y /= g;

    return {x, y};
  }
};

ll sq(ll x) {
  return x * x;
}

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

  ll n, c;
  cin >> n >> c;

  vector<ll> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }

  vector<Line> lines;
  ll prev = 0;
  int first = 0;
  for (int i = 0; i < n; ++i) {
    // pop old ones that will never be best again
    while (first <= (int) lines.size() - 2) {
      auto &f = lines[first], &s = lines[first + 1];
      if (f.val(h[i]) >= s.val(h[i])) {
        ++first;
      } else {
        break;
      }
    }

    if (first != lines.size()) {
      prev = lines[first].val(h[i]) + sq(h[i]) + c;
    }

    Line cur = {-2 * h[i], sq(h[i]) + prev};
    while (first <= (int) lines.size() - 2) {
      auto &ll = lines.end()[-2], &l = lines.back();
      auto x1 = ll.inter(cur), x2 = l.inter(cur);
      if ((__int128) x1.first * x2.second >= (__int128) x2.first * x1.second) {
        lines.pop_back();
      } else {
        break;
      }
    }

    lines.emplace_back(cur);
  }

  cout << prev << '\n';

  return 0;
}


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

int main() {
  //vector<int> b(101);
  //b.at(0)=1;
  int N;
  int i,s, ss;
  cin >> N;
  vector<int> V(N), C(N);
  for (i=0; i<N; i++) cin >> V.at(i);
  for (i=0; i<N; i++) cin >> C.at(i);
  for (i=0, s=0; i<N; i++) { 
    ss=V.at(i) - C.at(i);
    if (ss>0) s+=ss;
  }
  cout << s << endl;
  return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(ll, a, b, c);
  ll d = c - (a + b);
  if (d > 0 && 4 * a * b < d * d) {
    out("Yes");
  } else {
    out("No");
  }
}


Measured memory_bytes: 3640
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
from _collections import defaultdict
from functools import lru_cache

class Scanner():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def map_int():
        return [int(x) for x in Scanner.string().split()]
    def string_list(n):
        return [input() for i in range(n)]
    def int_list_list(n):
        return [Scanner.mapInt() for i in range(n)]
    def int_cols_list(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True

MOD = int(1e09) + 7

def main():
    N = Scanner.int()
    A = Scanner.map_int()
    M = defaultdict(int)
    for i in range(N):
        M[A[i]] +=1
        M[A[i] + 1]+=1
        M[A[i] - 1]+=1
    ans = 0
    for v in M.values():
        ans = max(ans,v)
    print(ans)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 65716
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

const int Maxn = 2010;

ll minc[Maxn][Maxn];
ll a[2 * Maxn];
int n;
ll x;

void f(int i, int k) {
    if (k == 0){
        minc[i][k] = a[i];
        return;
    }

    if (i - k < 0)minc[i][k] = min(minc[i][k - 1], a[i + n - k]);
    else minc[i][k] = min(minc[i][k - 1], a[i - k]);
}

int main() {
    cin >> n >> x;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i + n] = a[i];
    }

    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            f(i, k);
        }
    }

    ll ans = numeric_limits<ll>::max();
    for (int k = 0; k < n; ++k) {
        ll cost = k * x;
        for (int i = 0; i < n; ++i) {
            cost += minc[i][k];
        }
        ans = min(ans, cost);
    }

    cout << ans << endl;
}

Measured memory_bytes: 31744
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;

const int N = 200010;
int n, m;

vector <int> e[N];

inline int read()
{
	char ch = getchar(); int x = 0;
	while (ch < '0' || ch > '9') ch = getchar();
	while (ch >= '0' && ch <= '9'){
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x;
}

int main()
{
	n = read(); m = read();
	for (int i = 1; i <= m; i ++){
		int x, y;
		x = read(); y = read();
		/*bool flag = true;
		for (int j = 0; j < e[x].size(); j ++)
			if (e[x][j] == y){
				flag = false;
				break;
			}
		if (flag){*/
			e[x].push_back(y);
			e[y].push_back(x);
		//}
	}
	for (int i = 2; i < n; i ++)
	{
		bool flag1 = false, flag2 = false;
		for (int j = 0; j < e[i].size(); j ++){
			if (e[i][j] == 1) flag1 = true;
			if (e[i][j] == n) flag2 = true;
			if (flag1 && flag2){
				puts("POSSIBLE");
				return 0;
			}
		}
	}
	puts("IMPOSSIBLE");
	return 0;
}

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

using namespace std;

long long n, m;

long long check(long long n, long long m)
{
	return min(n, m / 2);
}


int main()
{
	scanf("%lld %lld", &n, &m);
	long long L = 0, R = m / 2;
	while (L < R)
	{
		long long M = (L + R) >> 1;
		if (check(n + M, m - M * 2) > check(n + M + 1, m - (M + 1) * 2))
			R = M;
		else
			L = M + 1;
	}
	printf("%lld\n", check(n + L, m - L * 2));
	return 0;
}


Measured memory_bytes: 128
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {
	int n;
	ll T;
	cin >> n >> T;
	vector<ll>t(n);
	ll sum = 0;
	rep(i, n)cin >> t[i];
	rep(i, n - 1) {
		ll d = t[i + 1] - t[i];
		if (d > T)sum += T;
		else sum += d;
	}
	sum += T;
	cout << sum;
	return 0;
}





Measured memory_bytes: 1792
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int[] a) {
    auto dq = new Deque!int(a.length);
    dq.pushBack(a[0]);

    void dump() {
        int[] x;
        foreach (i; 0..dq.size()) {
            x ~= dq[i];
        }
        writeln(">> ", x.map!text.join(" "));
    }

    foreach (e; a.drop(1)) {
        int lo = 0;
        int hi = dq.size() - 1;
        int best = hi + 1;
        while (lo <= hi) {
            int m = (lo + hi) / 2;
            if (dq[m] >= e) {
                best = min(best, m);
                hi = m - 1;
            } else lo = m + 1;
        }

        if (best == 0) dq.pushFront(e);
        else dq[best-1] = e;
    }
    return dq.size();
}

void main() {
    int n = readint;
    int[] a;
    foreach (_; 0..n) a ~= readint;
    writeln(calc(a));
}

class Deque(T) {
    private T[] _buffer;
    private size_t _size;
    private int _front;
    private int _back;

    this(size_t size) {
        _buffer = new T[size * 3];
        _size = 0;
        _front = _back = cast(int)size * 3 / 2;
    }

    @property bool empty() {
        return _size == 0;
    }

    int size() {
        return cast(int)_size;
    }

    void pushFront(T elt) {
        if (_size == 0) {
            _buffer[_front] = elt;
        }
        else {
            _buffer[--_front] = elt;
        }
        _size++;
    }

    void pushBack(T elt) {
        if (_size == 0) {
            _buffer[_back] = elt;
        }
        else {
            _buffer[++_back] = elt;
        }
        _size++;
    }

    T opIndex(size_t index) {
        return _buffer[_front + index];
    }

    T opIndexAssign(T value, size_t index) {
        return _buffer[_front + index] = value;
    }
}


Measured memory_bytes: 4860
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <string>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <deque>
using namespace std;
const int maxn = 200005;
long long a[maxn], N, K;
bool ok(long long w)
{
    long long sum = 0;
    for (int i = 1; i <= N; i++)
        sum += (a[i] - 1) / w;
    if (sum <= K)
        return 1;
    else
    {
        return 0;
    }
}
int main()
{
    cin >> N >> K;
    long long l = 1, r = 0;
    for (int i = 1; i <= N; i++)
    {
        cin >> a[i];
        r = max(r, a[i]);
    }
    if (K == 0)
        cout << r << endl;
    else
    {
        while (l <= r)
        {
            long long mid = (l + r) / 2;
            if (ok(mid))
                r = mid - 1;
            else
                l = mid + 1;
        }
        cout << l << endl;
    }
}

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

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define endl '\n'
#define int long long
#define pb emplace_back
#define range(v) v.begin(),v.end()
#define ff first
#define ss second
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e6 + 10)

using namespace std;


int solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int &i : a) cin >> i;
	sort(range(a));
	vector<bool> p(N, false);
	int cnt = 0;
	for (int idx = 0; idx < n; idx++) {
		int i = a[idx];
		if (idx != n - 1 and a[idx] == a[idx + 1]) {
			p[i] = true;
			continue;
		}
		list<int> div;
		for (int j = 1; j * j <= i; j++)
			if (i % j == 0) div.pb(j), div.pb(i / j);
		bool f = true;
		for (int j : div) {
			if (p[j]) {
				f = false;
				break;
			}
		}
		if (f) cnt++;

		p[i] = true;
	}
	return cnt;
}

int32_t main() {
	fast
	int t_c = 1;
	// cin >> t_c;
	while (t_c--) {
		auto ans = solve();
		cout << ans << endl;
	}
}

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

#define REP(i, n) for(int i=0; i<n; i++)
#define REPA(i, a, n) for(int i=a; i<n; i++)
#define REPE(i, a, n) for(int i=a; i<=n; i++)
#define SetArray(a, n) for(int array_i=0; array_i<n; array_i++) cin >> a[array_i]
#define print(x) cout << x
#define printw(x) cout << x << " "
#define println(x) cout << x << endl
#define printl() cout << endl
#define sqr(x) (x)*(x)
#define cube(x) (x)*(x)*(x)
typedef long long ll;
typedef unsigned int uint;
typedef vector<int> vi;

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

    println(a + a*a + a*a*a);
    return 0;
}




Measured memory_bytes: 3620
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int a=in.nextInt();
    int b=in.nextInt();
    int c=in.nextInt();
    int k=in.nextInt();
    while(k!=0)
    {
      if(a>=b)
      {
        b*=2;
      }
      else if(b>=c)
      {
        c*=2;
      }
      k--;
    }
    if((c>a && c>b) && b>a)
    {
      System.out.println("Yes");
    }
    else
    {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35548
#include "bits/stdc++.h"
using namespace std;
int Red[100005] , Green[100005] , Colorless[100005];

pair<long long,pair<int,int> > FindGreenColorlessPointers( int Y , int B , int C ){
    long long Sum = 0LL;
    int i = 1 , j = 1 , k = 1;

    while( i <= B && j <= C && k <= Y ){
        if( Green[i] > Colorless[j] ){
            Sum = Sum + Green[i];
            ++i;
        }
        else{
            Sum = Sum + Colorless[j];
            ++j;
        }

        ++k;
    }

    while( k <= Y && i <= B ){
        Sum = Sum + Green[i];
        ++i;
        ++k;
    }

    while( k <= Y && j <= C ){
        Sum = Sum + Colorless[j];
        ++j;
        ++k;
    }

    return make_pair( Sum , make_pair( i , j ) );
}

long long FindMaxDeliciousness( int X , int Y , int A , int B , int C ){
    int i , PG , PC;
    long long Ans , Sum = 0LL;

    for( i = 1 ; i <= X ; ++i )
        Sum = Sum + Red[i];

    pair<long long,pair<int,int> > P = FindGreenColorlessPointers( Y , B , C );
    PG = P.second.first;
    PC = P.second.second;
    Sum += P.first;
    Ans = Sum;

    for( i = X ; i >= 1 ; --i ){
        if( C < X - ( i - 1 ) ) break;  
        Sum = Sum - Red[i];

        if( PG <= Y && PG <= B ){
            if( PC <= C ){
                if( Green[PG] > Colorless[PC] ){
                    Sum = Sum + Green[PG];
                    ++PG;
                }
                else{
                    Sum = Sum + Colorless[PC];
                    ++PC;
                }
            }
            else{
                Sum = Sum + Green[PG];
                ++PG;
            }   
        }
        else{
            Sum = Sum + Colorless[PC];
            ++PC;
        }
  
        Ans = max( Ans , Sum );
    } 

    return Ans;
}

int main(){
    int X , Y , A , B , C , i;
    scanf( "%d%d%d%d%d" , &X , &Y , &A , &B , &C );

    for( i = 1 ; i <= A ; ++i )
        scanf( "%d" , Red + i );
    for( i = 1 ; i <= B ; ++i )
        scanf( "%d" , Green + i );
    for( i = 1 ; i <= C ; ++i )
        scanf( "%d" , Colorless + i );

    sort( Red + 1 , Red + A + 1 , greater<int>() );
    sort( Green + 1 , Green + B + 1 , greater<int>() );
    sort( Colorless + 1 , Colorless + C + 1 , greater<int>() );
    printf( "%lld\n" , FindMaxDeliciousness( X , Y , A , B , C ) );
    return 0;
}

Measured memory_bytes: 1408
/*Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
map<long long,long long>mp;map<long long,long long>::iterator it;
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a;
        mp[a]++;
    }
    it=mp.begin();
    f=0;
    while(it!=mp.end()){
        if(it->second%2){
            f++;
        }
        it++;
    }
    cout<<f<<'\n';
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int A[200000], N, T;
int main(){
  long long res;
  rd(N);
  rd(T);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  res = T;
  {
    int KL2GvlyY;
    for(KL2GvlyY= 1;KL2GvlyY< (N-1) + 1;KL2GvlyY++){
      res += min(T, A[KL2GvlyY]-A[KL2GvlyY - (1) + (0)]);
    }
  }
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20170429-1

// --- original code ---
// int N, T, A[200000];
// {
//   ll res;
//   rd(N,T,A(N));
//   res = T;
//   res += min(T, A[1..N-1]-A[0..]);
//   wt(res);
// }


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

int main(){
  int m, f, r;
  while (true){
    cin >> m >> f >> r;
    if(m == -1 && f == -1 && r == -1){
      break;
    }
    if(m == -1 || f == -1){
      cout << "F" << endl;
    }else if(m + f >= 80){
      cout << "A" << endl;
    }else if(m + f >= 65 && m + f < 80){
      cout << "B" << endl;
    }else if(m + f >= 50 && m + f < 65){
      cout << "C" << endl;
    }else if(m + f >= 30 && m + f < 50){
      if(r >= 50){
        cout << "C" << endl;
      }else{
        cout << "D" << endl;
      }
    }else{
      cout << "F" << endl;
    }
  }
}


Measured memory_bytes: 3092
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  int d[100000];
  for(int i=0;i<N;i++){
  cin>>d[i];
  }
  sort(d,d+N);
  cout<<d[N/2]-d[N/2-1]<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

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

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  ll g = 0;
  REP(i, n) {
    cin >> a[i];
    g = gcd(g, a[i]);
  }
  REP(i, n) {
    ll t = a[i] - k;
    if (t >= 0 && t % g == 0) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back

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

    ll x,a,b;
    cin >> x >> a >> b;
    if(abs(x-a)<abs(x-b)) cout << 'A' << "\n";
    else cout << 'B' << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define method(name,res,...) function<res (__VA_ARGS__) > name = [&](__VA_ARGS__) -> res
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;


void func(int a,int l){
  method(func,int,int x){
    vector<int> line;
    rep(i,l){
      line.push_back(x%10);
      x/=10;
    }
    sort(all(line));
    int low = 0;
    int high = 0;
    rep(i,l){
      low *= 10;
      high *= 10;
      low += line[i];
      high += line[l-i-1];
    }
    return high - low;
  };
  vector<int> line(1,a);
  while(true){
    line.emplace_back(func(line.back()));
    rep(i,line.size()-1){
      if(line.back()==line[i]){
        cout << i << " " << line.back() << " " << line.size()-i-1 << endl;
        return;
      }
    }
  }
}

int main(){
  int a;
  int l;
  while(cin>>a>>l&&a+l){
    func(a,l);
  }

  return 0;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, K, Q;
    cin >> N >> K >> Q;
    // vector<ll> A(Q);
    map<ll, ll> cnt; rep(i, N){cnt[i] = 0;}
    rep(i, Q){ll tmp; cin >> tmp; tmp--; cnt[tmp] += 1;}
    rep(i, N){if ((K - (Q - cnt[i])) > 0){cout << "Yes" << endl;}else{cout << "No" << endl;} }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  int i = 0;
  if (S[0] == 'R'){
    if (S[1] == 'R'){
      if (S[2] == 'R'){
        i = 3;
      }
      else {
        i = 2;
      }
    }
    else {
      i = 1;
    }
  }
  else {
    if (S[1] == 'R'){
      if (S[2] == 'R'){
        i = 2;
      }
      else {
        i = 1;
      }
    }
    else {
      if (S[2] == 'R'){
        i = 1;
      }
    }
  }
        
  cout << i << endl;
  
  return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>

void swap(int *a, int *b) {
	int temp = *a;
	*a = *b;
	*b = temp;
}

void maxHeapify(int A[], int i, int H) {
	int l = (2*i)+1;
	int r = (2*i)+2;
	int largest;

	if(l<H && A[l]>A[i]) 
	{
		largest = l;
	}
	else 
	{
		largest = i;
	}
	
	if(r<H && A[r]>A[largest]) 
	{
		largest = r;
	}
	if(largest != i) {
		swap(&A[i], &A[largest]);
		maxHeapify(A, largest, H);
	}
}

void buildMaxHeap(int A[], int H) {
	for(int i = (H/2)-1; i >= 0; i--) {
		maxHeapify(A, i, H);
	}
}

int main() {
	int H;
	int A[500005];
	scanf("%d", &H);
	for(int i = 0; i < H; i++) 
	{
		scanf("%d", &A[i]);
	}
	buildMaxHeap(A, H);
	for(int i = 0; i < H; i++) {
		printf(" %d", A[i]);
	}
	printf("\n");
	
	return 0;
}




Measured memory_bytes: 4556
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define UP(i,a,b) for(int i=(a); i<=(b); ++i)
#define DOWN(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) UP(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/

/**********************************/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W, H, N;
    bool sq[101][101] {{0}};
    cin >> W >> H >> N;
    REP(i, N) {
        int x, y, a;
        cin >> x >> y >> a;
        if(a==1) {
            REP(r,H) REP(c,x) sq[r][c] = true;
        }
        else if(a==2) {
            REP(r, H) UP(c,x,W-1) sq[r][c] = true;
        }
        else if(a==3) REP(r, y) REP(c, W) sq[r][c] = true;
        else UP(r,y,H-1) REP(c,W) sq[r][c] = true;
    }
    int ans = 0;
    REP(i, H) REP(j, W) {
        if(!sq[i][j]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <queue>
#include <bits/stl_numeric.h>

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;


int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int res = 0;
    vector <int> p(n);
    REP(i,n)cin >> p[i];
    vector <int> ok(n, 0);

    int iMin = MOD;

    for(int i = 0; i < n; ++i)
    {
        iMin = min(iMin, p[i]);

        if(iMin == p[i])++res;

    }


    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

ll gcd(ll x, ll y) {
	return y != 0 ? gcd(y, x % y) : x;
}

int main() {
	string s;
	cin >> s;
	int a = 0, b = 0;
	for (int i = 0;i < s.size();++i) {
		if (s[i] == '1')++a;
		else ++b;
	}
	cout << min(a, b) * 2 << "\n";

	return 0;
}

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

ll rec(ll a, ll b){
    if(b<a) swap(a, b);

    if(b%a==0) return 2 * b - a;
    else return rec(a, b%a) + b / a * 2 * a;
}

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

    cout << rec(x, n-x) + n << endl;;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

vector<string> memo;
string str;
bool change['z'-'a'+1];
void rec(int p, string s) {
  if (p == str.size()) {
    memo.push_back(s);
    return;
  }

  if (change[str[p]-'a']) {
    if (str[p] != 'z' && !change[str[p]+1-'a']) {
      s[p] = s[p]+1;
      change[s[p]-'a'] = true;
      rec(p+1, s);
      change[s[p]-'a'] = false;
      s[p] = s[p]-1;
    }
    rec(p+1, s);
  }else if (str[p] == 'a'){
    if (!change['b'-'a']) {
      s[p] = s[p]+1;
      change[s[p]-'a'] = true;
      rec(p+1, s);
      change[s[p]-'a'] = false;
      s[p] = s[p]-1;
    }
    rec(p+1, s);
  }else {
    if (str[p] == 'z') {
      return;
    }
    if (!change[str[p]+1-'a']) {
      s[p] = s[p]+1;
      change[s[p]-'a'] = true;
      rec(p+1, s);
      change[s[p]-'a'] = false;
    }
  }
}

int main() {
  while (true) {
    cin >> str;
    if (str == "#") break;

    vector<string> emptyvec;
    memo = emptyvec;
    memset(change, false, sizeof(change));
    rec(0, str);
    if (str == "z") {
      std::cout << 0 << std::endl;
    }else {
      std::cout << memo.size() << std::endl;
      sort(memo.begin(), memo.end());
      if (memo.size() > 10) {
        for (int i = 0; i < 5; i++) {
          std::cout << memo[i] << std::endl;
        }
        for (int i = memo.size()-5; i < memo.size(); i++) {
          std::cout << memo[i] << std::endl;
        }
      }else {
        for (int i = 0; i < memo.size(); i++) {
          std::cout << memo[i] << std::endl;
        }
      }
    }
  }
}

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

int main()
{
    int64_t n;
    cin >> n;
    string ans = "";

    while(n > 0){
        int64_t tmp = n % 26;
        if(tmp == 0){
            tmp += 26;
        }
        n -= tmp;
        n /= 26;
        ans += ('a'+tmp-1);
    }
    
    reverse(ans.begin(), ans.end());

    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int n;
map<int,int> mp;
long long ans;
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		mp[x]++;
	}
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
		int nw=it->second;
		int nd=it->first;
		if(nw>=nd)ans+=nw-nd;
		else ans+=nw;
	}
	cout<<ans<<endl;
    return 0; 
}

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

using namespace std;

#define min(a, b) ((a) < (b)? (a):(b))
#define max(a, b) ((a) > (b)? (a):(b))
#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(int i=(a); i<(n); i++)

struct rect{
    int h, w, d;
    bool operator<(const rect& r) const {
        return d < r.d || (d == r.d && h < r.h);
    }
    bool operator>(const rect& r) const {
        return d > r.d || (d == r.d && h > r.h);
    }
};

int main() {
    while(true) {
        int h, w; cin >> h >> w;
        if(h == 0 && w == 0) break;
        
        rect r = {h, w, h*h + w*w};
        rect minr = {200, 200, 40000};
        REP(p, 1, 151) {
            REP(q, p+1, 151) {
                rect s = {p, q, p*p+q*q};
                if(s > r) minr = min(minr, s);
            }
        }
        cout << minr.h << " " << minr.w << endl;
    }
}



Measured memory_bytes: 3052