akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = 1;
  int c[26] = {};
  rep(i,n)c[s[i] - 'a']++;
  for(auto i : c){
    ans *= i + 1;
    ans %= INF;
  }
  cout << ans - 1 << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(12);
  int l;
  cin>>l;
  double a=(double)l/(double)3;
  long double ans=a*a*a;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    if (H < W) swap(H, W);

    write((N + H - 1) / H);
}

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


void main()
{
  auto n = readln.chomp.to!int;
  auto s = readln.chomp;
  int r, b;
  foreach (i; 0..n) {
    if (s[i] == 'R') r++;
    else b++;
  }

  if (r > b) writeln("Yes");
  else writeln("No");
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  vll A(N);
  ll minabs = INF;
  int negct = 0;
  ll sum = 0;
  rep(i, N) {
    cin >> A[i];
    chmin(minabs, abs(A[i]));
    sum += abs(A[i]);
    if(A[i] < 0) negct++;
  }
  
  if(negct % 2 == 0) {
    fin(sum);
  } else{
    fin(sum - minabs * 2);
  }
  
}
//33 3

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end() 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int main(){
    ll n;cin>>n;
    vector<ll>x(3);
    ll ans=1;
    ll a;
    rep(j,n){
        cin>>a;
        ll cnt=0;
        rep(i,3){
            cnt+=(a==x[i]);
        }
        rep(i,3){
            if(x[i]==a){
                x[i]++;
                break;
            }
        }
        ans*=cnt;
        ans%=inf;
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x;
    cin >> x;
    ll pos = 0;
    int sol = 1;
    while (pos < x)
        pos += sol, sol++;
    cout << sol - 1;
}


Measured memory_bytes: 256
n = int(input())
if 400 <= n <= 599:
    print(8)
elif 600 <= n <= 799:
    print(7)
elif 800 <= n <= 999:
    print(6)
elif 1000 <= n <= 1199:
    print(5)
elif 1200 <= n <= 1399:
    print(4)
elif 1400 <= n <= 1599:
    print(3)
elif 1600 <= n <= 1799:
    print(2)
else:
    print(1)

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

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

	int N;
	int i,j;
	int tmp;
	int answer;
	int counter=0;
	double ave;
	string S,T;
	vector<int> given;

	cin >> S >> T;


	if(S.size()==T.size()-1){
		if(equal(S.begin(),S.end(),T.begin(),T.end()-1))
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}



Measured memory_bytes: 3612
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;



int main() {
    ll X, money = 100;
    ll ans = 0;
    cin >> X;
    while (money < X) {
        money = money + money / 100;
        ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int n;
unsigned C[10010];
unsigned sum[10010];
int main()
{
  while(cin >>n,n){
  for(int i = 0;i < n;i++){
    cin>>C[i];
  }
  sort(C,C+n);
  unsigned int ans = 0;
  unsigned int tmp = 0;
  for(int i = 1;i <n;i++){
    tmp +=C[i-1];
    ans +=tmp;
  }
 
  cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine();
        WriteLine(n.LastIndexOf('Z') - n.IndexOf('A') + 1);
        ReadLine();
    }
}


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

using namespace std;
using ll=long long;

template <typename T=int>
struct Rmq {
    vector<T> raw;
    static const int LOG = 17; // 20;
    int k;
    int n;
    vector<int> st[LOG];
    Rmq(vector<T> _v) { // pass in vec[0, n)
        raw = _v;
        n = raw.size();
        k = 32 - __builtin_clz(n);
        for (int j = 0; j < k; j++) {
            st[j].resize(n);
        }
        build();
    }
    inline int comp(int x, int y) { // DO! > max
        return raw[x] > raw[y] ? x : y;
    }
    void build() {
        for (int i = 0; i < n; i++) {
            st[0][i] = i;
        }
        for (int j = 1; j < k; j++) {
            for (int i = 0; i + (1<<j) <= n; i++) {
                st[j][i] = comp(st[j-1][i], st[j-1][i + (1<<(j-1))]);
            }
        }
    }
    // [l, r)
    inline int query_id(int l, int r) {
        assert(0 <= l && l < r && r <= n);
        int j = 31 - __builtin_clz(r - l);
        return comp(st[j][l], st[j][r - (1<<j)]);
    }
    inline T query(int l, int r) {
        return raw[query_id(l, r)];
    }
};

const int N = 5005; 
ll d[N][N];

void solve() {
    int n,m;
    cin >> n >> m;
    vector<ll> a(n);
    a[0] = 0;
    for (int i = 1; i < n; i++) {
        cin >> a[i];
        a[i] += a[i-1];
    }

    vector<vector<int>> b(m, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> b[j][i];
        }
    }

    for (int j = 0; j < m; j++) {
        Rmq<> R(b[j]);
        function<void(int,int)> update = [&](int l, int r){
            if (l >= r) return;
            int i = R.query_id(l, r);
            d[l +1][i +1] += b[j][i];
            d[i+1 +1][i +1] -= b[j][i];
            d[l +1][r +1] -= b[j][i];
            d[i+1 +1][r +1] += b[j][i];
            update(l, i);
            update(i+1, r);
        };
        update(0, n);
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            d[i][j] += d[i][j-1]-d[i-1][j-1]+d[i-1][j];
        }
    }

    ll res = -(1ll<<60);
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            ll val = d[i+1][j+1] - (a[j]-a[i]);
            res = max(res, val);
        }
    }
    cout << res;
}

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


Measured memory_bytes: 199904
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    ans = float("inf")
    for i in a:
        k = 0
        while not i&1:
            i >>= 1
            k += 1
        if ans > k:
            ans = k
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38384
#include <iostream>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	int max;
 
	if (a + b > a - b)	max = a + b;
	else max = a - b;
 
	if (max < a*b)	max = a*b;
 
	cout << max;
 
	return 0;
}

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

int N;

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

	int ans = 0;

	cin >> N;
	for (int i=1; i<=N; i++) {
		int x;
		cin >> x;

		if (x%2 and i%2) ans++;
	}

	cout << ans << '\n';
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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


template<typename T>
void DEBUG_VEC2(vector<vector<T>> &v, int ilen, int jlen){
    REP(i,ilen){
        REP(j,jlen) if(v[i][j] != -1){ printf("[% 4d]", v[i][j]); }else{ printf("[    ]"); }
        puts("");
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,k;
    cin>>n>>k;
    vi x(n), y(n);
    vector<pii> xy(n);
    REP(i,n){
        cin>>x[i]>>y[i];
        xy[i] = pii(x[i],y[i]);
    }

    sort(ALL(x));
    sort(ALL(y));
    x.erase(unique(ALL(x)), x.end());
    y.erase(unique(ALL(y)), y.end());
    int szx = x.size();
    int szy = y.size();

    vector<vi> cs(szx+2, vi(szy+2,0));
    FOR(i,1,szx+1) FOR(j,1,szy+1){//x,y
        bool found = false;
        REP(k,n){
            if(xy[k].first == x[i-1]  &&  xy[k].second == y[j-1]){
                found=true;
                break;
            }
        }

        if(found){
            cs[i][j]++;
        }

        cs[i][j] += cs[i-1][j] + cs[i][j-1] - cs[i-1][j-1];
    }

    ll ans = LINF;

    REP(x1,szx) REP(y1,szy){
        FOR(x2,x1+1,szx) FOR(y2,y1+1,szy){
           int cntdot = ( cs[x2+1][y2+1] - cs[x2+1][y1] )  -  ( cs[x1][y2+1] - cs[x1][y1] );

           if(cntdot>=k){
               ll tate = (ll)y[y2]-(ll)y[y1];
               ll yoko = (ll)x[x2]-(ll)x[x1];
               chmin(ans,tate*yoko);
           }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,K=map(int, input().split())
A=list(map(int, input().split()))
if K==0:
  print(max(A))
  exit()
def f(x):
  cnt=0
  for i in A:
    if i%x==0:
      cnt+=i//x-1
    else:
      cnt+=(i//x)
  if cnt<=K:
    return True
  else:
    return False
ok=1
ng=1000000000
for i in range(50):
  mid=(ok+ng)//2
  if f(mid):
    ng=mid
  else:
    ok=mid
print(ng)


Measured memory_bytes: 30804
h,w,k=map(int,input().split())
a=[input() for _ in range(h)]
b=[[0 for _ in range(w)] for _ in range(h)]
c=1
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            b[i][j]=c
            c+=1
d=1            
for i in range(h):
    if b[i]!=[0]*w:
        for j in range(w):
            if b[i][j]==0:
                b[i][j]=d
            elif b[i][j]==d:
                continue
            elif b[i][j]!=d:
                d+=1
        d+=1    

for i in range(h):
    if b[i]==[0]*w and i==0:
        for j in range(h):
            if b[j]!=[0]*w:
                e=b[j]
                break
        for k in range(j+1):
            b[k]=e
    if b[i]==[0]*w:
        b[i]=b[i-1]
for i in b:
    print(*i)

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

using namespace std;

void trace(vector<int> nums, int N) 
{
  for (int k = 0; k < N; k++){
    if (k != N - 1){
      printf("%d ", nums[k]);
    }else{
      printf("%d\n", nums[k]);
    }
  }
}

void insertionSort(vector<int> nums, int N)
{
  int key;
  int j;
  for (int i = 1; i < N; i++){
    key = nums[i];
    j = i - 1;
    while (j >= 0 && nums[j] > key) {
      nums[j + 1] = nums[j];
      j--;
    }
    nums[j + 1] = key;
    trace(nums, N);
  }
}

int main()
{
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) cin >> A[i];
  trace(A, n);
  insertionSort(A, n);
  return 0;
}


Measured memory_bytes: 3268
#include<cstdio>
const int maxn=1000005;
struct edge{
  int to,next;
}lst[maxn<<1];int len=1,first[maxn];
void addedge(int a,int b){
  lst[len].to=b;lst[len].next=first[a];first[a]=len++;
}
int sg[maxn];
void dfs(int x,int p){
  sg[x]=0;
  for(int pt=first[x];pt;pt=lst[pt].next){
    if(lst[pt].to==p)continue;
    dfs(lst[pt].to,x);
    sg[x]^=(sg[lst[pt].to]+1);
  }
}
int main(){
  int n;scanf("%d",&n);
  for(int i=1,a,b;i<n;++i){
    scanf("%d%d",&a,&b);
    addedge(a,b);addedge(b,a);
  }
  dfs(1,0);
  printf("%s\n",(sg[1])?"Alice":"Bob");
  return 0;
}


Measured memory_bytes: 13440
use strict;
use warnings;
use 5.010;

my $n = <>;
my $ans = 0;
my $flag = 1;
chomp $n;
my @arr = split / /, <>;
chomp $arr[-1];
@arr = sort{$a <=> $b} @arr;

for(my $i = $n; $i < $n *3; $i++) {
	if($flag) {
		$ans += $arr[$i];
		$flag = 0;
	} else {
		$flag = 1;
	}
}
say $ans;

exit;

Measured memory_bytes: 54308
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 10000000

int main(){


    int a,b;
    cin >> a;
    int ans = a/3;
    cout << ans << endl;

    return 0;
}

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

int main()
{
    string s;
    cin>>s;
    char c = s[s.length()-1];
    if(c == 's')
    s = s + "es";
    else 
    s = s +"s";
    cout<<s<<endl;
   
   
   return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
#define int ll
#define pb push_back
#define pii pair<int,int>
#define ff first
#define ss second
const int MAX = 2e5+10;
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int par[MAX];



signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);


	


	int n; cin>>n;
	for (int i=0;i<n-1;i++){
		int x; cin>>x;
		par[x]++;
	}
	
	for(int i=1;i<=n;i++) cout<<par[i]<<"\n";
	return 0;
}

Measured memory_bytes: 5152
S = input()

if S[0] == 'R' and S[1] == 'R' and S[2] == 'R':
    print(3)
elif (S[0] == 'R' and S[1] == 'R') or (S[1] == 'R' and S[2] == 'R'):
    print(2)
elif S[0] == 'R' or S[1] == 'R' or S[2] == 'R':
    print(1)
else:
    print(0)

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	vector<int> a(1e6+10,0);
	for(int i=1;i<=1e6;++i){
		for(int j=i;j<=1e6;j+=i) {
			a[j]++;
		}
	}
	ll n;cin>>n;
	int ans=0;
	for(int i=n-1;i>0;--i) ans+=a[i];
	db(ans);
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	cin>>n;
	pll v;
	rep(i,0,n){
		cin>>j>>k;
		v.pb(mp(k,j));
	}	
	sort(all(v));
	t=0;
	rep(i,0,n){
		t+=v[i].S;
		if(t>v[i].F) ret("No")
	}
	ret("Yes")
	
	return 0;
}

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

int main(){
	int n ;cin >> n ;
	vector<int> a(n) ;
	int sum = 0 ;
	for(int i=0;i<n;i++){
		cin >> a.at(i) ;
		sum += a.at(i) ;
	}
	int sub = 0 ;
	int mn = 10000000 ;
	for(int i=0;i<n;i++){
		if(sub<sum-sub){
			mn = sum-sub*2 ;
			sub += a.at(i) ;
		}else{
			cout << min(mn,sub*2-sum) << endl ;
            return 0 ;
		}
	}
}

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


int main(void){
  
  int i = 0;
  int j;
  int a, b;
  int sum[10000] = {0};
  int temp;

  for(;;){
    if(scanf("%d %d",&a, &b) == EOF)break;
    sum[i++] = a + b;
 
  }

  for(i = 0; i < 10000; i++){
    if(sum[i] == 0) break;
    for(j = 0; j < 100; j++){
      if(sum[i] - (int)pow(10, j) < 0){
	printf("%d\n", j);
	break;
      }
    }
  }

  return 0;
  
}
  

Measured memory_bytes: 692
#include <atcoder/mincostflow>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using namespace atcoder;

const long long BIG = 1000000000;

int main() {
	int n, k;
	cin >> n >> k;
	
	mcf_graph<int, long long> g(2 * n + 2);
	int s = 2 * n;
	int t = 2 * n + 1;
	
	g.add_edge(s, t, n * k, BIG);
	
	for (int i = 0; i < n; i++) {
		g.add_edge(s, i, k, 0);
		g.add_edge(n + i, t, k, 0);
	}
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			long long a;
			cin >> a;
			g.add_edge(i, n + j, 1, BIG - a);
		}
	}
	
	auto result = g.flow(s, t, n * k);
	cout << 1LL * n * k * BIG - result.second << endl;
	
	vector<string> grid(n, string(n, '.'));
	auto edges = g.edges();
	for (auto e : edges) {
		if (e.from == s || e.to == t || e.flow == 0) continue;
		grid[e.from][e.to - n] = 'X';
	}
	
	for (int i = 0; i < n; i++) {
		cout << grid[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3888
# include "stdio.h"
int main(){
int n,k,x,y;
scanf("%d %d %d %d",&n,&k,&x,&y);
int sum=0;
if(n<=k)    sum=x*n;
else sum=x*k+y*(n-k);
printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
n = input()
a = map(int, raw_input().split())
b = map(int, raw_input().split())
greater = []
req = 0
ans = 0
for i in xrange(n):
	if a[i] > b[i]:
		greater.append(a[i]-b[i])
	elif a[i] < b[i]:
		req += b[i] - a[i]
		ans += 1
if sum(greater) < req:
	print -1
else:
	greater.sort(reverse = True)
	ptr = 0
	while req > 0:
		req -= greater[ptr]
		ptr += 1
		ans += 1
	print ans




Measured memory_bytes: 51308
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int a, int b, int c) {
    long ans = 0;

    // 毒入り(美味しい) -> 解毒剤(美味しい)の順に食べる
    int x = min(b, c);
    ans += x * 2;
    b -= x;
    c -= x;

    // 毒入り(美味しい) -> 解毒剤(美味しくない)の順に食べる
    x = min(a, c);
    ans += x;
    a -= x;
    c -= x;

    // 毒入り(美味しい)が余っているなら 1 枚だけ食べる
    if (c > 0) ans++;

    // 余りの解毒剤(美味しい)を食べる
    ans += b;
    return ans;
}

long calc2(int a, int b, int c) {
    int d = min(c, a + b + 1);
    return b + d;
}

void main() {
    auto abc = readints;
    int a = abc[0], b = abc[1], c = abc[2];
    writeln(calc2(a, b, c));
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
/*
long long  int c(long long int n,long long int k){
	if(n/2<k)return c(n,n-k);
	if(k==0)return 1;
	else return (int)((((n-k+1)/(double)k)*c(n,k-1))+0.5)%mod;
}
*/
long long int fact (long long int n){
	if(n==0)return 1;
	else return (n*fact(n-1))%mod;
}
long long int pow(long long int n,long long int k){
	if(k==0)return 1;
	if(k==1)return n;
	if(k%2==0) return (pow((n*n)%mod,k/2))%mod;
	else return ((pow((n*n)%mod,k/2))%mod*n)%mod;
}
long long int c(long long int n,long long int k){
	return (((fact(n)*pow(fact(k),mod-2))%mod)*pow(fact(n-k),mod-2))%mod;
}

int main(){
	int n,k;
	cin>>n>>k;
	if(debug){
		cout<<"fact("<<n<<")="<<fact(n)%mod<<endl;
		cout<<"c(2000,1000)="<<c(2000,1000)%mod<<endl;
	}
	for(int i=1;i<=k;i++){
		if(n-k-i+1<0){
			cout<<0<<endl;
			/*
		}else if(n-k-i+1==0){
			cout<<1<<endl;
			*/
		}else{
		cout<<(c(k-1,i-1)*c(n-k+1,i))%mod<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int o=0,l=0;
  cin >> s;
  for(int i=0;i<s.length();i++){
    if(s[i] == '0'){
      o++;
    }else{
      l++;
    }
  }
  cout << min(o,l) * 2;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void) {
	int i,n,minr,nowr,maxd,nowd;
	scanf("%d",&n); /*n >= 2*/
	scanf("%d %d",&minr,&nowr);
	maxd=nowd=nowr-minr;
	for(i=3;i<=n;i++){
		if(nowr<minr) minr=nowr;
		scanf("%d",&nowr);
		nowd=nowr-minr;
		if(nowd>maxd) maxd=nowd;
	}
	printf("%d\n",maxd);
	return 0;
}

Measured memory_bytes: 596
program folia
  implicit none
  integer :: n, i
  integer(8), dimension(0:100001) :: a = 0, b = 0, s = 0
  read(*,*) n
  read(*,*) a(0:n)
  do i = n, 0, -1
    s(i) = s(i + 1) + a(i)
  end do
  b(0) = 1 - a(0)
  do i = 1, n
    b(i) = min(b(i - 1) * 2 - a(i), s(i + 1))
  end do
  if (any(b(0:n) < 0)) then
    write(*,'(i0)') -1
    stop
  end if
  write(*,'(i0)') s(0) + sum(b(0:n))
end program folia

Measured memory_bytes: 5492
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

void solve()
{
  int n;int k;cin>>n>>k;
  string s;cin>>s;
  if(s[k-1]=='A')
  s[k-1]='a';
  else if(s[k-1]=='B')
  s[k-1]='b';
  else
  s[k-1]='c';
  
  cout<<s<<endl;
   
}
int32_t main()
{
    rapido;
    int t;
     // cin>>t;
    t=1;
    while(t--)
    solve();
}




Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

bool isTriangle(int a, int b, int c) {
    return (a != b && b != c && c != a) && ((a + b) > c) && ((b + c) > a) &&
           ((c + a) > b);
}

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

    if (n <= 2) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> L(n);
    rep(i, n) cin >> L.at(i);

    // sort(L.begin(), L.end());

    int cnt = 0;
    for (size_t i = 0; i < L.size(); i++) {
        for (size_t j = i + 1; j < L.size(); j++) {
            for (size_t k = j + 1; k < L.size(); k++) {
                // cout << i + 1 << " " << j + 1 << " " << k + 1;
                if (isTriangle(L.at(i), L.at(j), L.at(k)))
                    cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;
using LL = long long;

int main(){
    int n, r;
    cin >> n >> r;
    if(n>=10){
        cout << r << endl;
    }else{
        cout << r + 100*(10-n) << endl;
    }
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int N=sc.nextInt();
		if(((N%10000)/1000==(N%1000)/100 && (N%1000)/100==(N%100)/10) || ((N%1000)/100==(N%100)/10 && (N%100)/10==N%1)) {
			System.out.println("Yes");
		}else System.out.println("No");
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    ll a, minE = INF, sum = 0;
    int cntMinus = 0;
    bool isZero = false;
    for (int i = 0; i < N; i++) {
        cin >> a;
        if (a < 0) cntMinus++;
        else if (a == 0) isZero = true;
        a = abs(a);
        sum += a;
        minE = min(minE, a);
    }
    if (isZero || (cntMinus % 2 == 0)) cout << sum << '\n';
    else cout << sum - minE * 2 << '\n';
}


Measured memory_bytes: 384
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	string W,H;
	cin >>  W;
	H = "Yes";
	if ((W.size() ) % 2 == 0) {
		rep(i, (W.size())/2) {
			if (W.at(i*2) != 'h' || W.at(i*2+1) != 'i') {
				H = "No";
			}
		}
	}
	else {
		H = "No";
	}
	cout << H << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (ll)(s); i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

int main(){
    string s; cin>>s;
    map<int,int> res;
    int x=0;
    int p=1;
    res[0]++;
    for(int i=s.size()-1; i>=0; i--){
        x=(x+(s[i]-'0')*p)%2019;
        res[x]++;
        p=(p*10)%2019;
    }
    ll ans=0;
    for(auto i:res){
        ans+=i.second*(i.second-1)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3740
#include <iostream>
using namespace std;
int main(void){
    int x, y;
    while (1){
        cin >> x >> y;
        if (x == 0 && y == 0){
            break;
        }
        if (x < y){
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2980
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=1;
    REP(i, 1, n) 
        if(s[i-1]!=s[i]) cnt += 1;

    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 512
n=int(input())
s=list(input())
t=[]
for i in s:
  if i=="W":
    t.append(1)
  else:
    t.append(0)

from itertools import accumulate
t=[0]+list(accumulate(t))
ans=float("INF")
for i in range(1,n+1):
  ans=min(ans,t[i-1]+n-i-(t[n]-t[i]))

print(ans)


Measured memory_bytes: 141124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int ret = 0;
		
		for (int i=1; i<=n; i++) {
			ret = ret + i;
		}
		
		System.out.println(ret);
		sc.close();
	}

}

Measured memory_bytes: 21716
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var cin = new InputStream();
            var W = cin.ReadInt();
            var a = cin.ReadInt();
            var b = cin.ReadInt();

            WriteLine(Max(0, Max(a, b) - Min(a, b) - W));
        }
    }

    public class InputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public InputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine()   => Console.ReadLine();
        public int    ReadInt()    => int.Parse(Read());
        public long   ReadLong()   => long.Parse(Read());
        public double ReadDouble() => double.Parse(Read());
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n){
        if(n==0){
            return 0;
        }
        if(n==1){
            int a;cin >> a;
            cout << a << endl;
            continue;
        }
        vector<bool> b(n);
        vector<int> c(n+1,-1);
        vector<int> d(n);
        for(int i=0;i<n;i++){
            string s;cin >> s;
            d[i]=s.size();
            if(i&&d[i]<d[i-1]){
                for(int i=n-1;i>=s.size();i--){
                    if(c[i]!=-1){
                        if(b[i-1]){
                            c[i-1]*=c[i];
                        }
                        else{
                            c[i-1]+=c[i];
                        }
                        c[i]=-1;
                    }
                }
            }
            if(s[s.size()-1]=='+'){
                b[s.size()]=false;
                c[s.size()]=0;
            }
            else if(s[s.size()-1]=='*'){
                b[s.size()]=true;
                c[s.size()]=1;
            }
            else{
                int p=s[s.size()-1]-'0';
                if(b[s.size()-1]){
                    c[s.size()-1]*=p;
                }
                else{
                    c[s.size()-1]+=p;
                }
            }
        }
        for(int i=n-1;i>=2;i--){
            if(c[i]!=-1){
                if(b[i-1]){
                    c[i-1]*=c[i];
                }
                else{
                    c[i-1]+=c[i];
                }
                c[i]=-1;
            }
        }
        cout << c[1] << endl;
    }
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){ 
  while(x->left != NIL) x = x->left;
  return x;
} 

Node treeSearch(Node u, int k){ 
  while(u == NIL || k == u->key) return u;
  if(k < (u->key)) return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
} 

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeSuccessor(x->right);
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
} 

void treeDelete(Node z){ 
  Node y; // node to be deleted 
  Node x; // child of y 
  
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL) x = y->left;
  else x = y->right;

  if(x != NIL) x->parent = y->parent;

  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y != z) z->key = y->key;

} 

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    if((z->key) < (x->key)) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  
  if(y == NIL) root = z;
  else if((z->key) < (y->key)) y->left = z;
  else y->right = z;
  
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}

void preorder(Node u){
  printf(" %d",u->key);
  if(u->left != NIL) preorder(u->left);
  if(u->right != NIL) preorder(u->right);
}


int main(){
  int n, i, x;
  char command[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", command);
    if ( command[0] == 'f' ){ 
      scanf("%d", &x); 
      Node t = treeSearch(root, x); 
      if ( t != NIL ) printf("yes\n"); 
      else printf("no\n"); 
    }  
    else if ( command[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
    else if ( command[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
    else if ( command[0] == 'd' ){ 
      scanf("%d", &x); 
      treeDelete(treeSearch(root, x)); 
    } 
  }
  
  return 0;
}

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

int main() {
    ll x,ans=0;
    cin >> x;
    while(x>=500){
        x -=500;
        ans+=1000;
    }
    while(x>=5){
        x -=5;
        ans+=5;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
  int n,k,i,b=0;
  string s;
  cin >> n >> k >> s;
  for (i=0;i<n-1;i++){
    if (s[i]!=s[i+1]) b++;
  }
  cout << n-max(0,b-k*2)-1 << endl;
  return 0;
}

Measured memory_bytes: 512
n, m = [int(i) for i in input().split()]
switch_list_for_light_index = [0] * m

for light_index in range(m):
    switch_list_for_light_index[light_index] = [int(i) for i in input().split()[1:]]

p = [int(i) for i in input().split()]


def light_is_on(light_index, case):
    switch_list = switch_list_for_light_index[light_index]
    switch_on_count = 0
    for switch in switch_list:
        switch_on_count += int(case[switch - 1])
    if switch_on_count % 2 == p[light_index]:
        return True
    else:
        return False

answer = 0

for case_num in range(2**n):
    case = bin(case_num)[2:].zfill(n)
    suc_num = 0
    for light_index in range(m):
        if light_is_on(light_index, case) == True:
            suc_num += 1
        else:
            break
    if suc_num == m:
        answer += 1

print(answer)


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

using ll = long long;
using ull = unsigned long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define bzero(p, n) memset(p, 0, n)
#define all(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
inline ll powll(ll x,ll y) {ll p=1; while(y--) p*=x; return p;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    char sign[2] = {'+','-'};
    char c;
    int n[4][2];
    rep(i, 4) {
        cin >> c;
        n[i][0] = c - '0';
        n[i][1] = -n[i][0];
    }

    rep(i, 2) {
        rep(j, 2) {
            rep(k, 2) {
                if (n[0][0] + n[1][i] + n[2][j] + n[3][k] == 7) {
                    cout << n[0][0] << sign[i] << n[1][0] << sign[j] << n[2][0] << sign[k] << n[3][0] << "=7" << endl;
                    return 0;
                }
            }
        }
    }
}


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

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

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;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    string s = sread();
    long a, z;
    foreach (i; 0 .. s.length)
        if (s[i] == 'A')
        {
            a = i;
            break;
        }
    foreach_reverse (i; 0 .. s.length)
        if (s[i] == 'Z')
        {
            z = i;
            break;
        }
    writeln(z - a + 1);
}


Measured memory_bytes: 764
object Main extends App {
	val a = scala.io.StdIn.readInt
	val a1 = a/1000
	val a4 = a%10
	val a2 = a%100/10
	val a3 = a%1000/100

	if( a1 == a3 && a3 == a2) println("Yes")
	else if( a2 == a3 && a3 == a4) println("Yes")
	else println("No")

}



Measured memory_bytes: 27432
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        //String str[]=br.readLine().split(" ");
        //int n=Integer.parseInt(br.readLine());
        //int n=Integer.parseInt(str[0]);
        //int n=Integer.parseInt(str[1]);
        //String s=br.readLine();
        int n=Integer.parseInt(br.readLine());
        long sum=0;
        for(int i=1;i<=n;i++)
        {
            if(i%3!=0&&i%5!=0)
            sum=sum+i;
        }
        pw.println(sum);
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 32724
def dfs(cur, a, b, c)
  if cur == $n
    if [a, b, c].min > 0
      return (a-$a).abs + (b-$b).abs + (c-$c).abs - 30
    else
      return 9999999
    end
  end
  return [dfs(cur+1, a, b, c), dfs(cur+1, a+$l[cur], b, c)+10, dfs(cur+1, a, b+$l[cur], c)+10, dfs(cur+1, a, b, c+$l[cur])+10].min  
end

$n, $a, $b, $c = gets.chomp.split.map(&:to_i)
$l = []
$n.times do |i|
  $l[i] = gets.to_i
end
puts dfs(0, 0, 0, 0)

Measured memory_bytes: 1788