akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N;
  cin >> N;
  vector<ll> H(N);
  rep (i, N) cin >> H[i];
  ll ans = 0;
  ll current = 0;
  rep (i, N) {
    if (i == 0) continue;
    if (H[i] <= H[i-1]) {
      current++;
    } else {
      ans = max(ans, current);
      current = 0;
    }
  }
  ans = max(ans, current);
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 1024
#C - 白昼夢 / Daydream

s = input()[::-1]

while True:
  if s[:5] == "maerd":
    s = s[5:]
  elif s[:7] == "remaerd":
    s = s[7:]
  elif s[:5] == "esare":
    s = s[5:]
  elif s[:6] == "resare":
    s = s[6:]
  else:
    break

if s == "":
  print("YES")
else:
  print("NO")

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

#define F first
#define S second
#define ll long long
#define pb push_back
#define endl '\n'

using namespace std;

const int MOD = 1e9+7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  ll sum = 0, ans = 0;
  for (int &i: v) {
    cin >> i;
    sum = (sum + i) % MOD; 
  }
  for (int i = 0; i < n; ++i) {
    sum -= v[i];
    if (sum < 0) sum += MOD;
    ans += v[i] * sum;
    ans %= MOD;
  }           
  cout << ans << endl;
}


Measured memory_bytes: 3968
#include<stdio.h>

#define M 2000000

int H,A[M+1];

void maxHeapify(int i){
  int l,r,largest,tmp;

  l=2*i;
  r=2*i+1;

  if(l<=H && A[l]>A[i])
    largest=l;
  else
    largest=i;

  if(r<=H && A[r]>A[largest])
    largest=r;

  if(largest!=i){
    //swap(A[i],A[largest]);
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(largest);
  }
}

int main(){
  int i;
  
  scanf("%d",&H);

  for(i=1;i<=H;i++)
    scanf("%d",&A[i]);

  for(i=H/2;i>=1;i--)
    maxHeapify(i);

  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }

  printf("\n");

  return 0;
}



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

int main(void)
{
  int n;
  std::cin >> n;
  std::vector<int> hs;
  for(int i=0; i<n; i++)
  {
    int h;
    std::cin >> h;
    hs.push_back(h); 
  }
  
  int result = 0;
  int lasth = 0;
  int lastCount = 0;
  for( const auto& h : hs )
  {
    if( h <= lasth )
    {
      lastCount += 1;
    }
    else
    {
      result = std::max(lastCount, result);
      lastCount = 0;
    }
    lasth = h;
  }
  result = std::max(lastCount, result);
  std::cout << result;
  return 0; 
}


Measured memory_bytes: 892
import sys
input = sys.stdin.readline

'''

'''

x = int(input())
n = 8
for l, r in [(400, 599), (600, 799), (800, 999), (1000, 1199), (1200, 1399), (1400, 1599), (1600, 1799), (1800, 1999)]:
    if l <= x <= r:
        print(n)
        break
    n -= 1


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

int main(void){
	while(1){
		int d, n, m; cin >> d;
		if(d == 0) return 0;
		cin >> n >> m;
		vector<int> store;
		rep(i, n - 1){
			int tmp; cin >> tmp;
			store.push_back(tmp);
		}
		store.push_back(0); store.push_back(d); //??¬???????????????????????????
		sort(store.begin(), store.end());

		vector<int> k(m);
		rep(i, m) cin >> k[i];

		int sum = 0;
		rep(i, m){
			//????????¢?´¢??§k[i]??????????????????????????????????????????
			int l = *(lower_bound(store.begin(), store.end(), k[i]) - 1);
			int r = *(lower_bound(store.begin(), store.end(), k[i]));
			int ans = min(k[i] - l, r - k[i]);
			sum += ans;
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 1712
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{
	
	static Map<Character, Integer> roman_int = new HashMap<Character, Integer>();
	static{
		Main.roman_int.put('I', 1);
		Main.roman_int.put('V', 5);
		Main.roman_int.put('X', 10);
		Main.roman_int.put('L', 50);
		Main.roman_int.put('C', 100);
		Main.roman_int.put('D', 500);
		Main.roman_int.put('M', 1000);
	}
	
	static int toDecimal(String roman){
		char[] r = roman.toCharArray();
		int result = 0;
		
		Comparator<Character> rComperator = new Comparator<Character>(){
			
			@Override
			public int compare(Character c1, Character c2){
				int i1 = Main.roman_int.get(c1);
				int i2 = Main.roman_int.get(c2);
				if(i1 < i2)
					return -1;
				else if(i1 == i2)
					return 0;
				else
					return 1;
			}
		};
		
		char lastc = r[0];
		int temp = 0;
		for(char c: r){
			switch(rComperator.compare(lastc, c)){
				case -1:
					result += -temp;
					temp = Main.roman_int.get(c);
					break;
				case 1:
					result += temp;
					temp = Main.roman_int.get(c);
					break;
				case 0:
				default:
					temp += Main.roman_int.get(c);
			}
			lastc = c;
		}
		result += temp;
		return result;
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()){
			System.out.println(Main.toDecimal(sc.nextLine()));
		}
		sc.close();
	}
}

Measured memory_bytes: 15372
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
const ll ccc=1000000;
bool prime[ccc+1];
vector<ll> pr;
void makeprime(){
	ll i,j;
	for(i=2;i<=ccc;i++) prime[i]=true;
	for(i=2;i*i<=ccc;i++) if(prime[i]) for(j=2;j*i<=ccc;j++) prime[j*i]=false;
	for(i=2;i<=ccc;i++) if(prime[i]) pr.push_back(i);
}
template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll v):v(normS(v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll u[]={a,1,0},v[]={b,0,1};
		while(*v){
			ll t=*u/ *v;
			rep(i,3) swap(u[i]-=t*v[i],v[i]);
		}
		if(u[0]<0) rep(i,3) u[i]=-u[i];
		x=u[1],y=u[2];
		return u[0];
	}
	ModInt inv() const{
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<1000000007>;

int main(){
	makeprime();
	int N;
	cin>>N;
	mint a=1,b=0,c=0;
	vector<int> xs(N);
	rep(i,N) cin>>xs[i];
	rep(i,N){
		int x = xs[i];
		mint na = 0, nb = 0, nc = 0;
		if(prime[x] && (i-2<0||xs[i-2]<xs[i])){
			nb += a;
			nc += a;
		}
		if(prime[x] && (i-1<0||xs[i-1]<xs[i])){
			nb += b;
			nc += c;
		}
		{
			na += c;
		}
		a = na,b = nb,c = nc;
	}
	cout<<a+b<<endl;
}



Measured memory_bytes: 4892
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tmp = ReadLine().Split(' ');
            int K = int.Parse(tmp[0]);
            int N = int.Parse(tmp[1]);

            string[] tmp2 = ReadLine().Split(' ');
            List<int> A = new List<int>();
            for (int i = 0; i < N; i++)
            {
                A.Add(int.Parse(tmp2[i]));
            }

            List<int> B = new List<int>();
            for (int i = 0; i < N - 1; i++)
            {
                B.Add(A[i + 1] - A[i]);
            }

            B.Add(K - A[N-1] + A[0]);


            Write(K - B.Max());
        }
    }
}

Measured memory_bytes: 34932
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
	int n,k,ans=0;cin>>n>>k;
	for(int i=1;i<=n;i++){
		int val;cin>>val;
		if(val>=k)ans++;	
	}
	cout<<ans;
	return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 200001;

vector<vi> C(MAXN, vi());
ll PAR[MAXN] = {0};
ll DEP[MAXN] = {0};

ll N[3] = {0};

ll F[2] = {0};
bool bigpar = 0;

ll biggest = -1;

void dfs(ll i, ll par){
    PAR[i] = par;
    F[DEP[i]%2]++;
    trav(j,C[i]){
        if(j != par){
            DEP[j] = DEP[i]+1;
            dfs(j,i);
        }
    }
}

ll ANS[MAXN] = {0};
ll START[3] = {0};

void place(ll p, ll i){
    ANS[i] = START[p];
    START[p] += 3;
}

void solve1(){
    rep(c1,0,n){
        if(DEP[c1]%2 == bigpar){
            if(START[1] <= n){
                place(1,c1);
            }
            else{
                place(0,c1);
            }
        }
        else{
            if(START[2] <= n){
                place(2,c1);
            }
            else{
                place(0,c1);
            }
        }
    }
}

void solve2(){
    rep(c1,0,n){
        if(DEP[c1]%2 == bigpar){
            if(START[1] <= n){
                place(1,c1);
            }
            else{
                if(START[2] <= n){
                    place(2,c1);
                }
                else{
                    place(0,c1);
                }
            }
        }
        else{
            place(0,c1);
        }
    }
}

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

    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d,e;

    cin >> n;
    rep(c1,0,n-1){
        cin >> a >> b;
        a--;
        b--;
        C[a].push_back(b);
        C[b].push_back(a);
    }
    rep(c1,1,n+1){
        N[c1%3]++;
    }
    START[0] = 3;
    START[1] = 1;
    START[2] = 2;
    dfs(0,-1);

    if(F[1] > F[0])bigpar = 1;
    biggest = max(F[0], F[1]);

    if(biggest <= N[0] + N[1]){
        solve1();
    }
    else{
        solve2();
    }

    rep(c1,0,n){
        cout << ANS[c1] << " ";
    }cout << "\n";

    return 0;
}


Measured memory_bytes: 18560
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, k; cin >> n >> k;
  vector<long long> h(n); REP(i, n) cin >> h[i];
  sort(ALL(h));
  long long ans = LINF;
  REP(i, n-k+1) ans = min(ans, h[i+k-1] - h[i]);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
#define fo(i,s,e_ex) for(i=s;i<e_ex;i++)
#define Fo(i,k,n) for(i=k;k<n?i<=n:i>=n;k<n?i+=1:i-=1)
#define endl '\n'
#define MOD 1000000007//998244353
#define pbb push_back
#define mpp make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define mset(arr,val) memset(arr,val,sizeof(arr))
ll n;
double dp[305][305][305];
double answer(ll n1,ll n2,ll n3){
	if(n1+n2+n3==0) return 0;
	if(dp[n1][n2][n3]>=0) return dp[n1][n2][n3];
	double p0,p1,p2,p3,ans=1;
	p0=((double)(n-n1-n2-n3))/n;
	p1=((double)n1)/(n);
	p2=((double)n2)/(n);
	p3=((double)n3)/(n);
	if(n1>0) ans+=p1*answer(n1-1,n2,n3);
	if(n2>0) ans+=p2*answer(n1+1,n2-1,n3);
	if(n3>0) ans+=p3*answer(n1,n2+1,n3-1);
	ans/=(1-p0);
	return dp[n1][n2][n3]=ans;
}
void solve(ll caseno){
	ll i,j,n1=0,n2=0,n3=0,n0=0;
	cin>>n;
	fo(i,0,n){
		cin>>j;
		if(j==1) n1++;
		else if(j==2) n2++;
		else if(j==3) n3++;
	}
	mset(dp,-1);
	double ans=answer(n1,n2,n3);
	cout<<fixed<<setprecision(12)<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll t=1;
	//cin>>t;
	for(ll i=1;i<=t;i++){
		solve(i);
	}
	return 0;
}


Measured memory_bytes: 225532
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}


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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int t;
    cin>>t;
    while (t--)
    {
        int n;
        cin>>n;
        vector<pair<pair<int,int> ,pair<int,int> > >pp;
        int k,l,r;
        for(int i=0;i<n;i++)
        {
            cin>>k>>l>>r;
            pp.push_back({{abs(l-r),k},{l,r}});
        } 
        sort(pp.begin(),pp.end(),greater<>());
        set<int>s;
        for(int i=1;i<=n;i++)
            s.insert(i);
        int ans=0;
        int cnt=0;        
        for(auto i:pp)
        {
            if(i.second.first>i.second.second)
            {
                cnt++;
                auto j=s.lower_bound(i.first.second+1);
                if(j==s.begin())
                {
                    ans+=i.second.second;
                }
                else
                {
                    j--;
                    s.erase(j);
                    ans+=i.second.first;
                }                
            }
        }
        int sz=n-cnt;
        s.clear();
        for(int i=n;i>n-sz;i--)
            s.insert(i);
        for(auto i:pp)
        {
            if(i.second.first<=i.second.second)
            {
                auto j=s.lower_bound(i.first.second+1);
                if(j==s.end())
                {
                    j=s.begin();
                    ans+=i.second.first;
                    s.erase(j);
                }
                else
                {
                    s.erase(j);
                    ans+=i.second.second;
                }                
            }
        }
        cout<<ans<<'\n';
    }
        

} 
    


Measured memory_bytes: 18928
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

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

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  string s;cin>>s;
  if(s[0]=='7' || s[1]=='7' || s[2]=='7')cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


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

int main(void) {
  int n;
  cin >> n;
  
  vector<int64_t> lucas(87);
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  for (int i = 2; i < n + 1; i++)
    lucas.at(i) = lucas.at(i - 1) + lucas.at(i - 2);
  
  cout << lucas.at(n) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
 
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
 
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD
 
int main(){
 
int a,b;
cin>>a>>b;
cout<<"a ";
if(a<b)cout<<"<";
else if(a>b)cout<<">";
else cout<<"==";
cout<<" b"<<endl;
 
  return 0;
}

Measured memory_bytes: 1156
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        if(m==0){
            m=1;
        }
        int[] array = new int[m];
        for(int i=0;i<m;i++){
            try{
                array[i] = Integer.parseInt(sc.next());
            }catch(NoSuchElementException e){
                array[0] = -1;
            }
        }
        sc.close();
        int curstep = 0;
        int[] step = new int[n+1];
        step[0] = 1;
        if(array[0]==1){
            step[1] = 0;
            curstep++;
        }else{
            step[1] = 1;
        }
        int big = (int)Math.pow(10,9)+7;
        for(int i=2;i<n+1;i++){
            if(curstep < m && array[curstep] == i){
                step[i] = 0;
                curstep++;
            }else{
                step[i] = step[i-1] + step[i-2];
                if(step[i] > big){
                    step[i] -= big;
                }
            }
        }
        System.out.println(step[n]);
    }
}

Measured memory_bytes: 48716
//============================================================================
//  Search Allocation
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define pred(x) ((x)-1)
#define succ(x) ((x)+1)
//============================================================================
//============================================================================
//============================================================================

//============================================================================
//============================================================================
//----------------------------------------------------------------------------
#define INFTY 0x7fffffff
long change,N;
void merge(long *A, long left, long mid, long right)
{
    long i,j,k,*L,*R;
    long n1 = mid - left;
    long n2 = right - mid;

    L=malloc(succ(n1)*sizeof(long));
    R=malloc(succ(n2)*sizeof(long));
    for (i=0; i<n1; i++)
        L[i] = A[left + i];
    for (i=0; i<n2; i++)
        R[i] = A[mid + i];
    L[n1] = INFTY;
    R[n2] = INFTY;
    for (i=j=0, k = left; k<right; k++){
        if (L[i] <= R[j]){
            A[k] = L[i];
            i++;
            change++;
        }else{
            A[k] = R[j];
            j++;
            change++;
        }
    }
    free(L);
    free(R);
}
//----------------------------------------------------------------------------
void mergeSort(long * A, long left, long right)
{
    long mid;

    //for (mid=0; mid<N; mid++)
    //    printf("%ld ", A[mid]);
    //printf("\n");
    if (succ(left) < right){
        mid = (left + right)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}
//----------------------------------------------------------------------------
void input(FILE *file)
{
    long i,n;
    long *ary;

    fscanf(file, "%ld", &N);
    ary=malloc(N*sizeof(long));
    for (n=change=0; n<N; n++){
        fscanf(file, "%ld", &ary[n]);
    }
    mergeSort(ary, 0, N);
    for (i=0; i<N; i++){
        if (i) printf(" ");
        printf("%ld", ary[i]);
    }
    printf("\n%ld\n", change);
    free(ary);
}
//============================================================================
#ifndef DESKTOP
int main()
{
    input(stdin);
    return 0;
}
#endif

Measured memory_bytes: 8284
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n=INT()
    S=STR()
    r=0
    for s in S:
        if s=='R':
            r+=1
    
    w=0
    for i in range(r):
        if S[i]=='W':
            w+=1
    
    print(w)


if __name__=='__main__':
    do()

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

int main(){
  char s[200005], t[200005];  scanf("%s %s", s, t);
  int count = 0, len = strlen(s);
  for(int i=0; i<len; i++){
    if(s[i] != t[i])  count++;
  }
  
  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 2096
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> d >> x;
  rep(i, n) {
    cin >> a;
    ll now = 1;
    cnt = 0;
    while (1) {
      now = cnt * a + 1;
      if (now > d) break;
      cnt++;
      ans++;
    }
  }
  Cout(ans + x);
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int h,w;
	cin >> h >> w;
	vector<string> grid(h);
	for(int i = 0;i < h;i++)cin >> grid[i];

	vector<vector<bool>> gf(h,vector<bool>(w,false));
	for(int i = 0;i < h;i++){
		bool flag = true;
		for(int j = 0;j < w;j++){
			if(grid[i][j] == '#')flag = false;
		}
		if(flag){
			for(int j = 0;j < w;j++)gf[i][j] = true;
		}
	}

	for(int j = 0;j < w;j++){
		bool flag = true;
		for(int i = 0;i < h;i++){
			if(grid[i][j] == '#')flag = false;
		}
		if(flag){
			for(int i = 0;i < h;i++)gf[i][j] = true;
		}
	}

	for(int i = 0;i < h;i++){
		bool flag = false;
		for(int j = 0;j < w;j++){
			if(!gf[i][j]){
				cout << grid[i][j];
				flag = true;
			}
		}
		if(flag)cout << endl; 
	}
}


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

using namespace std;

const int kMax = 100 + 5;

int n;
int num[kMax];

void print_num() {
    for(int i = 0;i < n;++ i) {
        if(i) printf(" ");
        printf("%d", num[i]);
    }
    printf("\n");
}

void solve() {
    int res = 0;
    for(int i = 1;i < n;++ i) {
        for(int j = i - 1;j >= 0;-- j) {
            if(num[j] > num[j + 1]) swap(num[j], num[j + 1]), ++ res;
        }
    }
    print_num();
    printf("%d\n", res);
}

int main() {
    scanf("%d", &n);
    for(int i = 0;i < n;++ i) scanf("%d", &num[i]);
    solve();
}

Measured memory_bytes: 2712
while True:
    h, w = map(int, raw_input().split())
    if h == 0 and w == 0:
        break
    
    for i in range(0, h):
        wid = ""
        for j in range(0, w):
            if  (i+j)%2 == 0:
                wid += "#"
            else:
                wid += "."
        print wid

    print ""

Measured memory_bytes: 4208
#include<iostream>
#include<algorithm>
using namespace std;
long long dp[10][1001];
int main(){
	int n,s;
	while(true){
	cin>>n>>s;
	if(n==0&&s==0)break;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=s;j++){
			dp[i][j]=0;
		}
	}
	dp[0][0]=1;
	for(int k=0;k<=100;k++){
		for(int i=n-1;i>=0;i--){
			for(int j=0;j+k<=s;j++){
				dp[i+1][j+k]+=dp[i][j];
			}
		}
	}
	cout<<dp[n][s]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
int n;
int sum(int m){
  if (m==0) return 0;
  return m%10 + sum(m/10);
}
int main(){
  cin >> n;
  int ans = INT_MAX;
  for(int i=1;i<n;i++){
    ans = min(ans, sum(i)+sum(n-i));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll a, b;
  cin >> a >> b;
  ll ans = -1001001001;
  chmax(ans, a+b);
  chmax(ans, a-b);
  chmax(ans, a*b);
  cout << ans << endl;
  return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(),(x).rend()

typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;

bool graph[8][8];
bool visited[8];

int dfs(int v,int n,bool visited[8]){
	bool all_visited=true;
	for (int i = 0; i < n; ++i){
		if(visited[i]==false)all_visited=false;
	}
	if(all_visited)return 1;

	int sum=0;

	for (int i = 0; i < n; ++i){
		if(graph[v][i]==false||visited[i]==true)continue;
		
		visited[i]=true;
		sum+=dfs(i,n,visited);
		visited[i]=false;
	}

	return sum;

}

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

	int a,b;
	for (int i = 0; i < m; ++i){
		cin>>a>>b;
		graph[a-1][b-1]=graph[b-1][a-1]=true;
	}

	visited[0]=true;
	cout<<dfs(0,n,visited)<<endl;
	return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int ans = 0;
    int N; cin >> N;
    vector<int>h(N+1,0);
    rep(i, N)cin >> h[i];
    rep(i, N) {
        for (int j = 0;;j++) {
            if (h[i] == 0) {
                ans += j;
                break;
            }
            for (int k = i;;k++) {
                if (h[k] == 0)break;
                h[k]--;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if A <= B:
    if A + V*T >= B + W*T:
        print("YES")
    else:
        print("NO")
else:
    if A - V*T <= B - W*T:
        print("YES")
    else:
        print("NO")

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

int main() {
	int N,count=0,cco=0;
	cin >> N;
	vector<int> H(N);
	for(int i=0;i<N;i++){
		cin >> H.at(i);
	}
    int j;
	for(int i=0;i<N-1;i++){
		
		j=i;
		while(H.at(j)>=H.at(j+1)){
			count++;
			cco=max(cco,count);
			j++;
		    if(j==N-1) break;
		}
        i+=count;
		count=0;
	}
	cout << cco << endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(){
  int counth=0,countt=0,n,i,ku;
  char ha[101],ta[101];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",ta,ha);
    ku=strcmp(ta,ha);
    if(ku==0){
      counth++;
      countt++;
    }
    else if(ku>0)countt+=3;
    else counth+=3;
  }
  printf("%d %d\n",countt,counth);
  return 0;
}

Measured memory_bytes: 604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int A;
    int B;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.A = sc.nextInt();
        this.B = sc.nextInt();
    }
    
    //解答処理
    private int solve() {
        int answer = A * B;
        
        return answer;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35656
using System;
using System.Collections.Generic;
using System.Linq;

namespace Project {
    class Program {
        static void Main(string[] args) {
            var cr = new CR();
            var K = cr.i;
            var S = cr.i;

            var ans = 0;
            for (int x = 0; x <= K; x++) {
                for (int y = 0; y <= K; y++) {
                    var z = S - (x + y);
                    if (0 <= z && z <= K)
                        ans++;
                }
            }
            Console.WriteLine(ans);
        }

        private class CR {
            System.IO.TextReader _r;
            Queue<string> _d;
            public CR() { _r = Console.In; _d = new Queue<string>(); }
            string Read() {
                while (_d.Count == 0)
                    foreach (var v in _r.ReadLine().Split(' '))
                        if (v != "")_d.Enqueue(v);
                return _d.Dequeue();
            }
            public int i { get { return int.Parse(Read()); } }
            public string s { get { return Read(); } }
        }
    }
}

Measured memory_bytes: 11220
n=int(input())
x=[0]*n
y=[0]*n
for c in range(n):
    x[c],y[c]=map(int,input().split())
s=0
for i in range(n-1):
    for j in range(i+1,n):
        s=s+((x[i]-x[j])**2+(y[i]-y[j])**2)**0.5
print(s*2/n)

Measured memory_bytes: 3188
import math


def main():
    Q = int(input())

    N = 10 ** 5
    is_prime = eratosthenes(N)
    like_2017 = [0 for _ in range(N + 1)]
    for i in range(3, N + 1, 2):
        if is_prime[i] and is_prime[(i + 1) // 2]:
            like_2017[i] = 1
    for i in range(3, N + 1):
        like_2017[i] += like_2017[i - 1]

    for _ in range(Q):
        l, r = map(int, input().split())
        print(like_2017[r] - like_2017[l - 1])


def eratosthenes(N):
    """エラトステネスの篩"""
    is_prime = [True for _ in range(N + 1)]
    is_prime[0] = False
    is_prime[1] = False
    max_prime = int(math.sqrt(N))
    for n in range(2, max_prime + 1):
        if is_prime[n]:
            # n-1までは判定済みのため除外されている
            # => max_prime導入も同じ理由
            for i in range(n * n, N + 1, n):
                is_prime[i] = False
    return is_prime

if __name__ == '__main__':
    main()


Measured memory_bytes: 7212
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#include <utility>
#include <numeric>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>h(n);
	REP(i, n) {
		cin >> h[i];
	}
	ll ans = 0;
	vector<int>dp(n);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++) {
		dp[i] += min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int gcd(int x, int y) {
    if(y == 0)
        return x;
    else if(x > y) 
        return gcd(y, x % y);
    else
        return gcd(x, y % x);
}
int main() {
    int x, y;
    cin >> x >> y;

    cout << gcd(x, y) << endl;
    return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>

int main(){
  int h[10000], w[10000], i, j, k = 0;
  while(1){
    scanf("%d %d", &h[k], &w[k]);
    if(h[k] == 0 && w[k] == 0)
      break;
    k++;
  }

  k = 0;
  while(h[k] != 0 && w[k] != 0){
    for(i = 1; i <= h[k]; i++){
      for(j = 1; j <= w[k]; j++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
    k++;
  }

  return 0;
}



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

public class Main {

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

        for(int n=0; n<N; n++) H[n]=sc.nextInt();

        int ans = 0;
        int highest = 0;
        for(int n=0; n<N; n++){
            if(H[n] >= highest){
                ans++;
                highest = H[n];
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main(){
    string s1,s2;
    cin >> s1 >> s2;
    if(s1.size()>s2.size()){
        cout << "GREATER" << endl;
        return 0;
    }else if(s1.size()<s2.size()){
        cout << "LESS" << endl;
        return 0;
    }else{
        for(int i=0;i<s1.size();i++){
            int a = s1[i]-'0';
            int b = s2[i]-'0';
            if(a>b){
                cout << "GREATER" << endl;
                return 0;
            }else if(b>a){
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
}



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

int main()
{
    int a, b, c;
    int temp;

    cin >> a >> b >> c;

    if (a > b) {
        temp = a;
        a = b;
        b = temp;
    }
    if (a > c) {
        temp = a;
        a = c;
        c = temp;
    }
    if (b > c) {
        temp = b;
        b = c;
        c = temp;
    }

    cout << a << " " << b << " " << c << endl;

    return 0;
}

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

typedef long long ll;

int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main() {
  int n;
  cin >> n;
  int a[10];
  memset(a,0,sizeof(a));
  bool b[10][7]={{1,1,1,0,1,1,1},{0,0,1,0,0,1,0},{1,0,1,1,1,0,1},
		 {1,0,1,1,0,1,1},{0,1,1,1,0,1,0},{1,1,0,1,0,1,1},
		 {1,1,0,1,1,1,1},{1,0,1,0,0,1,0},{1,1,1,1,1,1,1},
		 {1,1,1,1,0,1,1}};
  for(int i=0; i<10; i++) {
    for(int j=0; j<7; j++) {
      if(b[i][j]) a[i]|=(1<<j);
    }
  }
  int k;
  cin >> k;
  int c[14];
  memset(c,0,sizeof(c));
  for(int i=0; i<k; i++) {
    int x,y;
    cin >> x >> y;
    c[x]|=(1<<y);
  }
  ll d[100];
  memset(d,0LL,sizeof(d));
  int x,y,z;
  for(int i=0; i<24; i++) {
    x=0;
    for(int t=0; t<7; t++) {
      if(a[i/10%10]&(1<<t) && !(c[8]&(1<<t))) x++;
      if(a[i%10]&(1<<t) && !(c[9]&(1<<t))) x++;
    }
    for(int j=0; j<60; j++) {
      y=0;
      for(int t=0; t<7; t++) {
	if(a[j/10%10]&(1<<t) && !(c[10]&(1<<t))) y++;
	if(a[j%10]&(1<<t) && !(c[11]&(1<<t))) y++;
      }
      for(int k=0; k<60; k++) {
	z=0;
	for(int t=0; t<7; t++) {
	  if(a[k/10%10]&(1<<t) && !(c[12]&(1<<t))) z++;
	  if(a[k%10]&(1<<t) && !(c[13]&(1<<t))) z++;
	}
	if(n-(x+y+z)>=0) d[n-(x+y+z)]++;
      }
    }
  }
  ll d2[2][100];
  memset(d2,0LL,sizeof(d2));
  for(int i=1; i<=12; i++) {
    x=0;
    for(int t=0; t<7; t++) {
      if(a[i/10%10]&(1<<t) && !(c[4]&(1<<t))) x++;
      if(a[i%10]&(1<<t) && !(c[5]&(1<<t))) x++;
    }
    for(int j=1; j<=day[i]; j++) {
      y=0;
      for(int t=0; t<7; t++) {
	if(a[j/10%10]&(1<<t) && !(c[6]&(1<<t))) y++;
	if(a[j%10]&(1<<t) && !(c[7]&(1<<t))) y++;
      }
      for(int k=0; k<100; k++) {
	if(k-(x+y)>=0) {
	  d2[1][k-(x+y)]+=d[k];
	  d2[0][k-(x+y)]+=d[k];
	}
      }
    }
    if(i==2) {
      int j=29;
      y=0;
      for(int t=0; t<7; t++) {
	if(a[j/10%10]&(1<<t) && !(c[6]&(1<<t))) y++;
	if(a[j%10]&(1<<t) && !(c[7]&(1<<t))) y++;
      }
      for(int k=0; k<100; k++) {
	if(k-(x+y)>=0) {
	  d2[1][k-(x+y)]+=d[k];
	}
      }
    }
  }
  ll ans=0;
  for(int i=0; i<10000; i++) {
    x=0;
    for(int t=0; t<7; t++) {
      if(a[i/1000%10]&(1<<t) && !(c[0]&(1<<t))) x++;
      if(a[i/100%10]&(1<<t) && !(c[1]&(1<<t))) x++;
      if(a[i/10%10]&(1<<t) && !(c[2]&(1<<t))) x++;
      if(a[i%10]&(1<<t) && !(c[3]&(1<<t))) x++;
    }
    int k=0;
    if(i%400==0) k=1;
    else if(i%100==0) k=0;
    else if(i%4==0) k=1;
    for(int j=0; j<100; j++) {
      if(j-x==0) ans+=d2[k][j];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1164
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

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

	vector<ll> l(n);

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

	int co = 0;

	for (int i = 0; i < n-2;i++) {
		for (int j = i+1; j < n - 1; j++) {
			for (int k = j + 1; k < n; k++) {
				ll g = max(l[i],l[j]);
				g = max(g, l[k]);
				if (l[i]!=l[j]&&l[j]!=l[k]&&l[i]!=l[k]&&2*g<l[i]+l[j]+l[k]) {
					co++;
				//cout << l[i] << l[j] << l[k] << endl;
				}

			}
		}
	}

	cout << co << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

const int MaxN = 100000;
const int MaxM = 100000;

int n, m;
s64 nK;

int a[MaxN + 1], d[MaxN + 1];

int rep[MaxN + 1];
int ret[MaxN + 1];

inline int work(int *a, int *b)
{
	static int c[MaxN + 1];
	for (int i = 1; i <= n; ++i)
		c[i] = a[b[i]];
	for (int i = 1; i <= n; ++i)
		a[i] = c[i];
}

int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
		d[i] = a[i] - a[i - 1];
	}

	cin >> m >> nK;
	for (int i = 1; i <= n; ++i)
		rep[i] = ret[i] = i;
	for (int i = 1, x; i <= m; ++i)
	{
		scanf("%d", &x);
		swap(rep[x], rep[x + 1]);
	}

	for (s64 i = nK; i; i >>= 1)
	{
		if (i & 1)
			work(ret, rep);
		work(rep, rep);
	}

	work(d, ret);

	s64 res = 0;
	for (int i = 1; i <= n; ++i)
		printf("%lld\n", res += d[i]);

	return 0;
}

Measured memory_bytes: 3200
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		HashMap<String, Integer> h = new HashMap<String, Integer>();
		String[] str = sc.nextLine().split(" ");
		String max = "";
		for (int i = 0; i < str.length; i++) {
			if (max.length() < str[i].length())
				max = str[i];
			if (h.containsKey(str[i]))
				h.put(str[i], h.get(str[i]) + 1);
			else
				h.put(str[i], 1);
		}
		int maxCnt = 0;
		String maxCntWord = "";
		for (String s : h.keySet()) {
			if (maxCnt < h.get(s)) {
				maxCnt = h.get(s);
				maxCntWord = s;
			}
		}
		System.out.println(maxCntWord + " " + max);
	}

}

Measured memory_bytes: 15304
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			int c = Integer.parseInt(chr[2]);
			int d = Integer.parseInt(chr[3]);
			System.out.println(a+b>c+d?"Left"
							  :a+b<c+d?"Right"
							  :"Balanced");

		}
	}
}

Measured memory_bytes: 25424
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    C = input()
    red = C.count('R')
    red2 = C[:red].count('R')
    print(red-red2)



if __name__ == '__main__':
    main()


Measured memory_bytes: 9480
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s; cin >> s; s+= 'S';
    int cur = 0;
    int best = 0;
    for(auto &a: s){
        if(a == 'R'){
            cur++;
        }else{
            best = max(best,cur);
            cur = 0;
        }
    }
    cout << best << "\n";
    return 0;
}


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

int N, M, Q, ans = 0;
vector<int> a(0), b(0), c(0), d(0);
vector<int> A(0);

bool next(){
//	printf("test2\n");
//	printf("(%d, %d, %d)\n", N, M, Q);
	int i, j;
	for(i = N - 1; i >= 0; i--){
//		printf("test3:%d\n", A[i]);
		if(A[i] < M){
//			printf("test4\n");
			A[i]++;
			for(j = i + 1; j < N; j++){
				A[j] = A[i];
			}
			return true;
		}
	}
	return false;
}

signed main(){
	int i;
	scanf("%d%d%d", &N, &M, &Q);
	a.assign(Q, 0);
	b.assign(Q, 0);
	c.assign(Q, 0);
	d.assign(Q, 0);
	for(i = 0; i < Q; i++){
		scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
		a[i]--;
		b[i]--;
	}
	A.assign(N, 1);
	do{
/*		printf("A:");
		for(i = 0; i < N; i++){
			printf("%d ", A[i]);
		}
		printf("\n");
*/		int sum = 0;
		for(i = 0; i < Q; i++){
			if(A[b[i]] - A[a[i]] == c[i]){
				sum += d[i];
			}
		}
//		printf("sum = %d\n", sum);
		ans = max(ans, sum);
	}while(next());
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3804
#include <stdio.h>

int main(){
  int ans = 0;
  int tmp = 0;
  while(1){
    char c = getchar();
    if(c=='A' ||c=='G' ||c=='T' ||c=='C'){
      tmp++;
      if(ans < tmp){
        ans = tmp;
      }
    }else if(c >= 'A' && c <= 'Z'){
      tmp = 0;
    }else{
      break;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
/* ex4_1
   UMAboogie */

#include<stdio.h>
#include<math.h>

int main(void){
  double apple,range;
  scanf("%lf  %lf",&apple,&range); //りんごの個数と監視の幅を入力
  int watchmen = ceil(apple / (range*2 + 1)); //1人の監視員は監視の幅の2倍に１加えた数のりんごを監視できるので、りんごの数をそれで割り小数点以下、切り上げる
  printf("%d",watchmen); //監視員の人数を出力
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<climits>
#include<functional>

typedef long long ll;

int m, n;
ll p[10001], c[10001], e[10001];
ll dp[501][10001];

int main(){
	for (int i = 0; i < 501; i++){
		for (int j = 0; j < 10001; j++)dp[i][j] = LLONG_MAX;
	}
	dp[0][0] = 0;

	std::cin >> m >> n;

	for (int i = 0; i < m; i++)std::cin >> p[i];
	for (int i = 0; i < n; i++)std::cin >> c[i] >> e[i];

	for (int i = 0; i < n; i++){
		for (int j = 0; j <= 10000; j++){
			if (dp[i][j] != LLONG_MAX){
				dp[i + 1][j] = std::min(dp[i + 1][j], dp[i][j]);
				dp[i + 1][std::min<ll>(10000, j + c[i])] = std::min(dp[i + 1][std::min<ll>(10000, j + c[i])], dp[i][j] + e[i]);
			}
		}
	}
	for (int i = 10000 - 1; i >= 0; i--)dp[n][i] = std::min(dp[n][i], dp[n][i + 1]);

	std::sort(p, p + m, std::greater<ll>());

	for (int i = 1; i < m; i++)p[i] += p[i - 1];

	ll max = 0;
	for (int i = 0; i < m; i++){
		max = std::max(max, p[i] - dp[n][i + 1]);
	}
	std::cout << max << std::endl;

	return 0;
}

Measured memory_bytes: 40428