akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.concurrent.LinkedBlockingDeque;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String str = sc.next();

			if ("0".equals(str)) {
				return;
			}

			char[] one = str.toCharArray();
			char[] two = sc.next().toCharArray();
			char[] three = sc.next().toCharArray();

			int a_1 = 0, a_2 = 0, a_3 = 0, b_1 = 0, b_2 = 0, b_3 = 0;

			for (int i = 1; i < one.length; i++) {
				if (one[i] == 'A') {
					a_1++;
				} else if (one[i] == 'B') {
					b_1++;
				}
			}
			
			if(two[0] == 'A'){
				a_1++;
			} else if (two[0] == 'B') {
				b_1++;
			}
			
			for (int i = 1; i < two.length; i++) {
				if (two[i] == 'A') {
					a_2++;
				} else if (two[i] == 'B') {
					b_2++;
				}
			}
			
			if(three[0] == 'A'){
				a_2++;
			} else if (three[0] == 'B') {
				b_2++;
			}
			
			for (int i = 1; i < three.length; i++) {
				if (three[i] == 'A') {
					a_3++;
				} else if (three[i] == 'B') {
					b_3++;
				}
			}
			
			if(a_3 > b_3){
				a_3++;
			}else{
				b_3++;
			}
			
			System.out.println(a_1 + " " + b_1);
			System.out.println(a_2 + " " + b_2);
			System.out.println(a_3 + " " + b_3);
		}

	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



template <typename T> T gcd(T a, T b) {if(b == 0) return a;return gcd(b,a%b);}
template <typename T> T extgcd(T a, T b, T& x, T& y){
    T d = a;
    if(b != 0){d = extgcd(b,a%b,y,x); y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> T modpow(T x, T n, T m) {
    if(n==0) return 1;
    T resp = modpow(x*x%m,n/2,mod);
    if(n&1) resp = resp*x%m;
    return resp;
}
template <typename T> T modinverse(T a, T m) {
    T x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
struct combination {
    ll M = mod;
    vector<ll> fact;vector<ll> ifact;
    combination(ll n):fact(n+1),ifact(n+1){
        fact[0]=1;ifact[0]=1;
        for (ll i = 0; i<n; i++) {fact[i+1] = fact[i]*(i+1) % M;ifact[i+1] = ifact[i]*modpow(i+1, M-2, M) % M;}
    }
    ll com(ll a, ll b){
        if(a == 0 && b == 0)return 1;if(a < b || a < 0)return 0;
        ll tmp = ifact[a-b]* ifact[b] % M;
        return tmp * fact[a] % M;
    }
};





int main()
{
    int N,K;
    cin >> N >> K;
    vl A(N);
    in(N,A);
    sort(all(A));
    
    combination COM(300000);
    
    
    ll ans = 0;
    rep(i,N){
        ans += A[i]*COM.com(ll(i),ll(K-1))%mod;
        ans %= mod;
        ans += mod;
        ans -= A[i]*COM.com(ll(N-i-1),ll(K-1))%mod;
        ans %= mod;
    }

    out(ans);
    


    return 0;
}


Measured memory_bytes: 5760
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,M=mi()

    X = [0]*(M+1)
    for i in range(N):
        Y = list(mi())
        for a in Y[1:]:
            X[a] += 1
    
    ans = 0
    for x in X:
        if x == N:
            ans += 1
    
    print(ans)
            
        



if __name__ == "__main__":
    main()

Measured memory_bytes: 62556
#include<iostream> 
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	int n, k,m=1,r=0,i;

	cin >> n >> k;
	if (n == 1) {
		if (2 > k + 1)
			cout << k + 1 << endl;
		else
			cout << 2 << endl;
		return 0;
	}
	while (m < k ) {
		m *= 2;
		r++;
	}
	for (i=0;i < n-r;i++) {
		m += k;
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 3548
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>  
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 
ll mpow(ll a, ll b){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}
 
ll mpow(ll a, ll b, ll p){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}
 
ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}
 
ll range(ll l, ll r){
	return l + rand()%(r-l+1);
}

void solve(){
	ll n,k;
	cin >> n >> k;
	ll ans = n-k+1;
	ll a[n];
	forn(i,n) cin >> a[i];
	ll f[n];
	ll sum = 0;
	set<ll> s;
	bool bo = 0;
	k--;
	forn(i,n){
		s.insert(a[i]);
		sum += (a[i] < ((i-1 >= 0) ? a[i-1] : -1));
		if(i>=k){
			s.erase(a[i-k]);
			sum -= (a[i-k] < ((i-k-1 >= 0) ? a[i-k-1] : -1));
			if(sum == 0){
				bo = 1;
				ans--;
			}
			else{
				if(a[i-k] < *(s.begin()) && ((i+1<n) ? a[i+1] : -1) > *(--s.end())) ans--;
			}
		}
	}
	if(bo) ans++;
	cout << ans << ln;
}
 
int main()
{
	fast_cin();
    ll t=1;
	// cin >> t;
    forn(i,t) {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 11264
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
           
#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


const int coin[] = { 500, 100, 50, 10, 5, 1 };
int min_coin(int change)
{
    int res = 0;
    rep (i, 6)
    {
	int c = change / coin[i];
	res += c;
	change -= c * coin[i];
    }
    return res;
}
bool pint_eq(const pint& a, const pint& b)
{
    cout << "hoge" << endl;
    return a.first == b.first;
}
int main()
{
    int p, n[6];
    while (scanf("%d", &p), p)
    {
	rep (i, 6)
	    scanf("%d", n + i);
	reverse(n, n + 6);

	vector<pint> d[7];
	d[0].push_back(pint(p,0));

	int res = 1 << 25;
	rep (i, 6)
	{
	    rep (j, d[i].size())
	    {
		int left = d[i][j].first;
		int use = d[i][j].second;
		for (int c = min(n[i], max(0, left / coin[i]));
		     c <= n[i] && c * left - c * coin[i] >= -500; ++c)
		{
		    d[i + 1].push_back(pint(left - c * coin[i], use + c));
		}
	    }
	    sort(all(d[i + 1]));
	    d[i + 1].erase(unique(all(d[i + 1])), d[i + 1].end());
	    rep (j, d[i + 1].size())
	    {
		int left = d[i + 1][j].first;
		int use = d[i + 1][j].second;
		if (left <= 0)
		    min_swap(res, use + min_coin(-left));
	    }
	}
	printf("%d\n", res);
    }
}

Measured memory_bytes: 1140
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
//#define _GLIBCXX_DEBUG//only for debugging
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0);ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);cerr<<fixed<<setprecision(5);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
/* VARIABLE DECLARATION START */
//int arr[8000][8000];
/*  FUCNTION TEMPLATE STARTS  HERE */
double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA
   string s;
   vector<int>v;
   int flag1=0,flag2=0;
   while(cin>>s)
   {
     if(s==" ")
      continue;
     else if(s=="+")
      flag1=1;
    else if(s=="-")
      flag2=1;
     else
     {
      v.pb(stoi(s));
     }
   }
   if(flag1)
   {
    cout<<v[0]+v[1]<<endl;
   }
   else
   {
    cout<<v[0]-v[1]<<endl;
   }
   

    
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

const int MAX = 2e3 + 5;
ll dp[MAX][MAX];

ll calc(ll st, ll en, vector <pii> &v)
{
	if(st > en) return 0;
	if(dp[st][en] != -1) return dp[st][en];
	int curr = st + (int)v.size() - 1 - en;
	return dp[st][en] = max(calc(st + 1, en, v) + 1ll * v[curr].f * abs(v[curr].s - st), calc(st, en - 1, v) + 1ll * v[curr].f * abs(v[curr].s - en));
}
int main()
{
	boost;
	int n, i;
	cin >> n;
	vector <pii> v(n);
	fo(i, 0, n) {
		cin >> v[i].f;
		v[i].s = i;
	}
	sort(all(v), greater <pii>());
	memset(dp, -1, sizeof dp);
	cout << calc(0, n - 1, v);
}

Measured memory_bytes: 35144
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

//-------------------------------------------------------------------
int M=1;
std::vector<int> seg_e, seg_o;
void init(int N){
  while(M<N) M*=2;
  M=M*2-1;
  for(int i=0;i<M;i++) {
    seg_e.push_back(1000000007);
    seg_o.push_back(1000000007);
  }
}
void update_e(int l, int r, int x, int k){
  k+=(M+1)/2-1;
  seg_e[k] = x;
  while(k>0){
    k = (k-1)/2;
    seg_e[k] = min(seg_e[k*2+1], seg_e[k*2+2]);
  }
}
void update_o(int l, int r, int x, int k){
  k+=(M+1)/2-1;
  seg_o[k] = x;
  while(k>0){
    k = (k-1)/2;
    seg_o[k] = min(seg_o[k*2+1], seg_o[k*2+2]);
  }
}
ll query_e(int a, int b, int l, int r, int k){
  if(r<=a || b<=l) return 1000000007;
  if(a<=l && r<=b) return seg_e[k];
  ll A = query_e(a, b, l, (l+r)/2, k*2+1);
  ll B = query_e(a, b, (l+r)/2, r, k*2+2);
  return min(A, B);
}
ll query_o(int a, int b, int l, int r, int k){
  if(r<=a || b<=l) return 1000000007;
  if(a<=l && r<=b) return seg_o[k];
  ll A = query_o(a, b, l, (l+r)/2, k*2+1);
  ll B = query_o(a, b, (l+r)/2, r, k*2+2);
  return min(A, B);
}
//-------------------------------------------------------------------

int main(int argc, char const *argv[]) {
  ll N, a;
  std::cin >> N;
  init(N);
  std::vector<ll> idx(N+1);
  for(int i=0;i<N;i++){
    std::cin >> a;
    idx[a] = i;
    if(i%2==0) update_e(0, (M+1)/2, a, i);
    else update_o(0, (M+1)/2, a, i);
  }
  std::vector<int> ans;
  set<int> h;
  h.insert(N);

  multiset<vector<ll>> q;
  q.insert(std::vector<ll> {query_e(0, N, 0, (M+1)/2, 0), 0, N-1});

  while(!q.empty()){
    auto itr = q.begin();
    ll l = (*q.begin())[1], r = (*q.begin())[2], a = (*q.begin())[0], b;
    q.erase(itr);
    if(idx[a]%2==0) b = query_o(idx[a]+1, r+1, 0, (M+1)/2, 0);
    else b = query_e(idx[a]+1, r+1, 0, (M+1)/2, 0);
    ans.push_back(a), ans.push_back(b);
    if(idx[a]-l>=2) {
      ll ne;
      if(l%2==0) ne = query_e(l, idx[a], 0, (M+1)/2, 0);
      else ne = query_o(l, idx[a], 0, (M+1)/2, 0);
      q.insert(vector<ll> {ne, l, idx[a]-1});
    }
    if(idx[b]-idx[a]!=1) {
      ll ne;
      if(idx[a]%2==1) ne = query_e(idx[a]+1, idx[b], 0, (M+1)/2, 0);
      else ne = query_o(idx[a]+1, idx[b], 0, (M+1)/2, 0);
      q.insert(vector<ll> {ne, idx[a]+1, idx[b]-1});
    }
    if(r-idx[b]>=2) {
      ll ne;
      if(idx[b]%2==1) ne = query_e(idx[b]+1, r+1, 0, (M+1)/2, 0);
      else ne = query_o(idx[b]+1, r+1, 0, (M+1)/2, 0);
      q.insert(vector<ll> {ne, idx[b]+1, r});
    }
  }
  for(int i=0;i<N;i++) std::cout << ans[i] << (i==N-1?"\n":" ");
  return 0;
}


Measured memory_bytes: 12388
#include <cstdio>
#include <algorithm>
using std::sort;
int main(void)
{
    int i,N,ptr,currCount,lastNum,res=0;
    int *a;
    scanf("%d",&N);
    a=new int [N];
    for(i=0;i<N;i++)
        scanf("%d",a+i);
    sort(a,a+N);
    ptr=0;
    while(ptr<N)
    {
        lastNum=a[ptr];
        currCount=0;
        while(ptr<N && a[ptr]==lastNum)
        {
            currCount++;
            ptr++;
        }
        res+= currCount%2;
    }
    printf("%d\n",res);
    delete [] a;
    return 0;
}


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

int main(){
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    int good{};
    if(x == W/2.0 && y == H/2.0){
        good = 1;
    }
    double sum = W*H/2.0;
    cout << sum << " " << good << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x;
	cin >> x;
    int ans;
    if(x%2==0)ans=x;
    else ans = x*2;
      cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<array>

using namespace std;

int main(){
    int n;
    int flag = 0;
    array<int,100>a;
    cin>>n;
    for(int i = 0; i < n; i++){
        cin>>a.at(i);
        if(a.at(i)%2 == 0 && a.at(i)%3 != 0 && a.at(i)%5 != 0){
            flag = 1;
        }
    }
    if(flag == 0){
        cout<<"APPROVED"<<endl;
    }else{
        cout<<"DENIED"<<endl;
        }
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i, 1, n + 1) {
        if (to_string(i).size() % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define INF (1 << 31) - 1
#include <math.h>
#define PI 3.14159265358979323846

int main() {
  cout << fixed << setprecision(30);
  long double A,B,H,M;
  cin >> A >> B >> H >> M;
  long double COS = cos((H/6-M/30+M/360)*PI);
  long double ans = sqrt(A*A+B*B-2*A*B*COS);
  cout << ans << endl;
}

Measured memory_bytes: 4192
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def rotate(nd, d):
    c = nd[d]
    if d:
        nd[1] = c[0]
        c[0] = nd
    else:
        nd[0] = c[1]
        c[1] = nd
    return c


root = None
def insert(val, pri):
    global root
    st = []
    dr = []
    x = root
    while x:
        st.append(x)
        if x[2] == val:
            return
        d = (x[2] < val)
        dr.append(d)
        x = x[d]
    nd = [None, None, val, pri]
    while st:
        x = st.pop(); d = dr.pop()
        c = x[d] = nd
        if x[3] >= c[3]:
            break
        rotate(x, d)
    else:
        root = nd

def __delete(nd):
    st = []; dr = []
    while nd[0] or nd[1]:
        l = nd[0]; r = nd[1]
        d = (l[3] <= r[3]) if l and r else (l is None)
        st.append(rotate(nd, d))
        dr.append(d ^ 1)
    nd = x = None
    while st:
        nd = x; x = st.pop(); d = dr.pop()
        x[d] = nd
    return x

def delete(val):
    global root
    x = root

    y = None
    while x:
        if val == x[2]:
            break
        y = x; d = (x[2] < val)
        x = x[d]
    else:
        return

    if y:
        y[d] = __delete(x)
    else:
        root = __delete(x)

def find(val):
    x = root
    while x:
        if val == x[2]:
            return 1
        x = x[x[2] < val]
    return 0

def debug():
    s0 = [""]
    s1 = [""]

    def dfs(nd):
        v = str(nd[2])
        s0.append(v)
        if nd[0]:
            dfs(nd[0])
        s1.append(v)
        if nd[1]:
            dfs(nd[1])
    dfs(root)
    return " ".join(s1), " ".join(s0)


M = int(readline())
ans = []
for m in range(M):
    cmd, *V, = readline().split()
    if cmd == "print":
        ans.extend(debug())
    elif cmd == "find":
        ans.append("yes" if find(int(V[0])) else "no")
    elif cmd == "delete":
        delete(int(V[0]))
    else:
        val, pri = map(int, V)
        insert(val, pri)
write("\n".join(ans))
write("\n")




Measured memory_bytes: 65680
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n"
#define X first
#define Y second
#define pii pair<int,int>
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout)

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;

ll poww(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));}
ll n ;
ll m ; 
ll w[maxn];
ll v[maxn];
ll dp[105][maxn];
int main(){
	migmig;
	
	cin >> n >> m ;
	
	for(int i=0;i<n;i++){
    	cin>>w[i]>>v[i];
  	}
  	
  	for(int i=1;i<=n;i++){
    	for(int j=0;j<=m;j++){
      		if(w[i-1]<=j){
      				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
			  } 
      		else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    	}
  	}
  cout<<dp[n][m]<<"\n";
}



Measured memory_bytes: 79360
#include <iostream>
#include <string>
using namespace std;
int main() {
    int a=0 , w =0 , r=0 , t=0;
    int n ;
    cin>>n;
    for (int i=1 ; i<=n ; i++)
    {
        string s;
        cin>>s;
        if (s =="AC")
        {
            a=a+1;
        }
        else if (s=="WA")
        {
            w=w+1;
        }
        else if (s=="TLE")
        {
            t=t+1;
        }
        else if (s=="RE")
        {
            r=r+1;
        }
    }
    cout<<"AC x "<< a<<endl;
    cout<<"WA x "<< w<<endl ;
    cout<<"TLE x "<<t<<endl;
    cout<<"RE x "<<r<<endl;

    return 0;
}

Measured memory_bytes: 3576
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
long long standerd = long long(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

long long koyaku_max(long long a,long long b){
    long long r;
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

long long kobai_min(long long a,long long b){
    long long tmp;
    tmp =  a / koyaku_max(a,b);
    return tmp * b;
}


int main(){

    long long A;
    long long B;
    long long C;
    long long D;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    long long CD;

    CD = kobai_min(C,D);

    long long maxvalue;
    long long minvalue;

    maxvalue = B - (B / C + B / D - B / CD );
    minvalue = (A-1) - ((A-1) / C + (A-1) / D - (A-1) / CD );

    //cout << CD << endl;
    //cout << maxvalue << endl;
    //cout << minvalue << endl;
    cout << maxvalue-minvalue << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define sz(x) (int)x.size()
#define pb push_back
#define ll long long
#define vi vector<long long>
#define pi pair<long long, long long>
#define mp make_pair
#define endl '\n'
#define _ << ' '
#define FAST_LOG2(x) (sizeof(unsigned long)*8 - 1 - __builtin_clzl((unsigned long)(x)))
#define clog2(x) (((x) - (1 << FAST_LOG2(x))) ? FAST_LOG2(x) + 1 : FAST_LOG2(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e18;
const ll N = (1<<5);
const double PI = 3.1415926535897;

ll n, kk, a[200001], f[200001], ans;

bool check(ll x){
    ll k = kk;
    for(int i=0; i<n; i++){
        if(a[i]*f[i]>x){
            k -= (a[i]*f[i]-x+f[i]-1)/f[i];
        }
        if(k<0) return 0;
    }
    return 1;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("C.txt", "r", stdin);
    #endif
    cin >> n >> kk;
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) cin >> f[i];
    sort(a, a+n, greater<ll>()); sort(f, f+n);
    ll lb=0, rb=(ll)1e12+1;
    while(lb<rb){
        ll mid = (lb+rb)/2;
        if(check(mid)){
            ans = mid;
            rb = mid;
        }
        else{
            lb = mid + 1;
        }
    }
    cout << ans;
}




Measured memory_bytes: 3328
#include <cstdio>
#include <vector>
#include <array>
using namespace std;

int main(){
    int N;
    scanf("%d",&N);
    vector<array<int,3>> ar(N),cnt(101);
    for(auto& x : ar){
        for(auto& y : x) scanf("%d",&y);
        for(int i=0;i<3;i++) cnt[x[i]][i]++;
    }
    for(auto x : ar){
        int pt=0;
        for(int i=0;i<3;i++) if(cnt[x[i]][i]==1) pt+=x[i];
        printf("%d\n",pt);
    }
}

Measured memory_bytes: 1012
#include<cstdio>
int main(){
    int h,w;
    char a[8][9];
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++)scanf("%s",a[i]);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='#'&&(i!=h-1||j!=w-1)){
                int d=0;
                if(a[i][j+1]=='#')d++;
                if(i+1<h&&a[i+1][j]=='#')d++;
                if(d!=1){
                    printf("Impossible");
                    return 0;
                }
            }
            if(a[i][j]=='#'&&(i!=0||j!=0)){
                int d=0;
                if(j>0&&a[i][j-1]=='#')d++;
                if(i>0&&a[i-1][j]=='#')d++;
                if(d!=1){
                    printf("Impossible");
                    return 0;
                }
            }
        }
    }
    printf("Possible");
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
using namespace std;
int n,W;
long long w[105],v[105];
long long f[105][1000005];//f[i][j] 前i个物品中容量为j的最大价值 
int main(){
	scanf("%d%d",&n,&W);
	for(int i=1;i<=n;i++)	scanf("%d %d",w+i,v+i);
	for(int i=1;i<=n;i++)
		for(int j=0;j<=W;j++){
			if(w[i]>j)	f[i][j]=f[i-1][j];
			else f[i][j]=max(f[i-1][j],f[i-1][j-w[i]]+v[i]);
		}
	printf("%lld",f[n][W]);
	return 0;
}

Measured memory_bytes: 274304
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
	int x,a,b;
	scanf("%d%d%d",&x,&a,&b);
	printf("%d\n",x-a-(x-a)/b*b);
	return 0;
}

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

#define rep(i,N) for(int i=0;i<(int)(N);i++)
#define REP(i,k,N) for(int i=k;i<(int)(N);i++)

#define vi vector<int>
#define pb push_back

#define pdd pair<double,double>
#define fi first
#define se second
const double  EPS = 1e-7;

double dist(double x,double y){
    return x*x+y*y;
};

int main(){
//    ifstream in("d_in.txt");
//    cin.rdbuf(in.rdbuf());
    int n;
    while(cin >> n,n){
        int ma = 1;
        pdd p[330];
        rep(i,n) cin >> p[i].fi >> p[i].se;
        rep(i,n-1){
            REP(j,i+1,n){

                double x1,y1,x2,y2,x3,y3;
                tie(x1,y1) = p[i];
                tie(x2,y2) = p[j];
                double cx1,cy1,cx2,cy2;
                if(dist(x1-x2,y1-y2)  > 4+EPS  ) continue;

                //はりまコーナー
//                double ax,ay,bx1,by1,bx2,by2,mx,my,dx,dy;
//                ax=x1-x2;ay=y1-y2;
//                mx=(x1+x2)/2;my=(y1+y2)/2;
//                by1 = (-0.5)*pow(ax,4)+pow(ax,2)+(-0.5)*pow(ax,2)*pow(ay,2)
//                        /dist(ax,ay);
//                by1 = sqrt(abs(by1));
//                by2 = -1*by1;
//                cy1= my+by1;
//                cy2= my+by2;
//                bx1= -1*(ay*by1)/ax;
//                bx2= -1*(ay*by2)/ax;
//                cx1=bx1+mx;
//                cx2=bx2+mx;


                //あじのりコーナー
                double mx=(x1+x2)/2,my=(y1+y2)/2;

                double ld = sqrt(1-dist((x1-x2),(y1-y2))/4);
                double theta = atan((y2-y1)/(x2-x1));
                cx1 = mx - sin(theta)*ld;
                cy1 = my + cos(theta)*ld;
                cx2 = mx + sin(theta)*ld;
                cy2 = my - cos(theta)*ld;

                int cnt1 = 0,cnt2=0;
                for(int k = 0;k<n;k++) {
                    tie(x3, y3) = p[k];
                    if (EPS + 1> dist((cx1 - x3), (cy1 - y3))) cnt1++;
                    if (EPS + 1> dist((cx2 - x3), (cy2 - y3))) cnt2++;
                }
                ma = max({cnt1,cnt2,ma});
            }
        }
        cout<< ma << endl;
    }
    return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
lli po[40] = {};
int n;
lli sz[200005] = {};
lli v[200005] = {};
lli dp[200005] = {};
bool used[100005] = {};
int main() {
    rep(i,40) po[i] = 1LL << i;
    map<lli,set<int>> m;
    cin >> n;
    vector<lli> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    rep(i,n){
       m[a[i]].insert(i);
    }
    int k = 0;
    int ans = 0;
    rrep(i,n){
        if(used[i])continue;
        rrep(j,40){
            if(used[i])break;
            lli fuga = po[j]-a[i];
            if(fuga<=0)break;
            for(auto s:m[fuga]){
                if(!used[s] && s != i){
                    ans++;
                    //cout << s << " " << i << endl;
                    used[s] = true;
                    used[i] = true;
                    m[fuga].erase(s);
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 237696
#include <bits/stdc++.h>
using namespace std;
const long long a=1e9;
long long S;
int main() {
	cin>>S;
	cout<<"0 0 1000000000 1 ";
	if(S%a==0) {
		cout<<"0 "<<(S/a);
	} else {
		cout<<(a-S%a)<<" "<<(S/a+1);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  map<int, int> mp;
  for (int i = 0; i < M; i++)
  {
    int a, b;
    cin >> a >> b;
    mp[a]++;
    mp[b]++;
  }
  for (int i = 1; i <= N; i++)
    cout << mp[i] << endl;
  return 0;
}

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

int main(){
  long n,inf = 1000000007;
  cin >> n;
  vector<long> a(n),b(n);
  for(long i = 0;i < n;i++){
    cin >> a.at(i);
    b.at(a.at(i))++;
  }
  long ok = 0;
  bool not0 = false;
  if(n % 2 == 0){
    for(long i = 1;i < n;i += 2){
      if(b.at(i) == 2){
        ok++;
      }
    }
    if(ok == n/2){
      not0 = true;
    }
  }
  else{
    for(long i = 0;i < n;i += 2){
      if(i == 0 && b.at(i) == 1){
        ok++;
      }
      else if(i != 0 && b.at(i) == 2){
        ok++;
      }
    }
    if(ok == n/2 + 1){
      not0 = true;
    }
  }
  long kekka = 1;
  if(not0 == true){
    for(long i = 0;i < n/2;i++){
      kekka = (kekka*2) % inf;
    }
    cout << kekka << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 1792
MOD = 1000000007


maxn = 200005
fact = [1] * maxn
inv = [1] * maxn
ifact = [1] * maxn
for i in range(2, maxn):
    fact[i] = fact[i - 1] * i % MOD

    q = MOD / i
    r = MOD % i
    inv[i] = (-q * inv[r]) % MOD

    ifact[i] = ifact[i - 1] * inv[i] % MOD

def count_paths(a, b):
    xa, ya = cells[a]
    xb, yb = cells[b]
    if xa <= xb and ya <= yb:
        resp = fact[xb - xa + yb - ya] * ifact[xb - xa] % MOD
        resp = resp * ifact[yb - ya] % MOD
        return resp
    return 0


n, m, k = map(int, raw_input().split())
cells = [[1, 1]]
for _ in range(k):
    cells.append(map(int, raw_input().split()))
cells.append([n, m])
cells.sort()
k += 2

dp = [0] * k
dp[0] = 1
for i in range(1, k):
    dp[i] = count_paths(0, i)
    for j in range(1, i):
        dp[i] -= dp[j] * count_paths(j, i)
        dp[i] %= MOD
print(dp[k - 1])


Measured memory_bytes: 38632
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, T = rl()
A = np.array(rl())
A_cummin = np.minimum.accumulate(A)
B = A - A_cummin

answer = (B == B.max()).sum()
print(answer)

Measured memory_bytes: 23416
use std::io::*;
use std::str::FromStr;

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let n = s.len();

    let mut rui: Vec<i64> = vec![0; n + 1];
    for i in 0..n {
        if s[i] == 'W' {
            rui[i + 1] += 1;
        }
    }

    for i in 0..n {
        rui[n - i - 1] += rui[n - i];
    }

    let mut ans: i64 = 0;
    for i in 0..n {
        if s[i] == 'B' {
            ans += rui[i + 1];
        }
    }

    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 6396
import java.util.*;

public class Main {

    public static void main(String[] args) {
        
        Scanner in = new Scanner(System.in);
        
        int n = in.nextInt();
        
        int[] a = new int[n];
        
        for (int i = 0; i < n; i++) {
            
            a[i] = in.nextInt();
            
        }
        
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(a[1] - a[0]);
        for (int i = 2; i < n; i++) {
            
            dp[i]  = Math.abs(a[i] - a[i - 1]) + dp[i - 1];
            dp[i] = Math.min(dp[i] , Math.abs(a[i] - a[i - 2]) + dp[i - 2]);
            
        }
//        System.out.println(Arrays.toString(dp));
        System.out.println(dp[n - 1]);
        
        
    }
    
}


Measured memory_bytes: 50608
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int n,x,y,ans[2000]={},a;
  cin>>n>>x>>y;
  x--; y--;
  rep(i,0,n-1){
    rep(j,i+1,n){
      a=min(abs(j-i),abs(x-i)+1+abs(j-y));
      a=min(a,abs(y-i)+1+abs(j-x));
      ans[a-1]++;
    }
  }
  rep(i,0,n-1) co(ans[i]);
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

#ifndef INT_MAX
#  define INT_MAX std::numeric_limits<int>().max()
#endif
#ifndef INT_MIN
#  define INT_MIN std::numeric_limits<int>().min()
#endif
#define LL_MAX std::numeric_limits<ll>().max()
#define LL_MIN std::numeric_limits<ll>().min()
#define INF LL_MAX

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
// 配列の初期化
#define ZERO(p) memset(p, 0, sizeof(p))
// 配列の初期化(-1)
#define MINUS(p) memset(p, 1, sizeof(p))

#define MAX_N 100005
ll N, B, A;
vector<ll> H;

int main()
{
    cin >> N >> A >> B;
    REP(i, N) {
        ll hi;
        cin >> hi;
        H.push_back(hi);
    }

    SORT(H);

    // 最長ケースと最短ケースを求める
    ll longest = H[H.size()-1] / B;
    if(H[H.size()-1] % B != 0) { longest++; }
    ll shortest = H[0] / A;
    if(H[0] % A != 0) { shortest++; }

    // 二分探索
    ll last_success = longest;
    while(longest > shortest) {
        ll cur = (longest - shortest) / 2 + shortest;
        ll rem_a = cur; // A の残数
        if(cur == longest || cur == shortest) { break; }
        REP(i, N) {
            ll rem_h = H[i] - (B * cur);
            if(rem_h > 0) {
                // A を打つしかない
                ll shot = rem_h / (A - B);
                if(rem_h % (A - B) != 0) { shot++; }
                rem_a -= shot;
            }
            if(rem_a < 0) { break; }
        }
        if(rem_a < 0) {
            // この A の回数では足りなかったので、増やす
            shortest = cur;
        } else {
            // まだ A の回数を減らせそう
            last_success = cur;
            longest = cur;
        }
    }
    printf("%lld\n", last_success);

    return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;
  cout << (s.find("AC") != string::npos ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int N,M,i,j,num[50]={};
    long int a[50],b[50],c[50],d[50],min[50],dis;
    scanf("%d %d",&N,&M);
    for(i=0;i<N;i++) scanf("%ld %ld",&a[i],&b[i]);
    for(i=0;i<M;i++){
        scanf("%ld %ld",&c[i],&d[i]);
        for(j=0;j<N;j++){
            dis=labs(a[j]-c[i])+labs(b[j]-d[i]);
            min[j]>dis?(min[j]=dis,num[j]=i):i==0?min[j]=dis:0;
        }
    }
    for(i=0;i<N;i++) printf("%d\n",num[i]+1);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n+10],b[n+10];
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    int cnt = 0;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i])
            cnt++;
    }
    if(cnt>2)
        cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    string s;
    cin >> s;
    ll n = s.length();
    vector<vector<ll>> dp(1000000,vector<ll>(2,-INF));
    dp[0][0] = dp[1][1] = 1;
    for(ll i = 0;i<n;i++){
        //1=>1
        if(s[i] != s[i+1])chmax(dp[i+1][0],dp[i][0] + 1);
        //2=>2
        if(i >= 2 && s.substr(i-2,2) != s.substr(i,2))chmax(dp[i+2][1],dp[i][1] + 1);
        //1 => 2
        chmax(dp[i+2][1],dp[i][0] + 1);
        //2 => 1
        chmax(dp[i+1][0],dp[i][1] + 1);
    }
    cout << max(dp[n-1][0],dp[n-1][1]) << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 55172
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;


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

    string s;
    int cnt = 0;

    cin >> s;
    int ans = (int)s.size();
    for(char c: s)
    {
        if(c == 'T')
        {
            if(cnt)
            {
                cnt--;
                ans -= 2;
            }
        }
        else
            cnt++;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
int main(){
    int  a, b ,c;
    char X,Y;
    string S1,S2,S3;
    int A[] = {0,1,3,1,2,1,2,1,1,2,1,2,1} ;
    cin >>a >> b ;
    if(A[a] == A[b]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 

int main()
{ 
    int n;
    cin>>n;
    string s[n];
    int t[n];
    for(int j=0;j<n;j++){
        cin>>s[j];
        cin>>t[j];
    }
    string x;
    cin>>x;
    int ans=0;
    int i=0;
    while(s[i]!=x){i++;}
    for(int j=i+1;j<n;j++){
        ans=ans+t[j];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String args[]){
		
		Scanner sc=new Scanner(System.in);
		int te=sc.nextInt();
		Map <String,Integer> mp=new HashMap<>();
		String s=new String();
		mp.put("AC",0);
		mp.put("WA",0);
		mp.put("TLE",0);
		mp.put("RE",0);
		while(te-->0){
			s=sc.next();
			Integer val=mp.get(s);
			mp.put(s,val+1);
		}
		System.out.println("AC x "+mp.get("AC"));
		System.out.println("WA x "+mp.get("WA"));
		System.out.println("TLE x "+mp.get("TLE"));
		System.out.println("RE x "+mp.get("RE"));
	}
};

Measured memory_bytes: 58744
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

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

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

/* MACROS */ 
typedef unsigned long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(ll i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

bool isPow(ll x){
    return x && (!(x&(x-1)));  
}

void solve(){
	ll l,r,ans = 0; cin >> l >> r;
	
	if(r-l<=4){
		rep(i,l,r+1) ans ^= i;
		cout << ans;
	} else{
		while(l%4!=0){
			ans ^= l;
			l++;
		}
		l = r - (r%4);
		while(l<=r){
			ans ^= l;
			l++;
		}
		cout << ans;
	}	
}

int main(){
    IOS;    
    solve();
}

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

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

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

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

	cout << (A*B)/2 << endl;

	return 0;

}


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

int p[202], q[202], cnt;
long long n;

void solve(long long n) {
  if (!n) return;
  if (~n & 1)
    q[++q[0]] = cnt++, solve(n - 1);
  else
    p[++p[0]] = cnt++, solve(n >> 1);
}

int main() {
  scanf("%lld", &n), solve(n), printf("%d\n", cnt + 100);
  for (int i = 1; i <= q[0]; ++i) printf("%d ", cnt - q[i]);
  for (int i = p[0]; i; --i) printf("%d ", cnt - p[i]);
  for (int i = 1; i <= 100; ++i) printf("%d ", i);
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long

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

	map<int, int> mp;
	int n;
	cin >> n;
	while(n--){
		int num;
		cin >> num;
		mp[num]++;
	}
	int ans = 0;
	for(auto x:mp){
		if(x.second >= x.first) ans += (x.second-x.first);
		else ans += x.second;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 8036
def linecheck(a,i):
    for j in range(W):
        if a[i][j] != ".":
            return False
    return True
def colcheck(a,j,H):
    for i in range(H):
        if a[i][j] != ".":
            return False
    return True
H,W = map(int,input().split())
a = []
for i in range(H):
    a.append(list(input()))
i = 0
while i<H:
    if linecheck(a,i):
        del a[i]
        i = 0
        H -= 1
    else:
        i += 1
j = 0
while j<W:
    if colcheck(a,j,H):
        for i in range(H):
            del a[i][j]
        j = 0
        W -= 1
    else:
        j += 1
for i in range(H):
    print("".join(a[i]))

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
using namespace std;
const int N=105;
int b[N];
int main(){
	int n,i;
	scanf("%d",&n);
	for(i=1;i<n;i++) scanf("%d",&b[i]);
	b[n]=0x3f3f3f3f;int ans=b[1];
	for(i=1;i<n;i++)
		ans+=min(b[i],b[i+1]);	
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

const lint mod=1e9+7;

int main()
{
	int N,M;
	bool broken[100010]={};
	lint dp[100010]={};

	cin >> N >> M;
	for(int i=0;i<M;i++)
	{
		int a;
		cin >> a;
		broken[a]=true;
	}

	dp[0]=1;
	for(int i=0;i<=N;i++)
	{
		if(!broken[i+1])
			dp[i+1]+=dp[i];
		if(!broken[i+2])
			dp[i+2]+=dp[i];
		dp[i+1]%=mod;
		dp[i+2]%=mod;
	}

	cout << dp[N] << endl;
	return 0;
}



Measured memory_bytes: 1152
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

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

	if (A <= C && C <= B)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256