akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k, a, b, i;
  cin >> k >> a >> b;
  bool flag = false;
  i = k;
  while(k<=b)
  {
    if(k>=a && k<=b)
    {
      cout << "OK" << endl;
      flag = true;
      break;
    }
    k +=i;
  }
      if(!flag)
        cout << "NG" << endl;
}

Measured memory_bytes: 3632
import numpy as np

n =int(input())
S = [str(input()) for _ in range(0,n)]

def Count_Alphabet(word):
    string = str(word)
    alphabet=str("abcdefghijklmnopqrstuvwxyz")
    count = np.zeros(len(alphabet))
    
    for i in range(0,len(alphabet)):
        for j in range(0,len(string)):
            if alphabet[i] == string[j]:
                count[i] += 1
    
    return count
  
S_stat = np.ones((n,26))
for i in range (0,n):
    S_stat[i] = Count_Alphabet(S[i])
    
Min_sta = np.ones(26)
for i in range(0,26):
    Min_sta[i] = min(S_stat[:,i])
    
ans = str()
alphabet=str("abcdefghijklmnopqrstuvwxyz")
for i in range(0,26):
    ans += str(alphabet[i])*int(Min_sta[i])

print(ans)

Measured memory_bytes: 20628
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<char,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
const double PI=acos(-1);
using namespace std;

int main( ) {
    ll A,B,C,D,E;
    cin>>A>>B>>C>>D>>E;
    if(A==0) cout<<1<<endl;
    if(B==0) cout<<2<<endl;
    if(C==0) cout<<3<<endl;
    if(D==0) cout<<4<<endl;
    if(E==0) cout<<5<<endl;
    }


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll n, m, k, a[15][15], c[15], val[15], ans = inf;

void kombinasi(ll nilai, ll x){
	if(nilai > ans){
		return;
	}
	bool bl = 1;
	for(ll i = 0; i < m; i++){
		if(val[i] < k){
			bl = 0;
		}
	}
	if(bl){
		ans = min(nilai, ans);
	}
	for(ll i = x; i < n; i++){
		for(ll j = 0; j < m; j++){
			val[j] += a[i][j];
		}
		kombinasi(nilai + c[i], i + 1);
		for(ll j = 0; j < m; j++){
			val[j] -= a[i][j];
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n >> m >> k;
	for(ll i = 0; i < n; i++){
		cin >> c[i];
		for(ll j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	kombinasi(0, 0);
	if(ans == inf){
		ans = -1;
	}
	cout << ans << '\n';
	
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#include <utility>
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1e9
typedef long long int ll;
using namespace std;

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

    cout << min(a,b) << " " << max(0,(b+a)-n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	ll operator()() {
		return 0;
	}
};

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

	for(;;)
	{
		int l, r, d;
		cin >> l >> r >> d;
		if(cin.fail()) break;

		int ans=r/d-(l-1)/d;
		cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;

vector<vector<P>> ver;
vector<int> ans;
int ansnum = 0;

void dfs(int x, int ng){
  int col = 1;
  for(auto p: ver[x]){
    if(ans[p.second] != 0) continue;
    if(col == ng) ++col;
    ans[p.second] = col;
    ansnum = max(ansnum, col);
    dfs(p.first, col);
    ++col;
  }
}

int main(){
  int n, a, b;
  cin >> n;
  ver.resize(n);
  ans.resize(n);
  for(int i=0; i<n-1; ++i){
    cin >> a >> b;
    --a; --b;
    ver[a].push_back(make_pair(b,i));
    ver[b].push_back(make_pair(a,i));
  }
  dfs(0, -1);
  cout << ansnum << endl;
  for(int i=0; i<n-1; ++i){
    printf("%d\n",ans[i]);
  }
}

Measured memory_bytes: 9660
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}


console.log(main());
function main(){
  var n = o.a();
  var k = o.a();
  var h = o.l();
  var ans = 0;
  for(var i = 0; i < n; i++)if(k <= h[i])ans++;
  return ans;
}

Measured memory_bytes: 16588
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N, A, B;
    scan(N, A, B);
    if ((B - A) & 1)
    {
        writeln("Borys");
    }
    else
    {
        writeln("Alice");
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define precise cout.precision(8); cout << fixed;
#define seed srand(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
using namespace std;

ll solve(ll N, ll k) {
    ll quo = N / k;
    ll ans = k * ((quo * (quo + 1)) / 2);
    return ans;
}

int main() {

    zoom;    
    ll N; cin >> N;
    ll ans = (N * (N + 1)) / 2;
    ll rem = solve(N, 3) - solve(N, 15) + solve(N, 5);
    cout << ans - rem;
    return 0;
}

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

int main()
{
  int64_t N, M, acs, was = 0;
  cin >> N >> M;
  vector<int64_t> AC(N + 1, 0), WA(N + 1, 0);
  for (int64_t i = 0; i < M; i++)
  {
    int64_t p;
    string s;
    cin >> p >> s;
    if (s == "AC")
    {
      if (AC.at(p) == 0)
        AC.at(p)++;
    }
    else
    {
      if (AC.at(p) == 0)
        WA.at(p)++;
    }
  }
  acs = accumulate(AC.begin(), AC.end(), 0);
  for (int i = 0; i <= N; i++)
  {
    if (AC.at(i) != 0)
    {
      was += WA.at(i);
    }
  }
  cout << acs << ' ' << was << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    int white_cnt = 0;
    REP(i, h) {
        cin >> s[i];
        REP(j, w)if(s[i][j] == '.') white_cnt++;
    }
    vector<VI> dist(h, VI(w, INT_MAX));

    queue<pair<int, int>> search_q;
    search_q.push(make_pair(0, 0));
    dist[0][0] = 0;
    while(search_q.size() > 0) {
        int x = search_q.front().first;
        int y = search_q.front().second;
        search_q.pop();
        if(x == h - 1 and y == w - 1) break;
        REP(i, 4) {
            int adj_x = x + dx[i];
            int adj_y = y + dy[i];
            if(adj_x < 0 or h <= adj_x) continue;
            if(adj_y < 0 or w <= adj_y) continue;
            if(s[adj_x][adj_y] == '.') {
                search_q.push(make_pair(adj_x, adj_y));
                dist[adj_x][adj_y] = dist[x][y] + 1;
                s[adj_x][adj_y] = '#';
            }
                
        }
    }
    int ans = dist[h - 1][w - 1];
    cout << (ans == INT_MAX ? -1 : white_cnt - ans - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int N,s;
  s=0;
  cin >> N;
  vector<int> A(100001);
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    s += x;
    A.at(x)++;
  }
  int Q;
  cin >> Q;
  for(int j=0;j<Q;j++){
    long int B,C;
    cin >> B >> C;
    A.at(C) += A.at(B);
    s += (C-B)*A.at(B);
    cout << s << endl;
    A.at(B)=0;
  }
}


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

using namespace std;

int main(){
        int n,cnt = 0, maxcnt = 0;
        cin >> n;
        int arr[n] = {0};
        for(int i = 0; i < n; i++){
                cin >> arr[i];
        }
        for(int i = 0; i < n-1; i++){
                if(arr[i] >= arr[i+1]){
                        cnt++;
                        if(maxcnt < cnt)
                                maxcnt = cnt;
                }
                        
                else
                        cnt = 0;
        }
        cout << maxcnt << endl;
}                     

Measured memory_bytes: 640
use proconio::*;

fn run() {
    input! {
        n: usize,
        a: [u64; n + 1],
    }
    if n == 0 {
        if a[0] != 1 {
            println!("-1");
        } else {
            println!("1");
        }
        return;
    }
    if a[0] != 0 {
        println!("-1");
        return;
    }
    let mut sum = a.clone();
    for i in (0..n).rev() {
        sum[i] += sum[i + 1];
    }
    let mut ans = 1u64;
    let mut cnt = 1u64;
    for i in 1..=n {
        cnt = std::cmp::min(2 * cnt, sum[i]);
        if cnt < a[i] {
            println!("-1");
            return;
        }
        ans += cnt;
        cnt -= a[i];
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y,z,k;
    cin>>x>>y>>z>>k;
    vector<ll> a(x),b(y),c(z);
    rep(i,x){
      cin>>a[i];
    }
    rep(i,y){
      cin>>b[i];
    }
    rep(i,z){
      cin>>c[i];
    }
    sort(begin(a),end(a),greater<ll>());
    sort(begin(b),end(b),greater<ll>());
    sort(begin(c),end(c),greater<ll>());  
    vector<ll> sum1,sum2,sum3;
    vector<ll> ans;
    rep(i,x){
      rep(j,y){
        sum1.push_back(a[i]+b[j]);
      }
    }
    sort(begin(sum1),end(sum1),greater<ll>());
    rep(i,min(k,len(sum1))){
      sum2.push_back(sum1[i]);
    }
    rep(i,min(k,len(c))){
      sum3.push_back(c[i]);
    }
    rep(i,len(sum2)){
      rep(j,len(sum3)){
        ans.push_back(sum2[i]+sum3[j]);
      }
    }
    sort(begin(ans),end(ans),greater<ll>());
    rep(i,k){
      cout<<ans[i]<<'\n';
    }
}

Measured memory_bytes: 43384
#include <stdio.h>
#include <stdlib.h>

#define SWAP(a, b, v) v = a, a = b, b = v

int
partition(int *a, int p, int r)
{
	int x = a[r];
	int i, v;

	for (i = p; i < r; i++) {
		if (a[i] > x)
			continue;

		SWAP(a[p], a[i], v);
		p++;
	}

	SWAP(a[p], a[r], v);

	return p;
}

int
main(void)
{
	int i, n, q;
	int *a;

	scanf("%d", &n);

	a = (int *)malloc(sizeof(int) * n);
	if (a == NULL)
		return 1;

	for (i = 0; i < n; i++)
		scanf("%d", a + i);

	q = partition(a, 0, n - 1);

	for (i = 0; i < q; i++)
		printf("%s%d", i ? " " : "", a[i]);
	printf(" [%d]", a[i++]);
	for (; i < n; i++)
		printf(" %d", a[i]);
	puts("");

	return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (int)(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 ALL(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
 
bool vector_find(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) {
        return true;
    }
    else {
        return false;
    }
}
 
int main(){
  	int n;
  	vector<int> v;
  	vector<int> c;
  	int X=0,Y=0;
  	cin >> n;
  
  	for(int i=0;i<n;i++){
      int x;
      cin >> x;
      v.push_back(x);
    }
  	for(int i=0;i<n;i++){
      int x;
      cin >> x;
      c.push_back(x);
    }
  
  	for(int i=0;i<n;i++){
      if(v[i]>c[i]){
        X+=v[i];
        Y+=c[i];
      }
    }
  	
  	cout<<X-Y;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin>>H>>W;
        if(H==0 && W==0) break;
        
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
            cout <<"#";
        }
        cout<<"\n";
    
    }
    cout <<"\n";
}
return 0;
}


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

#define ll long long
#define ar array

const int mxN=1e5;
int x, y, a, b, c, p[mxN+1], q[mxN+1], r[2*mxN];
ll ans;

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

    cin >> x >> y >> a >> b >> c;
    for(int i=0; i<a; ++i)
        cin >> p[i];
    sort(p, p+a);
    for(int i=0; i<b; ++i)
        cin >> q[i];
    sort(q, q+b);
    p[a]=q[b]=1e9;
    for(int i=0; i<c; ++i)
        cin >> r[i];
    c=max(x+y, c);
    sort(r, r+c);
    for(int i=0; i<x; ++i)
        ans+=p[a-1-i];
    for(int i=0; i<y; ++i)
        ans+=q[b-1-i];
    for(int i=0, j1=a-x, j2=b-y; i<x+y; ++i) {
        if(r[c-1-i]<=p[j1]&&r[c-1-i]<=q[j2])
            break;
        ans+=r[c-1-i];
        if(p[j1]<q[j2])
            ans-=p[j1++];
        else
            ans-=q[j2++];
    }
    cout << ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;
	//int a,b,c;cin>>a>>b>>c;
	vint a(3);cin>>a[0]>>a[1]>>a[2];
	sort(all(a));
	cout << a[2] - a[0] << endl;
	//cout << (int)min(abs(b-a)+(int)abs(c-b), (int)abs(c-a)+(int)abs(c-b)) << endl;
	return 0;
}


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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

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


int main(void) {
	
	while (1) {
		int n;
		int x, y;
		int count = 0;
		int posx = 10;
		int posy = 10;
		int jwe[21][21] = {};
		int m;
		char d;
		int l;

		cin >> n;
		if (n == 0) {
			break;
		}
		FOR(i, 1, n) {
			cin >> x >> y;
			jwe[x][y]++;
		}
		cin >> m;
		FOR(i, 1, m) {
			cin >> d >> l;
			switch (d) {
			case 'N':
				FOR(t, 1, l) {
					posy++;
					if (jwe[posx][posy] > 0) {
						count++;
						jwe[posx][posy]--;
					}
				}
				break;
			case 'E':
				FOR(t, 1, l) {
					posx++;
					if (jwe[posx][posy] > 0) {
						count++;
						jwe[posx][posy]--;
					}
				}
				break;
			case 'S':
				FOR(t, 1, l) {
					posy--;
					if (jwe[posx][posy] > 0) {
						count++;
						jwe[posx][posy]--;
					}
				}
				break;
			case'W':
				FOR(t, 1, l) {
					posx--;
					if (jwe[posx][posy] > 0) {
						count++;
						jwe[posx][posy]--;
					}
				}
				break;
			}
		}
		if (n == count) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

}


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

using namespace std;
const int mod = 1e9+7;
const int N = 200005;

int n, a[N];

bool f(int k) {
	multiset<int> s;
	for(int i = 0; i < k; i++) s.insert(-1);
	for(int i = 1; i <= n; i++) {
		auto it = s.lower_bound(a[i]);
		if(it == s.begin()) return false;
		it--;
		s.erase(it);
		s.insert(a[i]);
	}
	return true;
}

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", a + i);
	
	int lo = 1, hi = n - 1, ans = n;
	while(lo <= hi) {
		int mid = (lo + hi) / 2;
		if(f(mid)) ans = mid, hi = mid - 1;
		else lo = mid + 1;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 7296
#include<stdio.h>
#include<math.h>

typedef struct{
  double x;
  double y;
} xy;
void kock(int,xy,xy);

int main(){
  int n;
  xy p1,p2;
  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y=0;

  scanf("%d",&n);
  printf("%f %f\n",p1.x,p1.y);
  kock(n,p1,p2);
  printf("%f %f\n",p2.x,p2.y);
  return 0;
}
void kock(int n,xy p1,xy p2){
  xy s;
  xy t;
  xy u;

  if(n==0) return;

  s.x=(2*p1.x+p2.x)/3;
  s.y=(2*p1.y+p2.y)/3;
  t.x=(p1.x+2*p2.x)/3;
  t.y=(p1.y+2*p2.y)/3;
  u.x=(t.x-s.x)/2-(t.y-s.y)*sqrt(3)/2+s.x;
  u.y=(t.x-s.x)*sqrt(3)/2+(t.y-s.y)/2+s.y;
  kock(n-1,p1,s);
  printf("%f %f\n",s.x,s.y);
  kock(n-1,s,u);
  printf("%f %f\n",u.x,u.y);
  kock(n-1,u,t);
  printf("%f %f\n",t.x,t.y);
  kock(n-1,t,p2);
  return;
}



Measured memory_bytes: 2052
$l = [1]
50.times {|i|
  $l[i+1] = $l[i] * 2 + 3
}

$p = [1]
50.times {|i|
  $p[i+1] = $p[i] * 2 + 1
}

def f(n, x)
  # puts "n=#{n} x=#{x}"
  if n == 0
    x
  elsif x <= 0
    0
  elsif x == 1
    0
  elsif x >= $l[n]
    $p[n]
  else
    if x >= $l[n-1] + 2
      y = x - $l[n-1] - 2
      f(n-1, y) + $p[n-1] + 1
    else
      f(n-1, x-1)
    end
  end
end

n,x=gets.split.map(&:to_i)
p f(n, x)

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<bits/stdc++.h>
using namespace std;

/*define*/
#define rep(i, n) for(int i=0; i<n; ++i)
#define endl "\n"
typedef long long ll;
//typedef pair<int, int> P;
static const int max_n = 1000001, max_m = 102;
static const int  INF = 1000000000;
int ci;

vector<int> A(max_n);
ll n, a;

int main(){
    cin >> n;
    rep(i, n){
        cin >> a;
        A[a]++;
    }
    int ans=0;
    rep(i, max_n){
        if(A[i]==0) continue;
        if(A[i]==1) ans++;
        for(int j=2*i; j<max_n; j+=i) A[j] = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7068
// https://atcoder.jp/contests/abc124/tasks/abc124_c

package main

import "fmt"

func main() {
	var s string
	fmt.Scanf("%s", &s)

	var diff int
	for i, c := range s {
		m := '0'
		if i%2 == 1 {
			m = '1'
		}

		if c != m {
			diff++
		}
	}

	if len(s)-diff < diff {
		diff = len(s) - diff
	}

	fmt.Println(diff)
}


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

#define MAX_N 100005

struct UnionFind{
    ll par[MAX_N]; // 親
    ll rank[MAX_N]; // 木の深さ
    ll siz[MAX_N]; // 素集合のサイズ

    // n要素で初期化
    void init(ll n){
        for(ll i=0;i<n;i++){
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }

    // 木の根を求める
    ll root(ll x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = root(par[x]);
        }
    }

    // xとyの属する集合を併合
    bool unite(ll x, ll y){
        x = root(x);
        y = root(y);
        if(x==y) return false; // 併合失敗
        if(rank[x] < rank[y]){
            par[x] = y;
            siz[y] += siz[x];
        }else{
            par[y] = x;
            siz[x] += siz[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
        return true; // 併合成功
    }

    bool issame(ll x, ll y){
        return root(x)==root(y);
    }

    ll size(ll x){
        return siz[root(x)];
    }
};


int main(){
    UnionFind uf;
    ll n, m;
    cin >> n >> m;
    ll a[m], b[m];
    rep(i, m){
        cin >> a[i] >> b[i];
        --a[i];
        --b[i];
    }

    uf.init(n);
    ll ans[m];
    ans[m-1] = n*(n-1)/2;
    for(int i=m-2;i>=0;i--){
        if(uf.issame(a[i+1], b[i+1])){
            ans[i] = ans[i+1];
        }else{
            ans[i] = ans[i+1] - uf.size(a[i+1]) * uf.size(b[i+1]);
            uf.unite(a[i+1], b[i+1]);
        }
    }
    rep(i, m){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 6016
main = getContents >>= putStr . unlines . map solve . init . map (rl . words) . lines

rl :: [String] -> [Int]
rl = map read

solve :: [Int] -> String
solve [] = []
solve (x:y:[]) = if x > y then (show y) ++ " " ++ (show x)
                          else (show x) ++ " " ++ (show y)


Measured memory_bytes: 4528
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> vi;
struct edge { int v; ll w; };

const int MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;

int main() {
	int N; cin >> N;
	vector<int> dp(N * 5), diff(N * 5);
	diff[0] = 1; diff[1] = -1;
	int ans = 0, prev = 0;
	rep(i, N) {
		dp[i] = (prev + diff[i]) % MOD;
		if (i != N - 1) {
			diff[i + 1] = (diff[i + 1] + dp[i]) % MOD;
			diff[i + 2] = (diff[i + 2] - dp[i]) % MOD;
			diff[i + 3] = (diff[i + 3] + dp[i]) % MOD;
			diff[i + N + 2] = (diff[i + N + 2] - dp[i]) % MOD;
		}
		if (i == N - 1) ans = (ans + (ll)dp[i] * N) % MOD;
		else ans = (ans + (ll)dp[i] * (N - 1) % MOD * (N - 1)) % MOD;
		prev = dp[i];
	}
	for (int i = N; i <= N * 3; i++) {
		dp[i] = (prev + diff[i]) % MOD;
		ans = (ans + dp[i]) % MOD;
		prev = dp[i];
	}
	cout << (ans + MOD) % MOD << endl;
}


Measured memory_bytes: 39296
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,A,B;cin>>N;
  for(int i=1;i<sqrt(N)+1;i++){
    if(N%i==0)A=i;
  }
  B=N/A;
  B=log10(B);
  cout<<B+1<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      long a = sc.nextLong();
      long b = sc.nextLong();
      long c = sc.nextLong();
      long sa = c-a-b;
      
      if(sa<=0){
        System.out.println("No");
        return;
      }
      if(4*a*b<sa*sa){
        System.out.println("Yes");
        return;
      }
      System.out.println("No");

    }
  
  private static long lcm(long m, long n) {
    return m * n / gcd(m, n);
}
  
  private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
}
}


Measured memory_bytes: 21972
#include <iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n,s[1000],p[1000],q[1000],r[1000],c[1000],i,P,Q,R,C,z=0;
    while(cin>>n){
        if(n==0)break;
        for(i=0;i<n;i++){
            cin>>s[i]>>p[i]>>q[i]>>r[i];
            c[i]=p[i]*4+q[i]*9+r[i]*4;
        }
        cin>>P>>Q>>R>>C;
        for(i=0;i<n;i++){
            if(P>=p[i]&&Q>=q[i]&&R>=r[i]&&C>=c[i]){
                cout<<s[i]<<endl;
                z=s[i];
            }
            
        }
        if(z==0)cout<<"NA"<<endl;
        z=0;
    }
          return 0;
}

Measured memory_bytes: 3120
#include<stdio.h>
int main()
{
    int money,coin,i,j,k,l ;
    scanf("%d%d",&money,&coin);
    if((money % 500)<=coin)
    {
        printf("Yes");
    }
    else if(money<coin || money%500==0){
         printf("Yes");
    }
    else{
            printf("No");
    }
    return 0;
}


Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define sec second
#define f first
#define pb push_back
#define pf push_front
#define po pop_back
const ll mod=1000000007;
#define fast ios_base::sync_with_stdio(false)
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pii pair<ll,ll>
#define set set<ll>
#define map map<ll,ll>
#define tostr to_string
#define toint stoi
#define gcd __gcd
ll maxm(ll a,ll b){return a>b?a:b;}
ll minm(ll a,ll b){return a>b?b:a;}
#define max maxm
#define min minm
ll powr(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=result*x;x=x*x;n=n/2;}return result;}
#define pow powr
const ll inf=1e18;
const double pi=3.1415926535897932384626433832795;


int main()
{
   fast;

   ll n,i,j;
   cin>>n;

   if(n==1)
   {
    cout<<0<<endl;
    return 0;
   }
   vi v;
   ll k=n,ans=0;
   for(i=2;i*i<=k;i++)
   {
     if(n%i==0)
     {
        ll c=0;
        while(n>0 && n%i==0)
        {
          n=n/i;
          c++;
        }

        j=1;
        ll res=0;
        while(1)
        {
          c-=j;
          if(c>=0)
          res++;
          else
            break;
         j++;
        }
        ans+=res;
     }
   }
   if(n>1)
    ans++;
   cout<<ans<<endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	long long i;
	cin>>s;
	long long n=s.length(),st=0,end=n-1,c=0;
	while(st<end)
	{
		if(s[st]==s[end])
		{
			st++;
			end--;
		}
		else
		{
			c++;
			break;
		}
	}
	if(c==0)
	{
		end=(n-1)/2-1,st=0,c=0;
		while(st<end)
		{
			if(s[st]==s[end])
			{
				st++;
				end--;
			}
			else
			{
				c++;
				break;
			}
		}
		if(c==0)
		{
			st=(n+3)/2-1,end=n-1;
			while(st<end)
			{
				if(s[st]==s[end])
				{
					st++;
					end--;
				}
				else
				{
					c++;
					break;
				}
			}
			if(c==0)
			{
				printf("Yes\n");
				return 0;
			}
			else
			{
				printf("No\n");
				return 0;
			}
		}
		else
		{
			printf("No\n");
			return 0;
		}
	}
	else
	{
		printf("No\n");
		return 0;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<ll, ll> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}


 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	// freopen("dislodging_logs_input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	string s;
	cin >> s;

	int ans = 0;
	for(auto &c : s){
		ans = (ans + (c - '0'));
		ans %= 9;
	}

	cout << (ans ? "No" : "Yes") << endl;


	return 0;
}


Measured memory_bytes: 3708
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i=1;
  while(++i<=n){
    int x=i;
    if(x%3==0){
      cout << " " << i;
      continue;
    }
    while(x){
      if(x%10==3){
	cout << " " << i;
	break;
      }
      x/=10;
    }
  }
  cout << endl;
  return 0;
}


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

using namespace std;

long long int f(long long n) {
    if (n == 1) return 1;
    return f(n / 2) * 2 + 1;
}

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

    cout << f(n) << endl;
    return 0;
}


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

const int64_t MOD= 1000000007;
const int Nfac= 100037;
#define MEMORY 1 // 1/0: 階乗を配列に格納をする前処理をする/しない
/* 剰余環 Z/nZ */
struct mint{ // Z/nZ に関する演算(n:素数の場合は除算も)をサポートする構造体
  int64_t rep; // 出力すべき代表元 rep \in {0,1,..,MOD- 1}
  mint(int64_t x=0): rep(((x%MOD)+ MOD)% MOD){}
  mint operator-() const { return mint(-rep);}
  mint& operator+=(const mint& x){
    rep+= x.rep; 
    if(rep>= MOD) rep-= MOD;
    return *this;
  }
  mint& operator-=(const mint& x){
    rep-= x.rep;
    if(rep< 0) rep+= MOD;
    return *this;
  }
  mint& operator*=(const mint& x){
    rep*= x.rep; rep%= MOD;
    return *this;
  }
  mint operator+(const mint x) const {
    mint ans(*this);
    ans+= x;
    return ans;
  }
  mint operator-(const mint x) const {
    mint ans(*this);
    ans-= x;
    return ans;
  }
  mint operator*(const mint x) const {
    mint ans(*this);
    ans*= x;
    return ans;
  }

  mint pow(int64_t d) const{ // d \geq 0
    if(d==0) return 1;
    else{
      mint ans= pow(d>>1);
      ans*= ans;
      if(d&1){ ans*= *this; }

      return ans;
    }
  }

  friend ostream& operator << (ostream &os, const mint& x) noexcept{
      return os << x.rep;
  }
  // MOD が素数(<=> Z/nZ が体)のとき
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint& x){
    *this *= x.inv();
    return *this;
  }
  mint operator/(const mint x) const {
    mint ans(*this);
    ans/= x;
    return ans;
  }
};

/* 階乗,二項係数 */
#if (MEMORY==1)
// 前処理として,階乗を配列に格納をするver.
vector<mint> mfac(Nfac+1), ifac(Nfac+1);
void fact_modp_init(int N= Nfac){
  mfac.at(0)= 1;
  mint buf;
  for(int i=1; i<=N; i++){
    buf= i;
    mfac.at(i)= mfac.at(i-1)* buf;
  }

  ifac.at(N)= mfac.at(N).inv();
  for(int i=N; i>0; i--){
    buf= i;
    ifac.at(i-1)= ifac.at(i)* buf;
  }
}
#else
// 前処理を回避するver.
void fact_modp_init(int N= Nfac){}
mint mfac(int N){
  mint ans= 1;
  mint buf;
  for(int i=1; i<=N; i++){
    buf= i;
    ans*= buf;
  }

  return ans;
}
#endif

mint binom_modp(int n, int k){
  if(n < 0 || min(k,n-k) < 0) return 0;
  else{
#if (MEMORY==1)
    return mfac.at(n)* ifac.at(k)* ifac.at(n-k);
#else
    return mfac(n)* mfac(k).inv()* mfac(n-k).inv();
#endif
  }
}
// ^^^ テンプレここまで ^^^

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

  unordered_map<int, int> factors;
  int div= 2;
  while(M > 1){
    int cnt= 0;
    while(M%div==0){
      cnt++;
      M/= div;
    }
    if(cnt > 0){
      factors[div]= cnt;
    }
    div++;
  }

  fact_modp_init(Nfac);
  mint ans= 1;
  for(auto &e:factors){
    int p,d;
    tie(p,d)= e;
    ans*= binom_modp(N+d-1, d);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
import math
n, m = map(int, input().split())
fact = []
ans = 1
MAX = int(math.sqrt(m)) + 1
for i in range(1, MAX):
    if m % i == 0:
        fact.append(i)
        if i != m // i:
            fact.append(m//i)
fact.sort()
for x in fact:
    if m < n * x:
        break
    ans = x
print(ans)

Measured memory_bytes: 9136
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); i++)	
using namespace std;


int max(int a,int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


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

	if (n % 500 <= a) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	
	//配列の要素数
	Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
	
	//配列の要素
	int A[] = new int[n];	
	//Scanner sc = new Scanner(System.in);
	for(int i=0;i<A.length;i++){
	    A[i]= scanner.nextInt();
	}
	Sort(A,n);
	Print(A,n);
    }
    //並べ替え
    private static void Sort(int A[], int n){
	for(int i=1; i < n; i++){
	    int v = A[i];
	    int j = i-1;
	    Print(A,n);
	    while(j >= 0 && A[j] > v){
		A[j+1] = A[j];
		j--;
	    }                                            
	    A[j+1] = v;
	}
    }
    //表示
    private static void Print(int A[], int n){
	for(int k=0;k<A.length;k++){
	    System.out.print(A[k]);
	    if(k < (n-1)){
		System.out.print(" ");
	    }
	}
	System.out.println();
    }
}



Measured memory_bytes: 34564
N = int(input())
A = list(map(int, input().split()))
MAX_A = 10**5
dp = [0] * (MAX_A + 1)
for i in range(N):
    dp[A[i]] += 1

tmp = 0
for j in range(MAX_A + 1):
    if dp[j] > 0:
        tmp += dp[j] - 1
tmp += tmp % 2
print(N - tmp)

Measured memory_bytes: 14396
h,w=map(int,input().split())
p=[1 for x in range(w)]
l=list()

for i in range(h):
  s=input()
  if '#' in s:
    l.append(s)
    for j in range(w):
      p[j] *= 1 if s[j]=='.' else 0

for i in range(len(l)):
  for j in range(w):
    if p[j]==0:
      print(l[i][j],end='')
  print()


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

typedef long long LL;
typedef pair<int,int> PII;
const int M=2e5+5;

map<int,int> mr,mc;

int main()
{
	//freopen("F.in","r",stdin);
	int n,q; scanf("%d%d",&n,&q);
	LL ans=1LL*(n-2)*(n-2);
	int con,x;
	mr[n]=n-1;
	mc[n]=n-1;
	//cout<<ans<<endl;
	while(q--)
	{
		scanf("%d%d",&con,&x);
		if(con==1)
		{
			auto it=mr.lower_bound(x);
			ans-=it->second-1;
			if(it==mr.begin())
			{
				mc[it->second]=x-1;
				mr[x]=it->second;
			}
		}
		else
		{
			auto it=mc.lower_bound(x);
			ans-=it->second-1;
			if(it==mc.begin())
			{
				mr[it->second]=x-1;
				mc[x]=it->second;
			}
		}
		//cout<<ans<<endl;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 13008
def f(a, b)
  r = a.size - b.size
  return r if r != 0
  a.size.times{|i|
    r = a[i].to_i - b[i].to_i
    return r if r != 0
  }
  return 0
end

A = gets.chomp
B = gets.chomp
puts case f(A, B)
when 1..1.0/0; "GREATER"
when 0; "EQUAL"
else "LESS"
end

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

#define MAX 2000

int main(){
  int n, i, j, a[20], dp[MAX+1], in;

  memset(dp,0,sizeof(dp));

  scanf("%d" ,&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d" ,a + i);
  }

  dp[0] = 1;
  for(i = 0 ; i < n ; i++){
    for(j = MAX ; j >= 0 ; j--){
      if(dp[j] && j + a[i] <= MAX){
        dp[j + a[i]] = 1;
      }
    }
  }
  
  scanf("%d" ,&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d" ,&in);
    if(dp[in]){
      puts("yes");
    }else{
      puts("no");
    }
  }

  return 0;
}

Measured memory_bytes: 584
def C_Good_Sequence():
    N=int(input())
    a=list(map(int, input().split()))
    count={}
    ans=0
    
    for num in a:
        count[num]= count.get(num,0)+1

    for num in count:
        if num > count[num]:
            ans += count[num]
        elif num < count[num]:
            ans += count[num]-num
    
    print(ans)
   
C_Good_Sequence()

Measured memory_bytes: 17780
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/
/* libnum {{{*/
void amax(N, Args...)(ref N x, Args y) {
  x = x.max(y);
}
void amin(N, Args...)(ref N x, Args y) {
  x = x.min(y);
}
auto maxE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amax(y);
  return x;
}
auto minE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amin(y);
  return x;
}
/*}}}*/


/+---test
TSTTSS
---+/
/+---test
SSTTST
---+/
/+---test
TSSTTTSS
---+/

void main(string[] args) {
  const S = readln.chomp;

  long rem, dep;
  foreach (c; S) {
    if (c == 'S') {
      ++dep;
    }
    if (c == 'T' && dep > 0) {
      --dep;
      ++rem;
    }
  }
  (S.length - rem*2).writeln;
}


Measured memory_bytes: 2684
"use strict";
function Main(input) {
  input = input.split("\n");
  const person = input[1].split(" ");
  let rates = [];
  
  for(let i=0; i < 9; i++){
    rates[i] = 0;
  }
    
  for(let personCount=0; personCount < person.length; personCount++){
    let inputValue = parseInt(person[personCount], 10);
    if(1 <= inputValue && inputValue < 400){
      rates[0] = 1;
    }
    else if(400 <= inputValue && inputValue < 800){
      rates[1] = 1;
    }
	else if(800 <= inputValue && inputValue < 1200){
      rates[2] = 1;
	}
	else if(1200 <= inputValue && inputValue < 1600){
      rates[3] = 1;
	}
	else if(1600 <= inputValue && inputValue < 2000){
      rates[4] = 1;
    }
    else if(2000 <= inputValue && inputValue < 2400){
      rates[5] = 1;
    }
    else if(2400 <= inputValue && inputValue < 2800){
      rates[6] = 1;
	}
	else if(2800 <= inputValue && inputValue < 3200){
      rates[7] = 1;
    }
    else if(3200 <= inputValue && inputValue <= 4800){
      rates[8] += 1;
    }
  }
  
  let  color = 0;
  for(let colorCount=0; colorCount < 8; colorCount++){
    color += rates[colorCount];
  }
  
  let max = color + rates[8];
  let min = color;
  
  if(color === 0 && rates[8] > 0){
    min = 1;
  }
  console.log(min,max);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

typedef long long ll;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

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

    int w, n;
    int a, b;
    char ch;

    scanf("%d", &w);
    scanf("%d", &n);

    vector<int> v(w);

    int i;

    for (i = 1; i <= w; i++) v[i - 1] = i;

    while (n--) {
        scanf("%d%c%d", &a, &ch, &b);

        a--;
        b--;

        swap(v[a], v[b]);
    }

    for (i = 0; i < w; i++) printf("%d\n", v[i]);

    return 0;
}

Measured memory_bytes: 3096
// A - Limited Insertion

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	vector<int> b(N+1);

	for (int i=1; i<=N; i++) {
		cin >> b[i];
	}

	vector<int> ans;

	while(1) {
		bool removed = false;
		for (int i = b.size() - 1; i>=1; i--) {
			if (i == b[i]) {
				ans.push_back(b[i]);
				b.erase(b.begin() + i);
				removed = true;
				break;
			}
		}

		if (removed == false) break;
	}

	if (ans.size() == N) {
		reverse(ans.begin(), ans.end());
		for (int a : ans) {
			cout << a << endl;
		}
	} else {
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 3516
#include <stdio.h>

int main() {

  int n,i,j;
  int card[4][13];
  int num;
  long long moji;

  scanf("%d", &n);

  for(j=0; j<4; j++) {
  for(i=0; i<13 ;i++){
    card[j][i] = 0;
  }
  }

  for(i=0; i<2*n ; i++) {
    scanf("%c ",&moji);
    scanf("%d",&num);
    if(moji == 'S') {
      card[0][num-1] = 1;
    } else if(moji == 'H') {
      card[1][num-1] = 1;
    } else if(moji == 'C') {
      card[2][num-1] = 1;
    } else if(moji =='D') {
      card[3][num-1] = 1;
    }
  }

  for(j=1;j<=13;j++) {
    if(card[0][j-1] != 1) {
      printf("S %d\n",j);
    }
  }
  for(j=1;j<=13;j++) {
    if(card[1][j-1] != 1) {
      printf("H %d\n",j);
    }
  }
  for(j=1;j<=13;j++) {
    if(card[2][j-1] != 1) {
      printf("C %d\n",j);
    }
  }
  for(j=1;j<=13;j++) {
    if(card[3][j-1] != 1) {
      printf("D %d\n",j);
    }
  }
   return 0;
}

Measured memory_bytes: 596
W, H, N = map(int, input().split())

l, r, d, u = 0, W, 0, H
for _ in range(N) :
    x, y, a = map(int, input().split())
    if a == 1 :
        l = max(l, x)
    elif a == 2 :
        r = min(r, x)
    elif a == 3 :
        d = max(d, y)
    else :
        u = min(u, y)

if l <= r and d <= u :
    print((r - l) * (u - d))
else :
    print(0)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define pb push_back
#define mp make_pair
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef long long ll;
using namespace std;

namespace IO
{
    const uint32 Buffsize=1<<15,Output=1<<24;
    static char Ch[Buffsize],*S=Ch,*T=Ch;
    inline char getc()
	{
		return((S==T)&&(T=(S=Ch)+fread(Ch,1,Buffsize,stdin),S==T)?0:*S++);
	}
    static char Out[Output],*nowps=Out;
    
    inline void flush(){fwrite(Out,1,nowps-Out,stdout);nowps=Out;}

    template<typename T>inline void read(T&x)
	{
		x=0;static char ch;T f=1;
		for(ch=getc();!isdigit(ch);ch=getc())if(ch=='-')f=-1;
		for(;isdigit(ch);ch=getc())x=x*10+(ch^48);
		x*=f;
	}

	template<typename T>inline void write(T x,char ch='\n')
	{
		if(!x)*nowps++='0';
		if(x<0)*nowps++='-',x=-x;
		static uint32 sta[111],tp;
		for(tp=0;x;x/=10)sta[++tp]=x%10;
		for(;tp;*nowps++=sta[tp--]^48);
		*nowps++=ch;
	}
}
using namespace IO;

inline void file()
{
#ifndef ONLINE_JUDGE
	FILE*WA=freopen("water.in","r",stdin);
	FILE*TER=freopen("water.out","w",stdout);
#endif
}

const int MAXN=2e5+7;

static int n,a[MAXN];

inline void init()
{
	read(n);
	Rep(i,1,n)read(a[i]);
}

inline bool Judge(int x)
{
	static map<int,int>G;
	G.clear();
	Rep(i,2,n)if(a[i]<=a[i-1])
	{
		G.erase(G.upper_bound(a[i]),G.end());
		++G[a[i]];
		for(int k=a[i];k&&G[k]==x;--k)
			G.erase(k),++G[k-1];
		if(G.find(0)!=G.end())return 0;
	}
	return 1;
}

inline void solve()
{
	static int flg=1;
	Rep(i,2,n)if(a[i]<=a[i-1]){flg=0;break;}
	if(flg)cout<<1<<endl,exit(0);
	int l=2,r=n,md;
	while(l<=r)
	{
		md=(l+r)>>1;
		if(Judge(md))r=md-1;
		else l=md+1;
	}
	cout<<l<<endl;
}

int main()
{
    init();
    solve();
    return 0;
}

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

#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
#define repinv(i, st, n) for (int i = ((n)-1); i >= (st); --i)
#define MEM(a, b) memset(a, b, sizeof(a));
#ifdef LOCAL
#define debug(x) std::cerr << #x << ": " << x << endl
#else
#define debug(x) 860111
#endif
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileIO(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

//mt19937 mrand(random_device{}());
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {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;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
pii operator+(const pii&x, const pii&y) { return mp(x.X+y.X, x.Y+y.Y);}
pii operator-(const pii&x, const pii&y) { return mp(x.X-y.X, x.Y-y.Y);}
//INT_MAX, ULLONG_MAX, LLONG_MAX or numeric_limits<int>::min()

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

//------------------------------------------------------------------------//
int T;
const int maxn = 2e5+7;
int n;
//ll a[maxn];

vector<pii> G[maxn];
bool color[maxn];
//check T

void dfs(int u, int p, bool c)
{
  color[u] = c;
  for(pii& vw: G[u])if(vw.X != p)
  {
    if(vw.Y%2 == 1) dfs(vw.X, u, !c); //not smae parity
    else dfs(vw.X, u, c);
  }
}

void solve()
{
  cin >> n;
  int a, b, w;
  rep(i, 1, n) 
  {
    cin >> a >> b >> w;
    G[a].pb(mp(b,w));
    G[b].pb(mp(a,w));
  }
  memset(color , 0, sizeof(color));
  dfs(1, -1, 0);
  rep(i, 1, n+1) cout << color[i] << endl;

  return;
}


signed main()
{
  fastIO();
  T = 1;
  //cin >> T; //this
  rep(tc, 1, T+1)
  {
    //cout << "Case #" << tc << ": ";
    solve();
  }
  return 0;
}


Measured memory_bytes: 11392
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  double A,B,C,D;
  cin>>A>>B>>C>>D;
  // cout<<C/B<<endl<<A/D<<endl;
  if(ceil(A/D)>=ceil(C/B)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3724
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
        	while(true) {
        		int n = sc.nextInt();
        		int r = sc.nextInt();
        		if(n==0 && r==0) break;
        		int [] cards = new int[n+1];
        		for(int i=1,j=n;i<=n;i++,j--) {
        			cards[i] = j;
        		}
        		for(int i=0;i<r;i++) {
        			int p = sc.nextInt();
        			int c = sc.nextInt();
        			int [] sh = new int[c];
        			for(int j=p,k=0;j<p+c;j++,k++) {
        				sh[k] = cards[j];
        			}
        			for(int j=p+c-1,k=p-1;k>=1;j--,k--) {
        				cards[j] = cards[k];
        			}
        			for(int j=1,k=0;k<c;j++,k++) {
        				cards[j] = sh[k];
        			}
        		}
        		System.out.println(cards[1]);
        	}
        }
    }
}
        		


Measured memory_bytes: 36744