akhauriyash/Code-Regression huggingface dataset:
#include<iostream> 
#include<vector> 
#include<algorithm> 
#include<iomanip> 
#include<stack> 
#include<unordered_map>
#include<queue> 
#include<deque>
#include<map> 
#include<climits>
#include<set> 
#include<string> 
//#include<time.h>
//#include<bits/stdc++.h> 
using namespace std; 
#define lld long long int 
#define eb emplace_back
//to insert pair use eb
#define mp make_pair
#define fi first
#define se second
#define pb push_back

#define X 1000000007
#define Y 998244353
#define E4 10000
#define E5 100000
#define E6 1000000
#define inf 2001001001001001001
#define pi 3.1415926535

# define rec2(i,a,n) for(lld i=a;i<n;i++) 
#define rec(i,n) for(lld i=0;i<n;i++)
#define rev(i,a,n) for(lld i=n-1;i>=a;i--)
#define all(v) (v).begin(), (v).end()
#define large(v)  *max_element(all(v))
#define small(v)  *min_element(all(v)) 
#define v vector 
#define p(x,y)  pair<x,y> 
const double EPS = 1e-6;

void google(int i)
{  cout<<"Case #"<<i<<": "; }

//prime[i]==1 if it is prime 
lld prime[E6+1]; 
void sieve(lld n) 
{ rec(i,n+1) 
    prime[i]=1; 
   for(lld i=2;i*i<=n;i++) 
     { if(prime[i]!=1) 
          continue; 
         for(lld j=i*i;j<=n;j=j+i) 
          if(prime[j]==1)
           prime[j]=i; 
      }
}

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

//fermat a^(m-2)%mod
lld binarymul(lld a,lld n,lld m)
{  lld res=1; 
 while(n) 
  { if(n%2) 
      { res=(res*a)%m; 
         n--; 
      } 
     a=(a*a)%m; 
     n/=2; 
  }
  return res; 
}
/*
void complexity(time_t end,time_t start)
{ 
  double taken = double(end - start); 
    cout<<"Time : "; 
    cout<<fixed<<taken<<setprecision(8);         cout<<" sec "<<endl;
}
*/ 
void bfs(lld s,v<lld> g[],lld n)
{ 
   bool vis[n]; 
   rec(i,n) 
    vis[i]=false; 
    
   vis[s]=true; 
   deque<lld> q; 
   q.pb(s); 
   
   while(!q.empty()) 
   {  
      s=q.front(); 
     q.pop_front(); 
      
     for(lld i=0;i<g[s].size();i++) 
      {  
        if(!vis[g[s][i]])
         { vis[g[s][i]]=true; 
            q.pb(g[s][i]); 
         }
      }
   }
}

void dfs(lld u,v<lld> g[],bool *vis)
{ 

   vis[u]=true; 
   for(lld i=0;i<g[u].size();i++) 
     if(!vis[g[u][i]])
          dfs(g[u][i],g,vis); 
       
}
void contest(lld t); 
int main()
{   
    /*
    time_t start, end; 
    time(&start); 
    */
   ios_base::sync_with_stdio(false); 
   cin.tie(0);
     #ifdef PUNEET_GOEL
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif
   //sieve(E6); 
    lld T=1; 
   
    rec(t,T) 
    {
      contest(t); 
    }
    /*
     time(&end); 
    complexity(end,start);
    */
	return 0;
}

void contest(lld t)
{ 
  lld n; 
  cin>>n; 
  lld a[n],b[n]; 
  lld cnt=0; 
  bool flag=false; 
  rec(i,n) 
   {  
     cin>>a[i]>>b[i]; 
     if(a[i]==b[i])      
       cnt++; 
     else 
      cnt=0; 
     if(cnt>=3) 
      flag=true; 
   }
   if(flag) 
    cout<<"Yes"; 
    else 
    cout<<"No"; 
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)

int N;
int A[200010];
int num[200010];

int nCr(int n, int r) {
	if(n==0)return 1;
	if(n<r)return 0;
	if(r*2>n)r=n-r;
	int dividend=1;
	int divisor=1;
	for (int i=1;i<=r;i++){
		dividend*=(n-i+1);
		divisor*=i;
	}
	return dividend/divisor;
}

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
		num[A[i]-1]=i+1;
	}
	int ans=0;
	set<int> U;
	U.insert(0);
	U.insert(N+1);
	REP(i,N){
		auto l=U.lower_bound(num[i]);
		ans+=(i+1)*(*l-num[i])*(num[i]-*(--l));
		U.insert(num[i]);
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main(){
    int a,b,c,d; scanf("%d%d%d%d",&a,&b,&c,&d);
    int l = a + b; int r = c + d;
    if(l < r)
        printf("Right\n");
    
    else if(l == r)
        printf("Balanced\n");
    
    else
        printf("Left\n");
    
    return 0;
}


Measured memory_bytes: 256
//Name: List of Top 3 Hills
//Level: 1
//Category: ????????????
//Note:

#include <stdio.h>

int compare_int(const void *a, const void *b)
{return *(int*)a - *(int*)b;}

int main()
{
    int x[10];
    int i, j;
    int tmp;

    for (i = 0; i < 10; i++)
      scanf("%d", &x[i]);

    qsort (x, 10, sizeof(int), compare_int);

    for (i = 0; i < 3; i++)
      printf("%d\n", x[9-i]);

    return 0;
}

Measured memory_bytes: 604
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		int M = sc.nextInt();
		long[] A = new long[N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextLong();
		}
		long[] sum = new long[N];
		for (int i = 0; i < N; ++i) {
			sum[i] = A[i] + (i - 1 >= 0 ? sum[i - 1] : 0);
		}
		double[][] f = new double[N + 1][M + 1];
		for (int i = 0; i < f.length; ++i) {
			for (int j = 0; j < f[i].length; ++j)
				f[i][j] = -Long.MAX_VALUE / 3;
		}
		f[0][0] = 0;
		//ブロックiの左側に仕切りがあり、使った仕切りの数は全部でj個の時の最大値
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < M; ++j) {
				for (int k = i + 1; k <= N; ++k) {
					double add = sum[k - 1] - (i > 0 ? sum[i - 1] : 0);
					add /= (k - i);
					f[k][j + 1] = Math.max(f[k][j + 1], f[i][j] + add);
				}
			}
		}
		PrintWriter pw = new PrintWriter(System.out);
		pw.printf("%.20f\n", f[N][M]);
		pw.close();
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}




Measured memory_bytes: 28824
#include <iostream>
#include <queue>
#define int long long
using namespace std;
signed main() {
	int k;
	cin >> k;
	queue<int> q;
	for (int i = 1; i <= 9; i++) q.push(i);
	while (!q.empty()) {
		int x = q.front(); q.pop(); k--;
		if (k == 0) {
			cout << x << '\n';
			break;
		}
		for (int y = (x % 10) - 1; y <= (x % 10) + 1; y++) {
			if (y < 0 || y > 9) continue;
			q.push(x * 10 + y);
		}
	}
	return 0;
}

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

long long n, m, a[100009], b[100009], c[100009], s[100009], t[100009], col[100009];
vector<pair<long long, long long>> x[100009]; map<pair<int, int>, int>M;
vector<pair<long long, long long>>V;

void dfs(int pos, int dep, int pre, long long cost) {
	if (col[pos] != -1) return;
	col[pos] = dep;
	if (pre != -1) {
		M[make_pair(pre, pos)] = 1; M[make_pair(pos, pre)] = 1;
		s[pos] = cost - s[pre];
	}
	for (int i = 0; i < x[pos].size(); i++) dfs(x[pos][i].first, dep ^ 1, pos, x[pos][i].second);
}

bool OK = true;

void dfs2(long long pos, long long cur) {
	if (t[pos] != (1LL << 60)) {
		if (t[pos] != cur) OK = false;
		return;
	}
	t[pos] = cur;
	for (int i = 0; i < x[pos].size(); i++) {
		dfs2(x[pos][i].first, x[pos][i].second - cur);
	}
}

int main() {
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		cin >> a[i] >> b[i] >> c[i];
		x[a[i]].push_back(make_pair(b[i], c[i]));
		x[b[i]].push_back(make_pair(a[i], c[i]));
	}
	for (int i = 1; i <= n; i++) col[i] = -1;
	dfs(1, 0, -1, 0);
	for (int i = 1; i <= m; i++) {
		if (M[make_pair(a[i], b[i])] == 1) continue;
		if (col[a[i]] == col[b[i]]) {
			long long E = c[i] - (s[a[i]] + s[b[i]]);
			if (E % 2 == 1) { cout << "0" << endl; return 0; }
			V.push_back(make_pair(a[i], s[a[i]] + E / 2));
			break;
		}
	}
	if (V.size() == 0) {
		long long m1 = (1LL << 60), m2 = (1LL << 60);
		for (int i = 1; i <= n; i++) {
			if (col[i] == 0) m1 = min(m1, s[i]);
			if (col[i] == 1) m2 = min(m2, s[i]);
		}
		for (int i = 1; i <= m; i++) {
			if (s[a[i]] + s[b[i]] != c[i]) { cout << "0" << endl; return 0; }
		}
		cout << max(m1 + m2 - 1, 0LL) << endl;
	}
	else {
		for (int i = 1; i <= n; i++) t[i] = (1LL << 60);
		dfs2(V[0].first, V[0].second);

		for (int i = 1; i <= n; i++) {
			if (t[i] <= 0) OK = false;
		}
		if (OK == true) cout << "1" << endl;
		else cout << "0" << endl;
	}
	return 0;
}

Measured memory_bytes: 37504
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

    ll N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;

    for (ll i = 0; i <= N - 1; i++) {
        ll u_u = i * D;
        ll u_d = i * C;
        ll d_u = (N - 1 - i) * C * -1;
        ll d_d = (N - 1 - i) * D * -1;
        ll u = u_u + d_u;
        ll d = d_d + u_d;
        if (B >= A + d && B <= A + u) {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int64_t Lucas(int N, vector<int64_t> &numbers);

int main()
{
  int N;
  cin >> N;
  vector<int64_t> numbers(86+1);
  numbers.at(0) = 2;
  numbers.at(1) = 1;
  int64_t ans = Lucas(N, numbers);
  printf("%lld\n", ans);
}

int64_t Lucas(int N, vector<int64_t> &numbers)
{
  if(numbers.at(N) != 0) return numbers.at(N);
  numbers.at(N) = Lucas(N-1, numbers) + Lucas(N-2, numbers);
  return numbers.at(N);
}


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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main() {
    string s;
    cin >> s;
    
    int a = 0;
    rep(i,s.length()){
        if(s[i] == 'A'){
            a = i;
            break;
        }
    }
    
    int z = 0;
    rep(i,s.length()){
        if(s[i] == 'Z'){
            z = i;
        }
    }
    
    cout << z - a + 1 << endl;
}

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

using namespace std;

bool sim(long long count, long long A, long long B, vector<long long>& h){
  long long diff = A - B;
  long long all = count * B;
  for (int i=0;i<h.size();i++) {
    if (all<h[i]) {
      count -= (h[i] - all) / diff;
      if (((h[i]-all)%diff)!=0)
        count --;
    }
    if (count < 0)
      return false;
  }


  return true;
}



int main(){
  long long N,A,B;

  cin>>N>>A>>B;
  vector<long long> h(N);
  for(int i=0;i<N;i++){
    cin>>h[i];
  }
  sort(h.begin(),h.end());

  long long ans =0;

  long long lb = 0, ub = 1000000000;

  while (lb < ub) {
    long long mid = (lb + ub) / 2;
    if (sim(mid,A,B,h)) ub = mid;
    else lb = mid+1;
  }
  ans = ub;
  cout << ans <<endl;

  return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	string str;
	cin>>str;
	int size = str.size();
	int ans = 0;
	for(int i=0;i<size;++i){
		ans += str[i]-'0';
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int s = in.nextInt();
            boolean[] exists = new boolean[1000001];

            int index = 0;
            while (true) {
                index++;
                if (exists[s]) {
                    out.println(index);
                    return;
                }
                exists[s] = true;
                if (s % 2 == 0) {
                    s = s / 2;
                } else {
                    s = 3 * s + 1;
                }
            }
        }

    }
}



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

using ll = long long;

vector<int> operator*(const vector<int>& a, const vector<int>& b)
{
    const auto N = int(a.size());
    auto c = vector<int>(N);
    for (auto i = 0; i < N; i++)
        c[i] = a[b[i]];
    return c;
}

template <typename T>
T power(const T x, const ll K)
{
    if (K == 1) return x;
    else if (K % 2 == 0) return power(x*x, K/2);
    else return x * power(x*x, K/2);
}

int main()
{
    ios::sync_with_stdio(false);

    int N; cin >> N;

    auto initial = vector<int>(N);
    for (auto& x : initial) cin >> x;

    auto delta = vector<int>(N-1);
    for (auto i = 0; i < N-1; i++)
        delta[i] = initial[i+1]-initial[i];

    int M; ll K; cin >> M >> K;

    auto pi = vector<int>(N-1);
    iota(begin(pi), end(pi), 0);

    for (auto i = 0; i < M; i++)
    {
        int a; cin >> a;
        a--;
        swap(pi[a], pi[a-1]);
    }

    pi = power(pi, K);

    auto x = ll(initial[0]);
    for (auto i = 0; i < N; i++)
    {
        cout << x << endl;
        if (i != N-1) x += delta[pi[i]];
    }
}


Measured memory_bytes: 25728
#![allow(unused)]

use std::{cell, cmp, collections, convert, fmt, io, iter, ops, str};

use cell::{Cell, RefCell};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($($args: tt)*) => { eprint!($($args)*) };
}

#[cfg(feature = "debug")]
macro_rules! debugln {
    ($($args: tt)*) => { eprintln!($($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($($args:tt)*) => {};
}

#[cfg(not(feature = "debug"))]
macro_rules! debugln {
    ($($args:tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn main() {
    let a = parse_word::<i32>();
    let b = parse_word::<i32>();

    println!("{}", vmax!(a + b, a - b, a * b));
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if !buf.is_empty() {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn next_prime(x: i32) -> i32 {
    for i in (x + 1).. {
        if is_prime(i) {
            return i;
        }
    }

    panic!("attempt to add with overflow");
}

fn is_prime(x: i32) -> bool {
    let ceil = f64::from(x).sqrt().ceil() as i32;
    x == 2 || (2..(ceil + 1)).all(|i| x % i != 0)
}

fn bit_high(bits: u64, pos: u64) -> bool {
    bits & (1 << pos) != 0
}


Measured memory_bytes: 4352
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextssort(n,a){return a?cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>b-a):cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>a-b);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}
var streams=[];function print(s){streams.push(s);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));
if(streams.length)console.log(streams.join("\n"));

function main(){
  var s = nextstr();
  return s[s.length-1] === "s" ? s+"es" : s+"s";
}

Measured memory_bytes: 29708
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>

class abc074a {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n, a;
	    in >> n >> a;
	    out << n * n - a << std::endl;

	}
};


int main() {
	abc074a solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int ncK(int N, int K) {
  if (N < K) return 0;
  if (N == 0) return 1;
  int res = 1;
  for (int i = 0; i < K; i++) {
    res *= N - i;
    res /= i + 1;
  }
  return res;
}
int dfs(string &S, int i, int K) {
  int n = S.size();
  int r = n - i;
  if (K < 0 || K > r) {
    return 0;
  } else if (K == 0) {
    return 1;
  }
  int d = S[i] - '0';
  int res = 0;
  if (d == 0) {
    return dfs(S, i + 1, K);
  } else {
    res += (d - 1) * pow(9, K -1) * ncK(r - 1, K - 1);
    res += ncK(r - 1, K) * pow(9, K);
    
    res += dfs(S, i + 1, K - 1);
  }
  return res;
}

int main() {
  string S;
  int K;
  cin >> S >> K;
  int N = S.size();
  int res = 0;
  cout << dfs(S, 0, K) << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, a, b, INF=1e18;
signed main()
{
	cin >> n >> a >> b;
	if(a>b) swap(a, b);
	int mn = INF;
	if(a%2LL==b%2LL)
	{
		mn=min(mn, (b-a)/2LL);
	}
	else
	{
		int d = (b-a-1)/2;
		d+=a;
		mn=min(mn, d);
		int c = (b-a-1)/2;
		c+=(n-b+1);
		mn=min(mn, c);
	}
	cout << mn;
}

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



bool check(){
	
}

int main(){
	int n,m;
	cin >> n >> m;
	vector<vector<int>> ls(m,std::vector<int>(n,0));
	
	vector<int> swt(m);
	
	for(int i=0;i<m;++i){
		int ch;
		cin >> ch;
		for(int j=0;j<ch;++j){
			cin >> ls[i][j];
		}
	}
	
	for(int i=0;i<m;++i){
		cin >> swt[i];
	}
	
	int sum = 0;
	int en = 1 << n;
	for(int i=0;i<en;++i){
		int j;
		for(j=0;j<m;++j){
			int val = 0;
			for(auto &k : ls[j]){
				val |= (1 << ( k-1 ));
			}
			val = i & val;
			
			int s = 0;
			for(int k=0;k<n;++k){
				s ^= (val >> k) & 1;
			}
			if(swt[j] != s){break;}
		}
		if(j >= m){
			++sum;
		}
		
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



int main() {


	char S[1000],T[300],R[466];
	scanf("%s%s%s" ,&T,&S,&R);



	printf("A%cC", S[0]);





}

Measured memory_bytes: 128
// 5/2

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
    ll X;
    cin >> X;

    for (ll A = 1; A < 120; A++) {
        for (ll B = 0; B < A; B++) {
            ll A5 = (ll)pow((double)A, 5.0);
            ll B5 = (ll)pow((double)B, 5.0);

            if (A5 - B5 == X) {
                cout << A << " " << B << endl;
                return 0;
            }
            else if (A5 + B5 == X) {
                cout << A << " " << - B << endl;
                return 0;
            }
        
            
        }
    }

}


Measured memory_bytes: 4104
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	if(y==0) return x;
	return gcd(y,x%y);	
}

ll lcm(ll x, ll y) {
	ll z=gcd(x,y);
	return x/z*y;
}

int main()
{
	string s;
	ll r=0,b=0;
	cin >> s;
	rep(i,s.size()){
		if(s[i]=='0') r++;
		else b++;
	}
	cout << 2*min(r,b) << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int maxn = 110;

int b[maxn], n;
int ans[maxn], cur;

int main() {
	scanf("%d", &n);
	cur = n;
	int tmp = n;
	for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
	while (n) {
		int ok = 0;
		for (int i = n; i >= 1; i--) {
			if (b[i] == i) {
				ok = i;
				break;
			}
		}
		ans[cur--] = b[ok];
		for (int i = ok; i < n; i++) b[i] = b[i+1];
		-- n;
		if (!ok) {
			puts("-1");
			return 0;
		}
	}
	for (int i = 1; i <= tmp; i++) printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 256
/*
	0565:Lunch
*/
#include	<iostream>
#include	<algorithm>

using namespace std;

int main(void) {
	int p1, p2, p3, j1, j2;
	int price;
	
	cin >> p1 >> p2 >> p3 >> j1 >> j2;
	
	price = min(p1, min(p2, p3) ) + min(j1 , j2) - 50;
	
	cout << price << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
// typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

typedef ll ull;

int main(){
    int n;cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    ll sum = accumulate(ALL(a),0LL);
    ll md;
    if(sum%2==1){
        md = (sum+1)/2;
    }else{
        md = sum/2;
    }

    ll min = INF;
    ll bsum = 0;
    for(int i=0;i<n;i++){
        bsum+=a[i];
        ll right = sum - bsum;
        ll calc = abs(bsum-md) + abs(right-md);
        if(calc<min)min = calc;
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 1792
from sys import stdin
input = stdin.buffer.readline

n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]

h.sort()

ans = 10 ** 9
for i in range(n-k+1):
    diff = h[i+k-1] - h[i]
    if diff < ans:
        ans = diff

print(ans)

Measured memory_bytes: 13316
#include <cstdio>
#define ll long long

const int MAXN = 1e5 * 2 + 5;

ll a[MAXN];

int main () {
	int n;
	ll ans = 0;
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf ("%lld", &a[i]);
	}
	for (int i = 1; i <= n; i++) {
		if (a[i] < a[i - 1]) {
			ans += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	} 
	printf ("%lld", ans);
	return 0;
}

Measured memory_bytes: 4656
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int ,int> pi;
typedef pair<ll ,ll> pl;
typedef map<ll ,ll> ml;
#define modulo 1000000007
#define maxN 100001
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int arr[maxN];
void solve()
{
    ll n,sum=0;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        ll x;
        cin >> x;
        sum+=x;
        arr[x]++;
    }
    ll q;
    cin >> q;
    for(int i=0;i<q;i++)
    {
        ll x,y;
        cin >> x >> y;
        sum-=x*arr[x];
        sum+=y*arr[x];
        arr[y]+=arr[x];
        arr[x]=0;
        cout << sum << endl;
    }

}

int main()
{
    
    fast;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
  return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << (k % 2 == 0 ? a - b : -(a - b) )<< endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  int x;
  for(int i=0; i<5; i++) {
    cin >> x;
    if (x == 0) {
      cout << i+1 << endl;
      return 0;
    }
  }

  return 0;
}

// EOF

Measured memory_bytes: 3592
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);
const int MAX = 510000;

//変数
LL n;
vector<LL> x;
vector<bool> exist;
bool bigThere = false;





//サブ関数
//入力
void input()
{
	cin >> n;
	exist.resize(MAX);
}

//枝刈
int failNo() {
	static int id = 0;
	while (exist[id + 1])id++;
	return id;
}

bool isSafeFail(int now) {
	if (bigThere)return false;


	FOR(i, now + 1, MAX) {
		if (exist[i])
			return false;
	}
	return true;
}

void insert(vector<bool>& exist, LL now) {
	if (exist[now]) {
		exist[now] = false;
		insert(exist, now - 1);
	}
	else {
		exist[now] = true;
	}
}

//計算
void calc()
{
	REP(i,n){
		LL now;
		cin >> now;
		if (n < now)bigThere = true;

		if (exist[0] || (now <= failNo() && !isSafeFail(now))) {
			if (n < now)bigThere = true;
			cout << "No" << endl;
		}
		else {
			if (now <= n) {
				insert(exist, now);
			}
			cout << "Yes" << endl;
		}
	}
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	//output();
	//debug();
	
	return 0;
}



Measured memory_bytes: 3176
#include <stdio.h>
#include <string.h>
 
#define M 1046527
#define L 14
 
char H[M][L];
 
int char2int(char c) {
  switch (c) {
    case 'A': return 1;
    case 'C': return 2;
    case 'G': return 3;
    case 'T': return 4;
    default: return 0;
  }
}
 
long long getKey(char str[]) {
  long long ret = 0, p = 1;
  int i;
  for(i = 0; str[i] != '\0'; i++) {
    ret += p * char2int(str[i]);
    p *= 5;
  }
  return ret;
}
 
int h1(int key) {
  return key % M;
}
 
int h2(int key) {
  return 1 + (key % (M - 1));
}
 
int find(char str[]) {
  long long key, h, i;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      return 0;
    }
  }
  return 0;
}
 
int insert(char str[]) {
  long long key, h, i;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}
 
int main(void) {
  int i, n;
  char str[L], cmd[9];
  for(i = 0; i < M; i++) {
    /* initialize hash */
    H[i][0] = '\0';
  }
 
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%s %s", cmd, str);
 
    if(cmd[0] == 'i') {
      insert(str);
    } else {
      if(find(str)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

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

  ll sum = n*(n-1)/2 + l*n;

  ll ms = inf;
  for (int i=0; i<n; i++) {
    if (abs(ms) > abs(i+l)) ms = i+l;
  }
  cout << sum - ms << "\n";

  return 0;
}


Measured memory_bytes: 3652
"use strict";

const main = arg => {
  let a = parseInt(arg.split(" ")[0]);
  let b = parseInt(arg.split(" ")[1]);
  let c = parseInt(arg.split(" ")[2]);

  let ans = 0;
  
  if(b >= c) {
    ans += c + b;
    c = 0;
  } else {
    ans += b*2;
    c -= b, b = 0;
  }
  
  if(c>0) {
    let tmp = Math.min(c,a);
    c -= tmp;
    ans += tmp;
  }

  if(c > 0) ans++;
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

using namespace std;

typedef long long ll;

ll bun[52], patty[52];
ll ret;
vector <ll> layers;

void f(int level, ll x){
	if(level == 0){
		//if(x) ret++;
		return;
	}
	if(x == layers[level]){
		ret += patty[level];
		x = 0;
		return;
	}
	if(x == 0) return;
	x--;
	if(x == 0) return;
	if(x < layers[level - 1]){
		f(level - 1, x);
		return;
	}
	ret += patty[level - 1];
	x -= layers[level - 1];
	if(x == 0) return;
	x--;
	ret++;
	if(x == 0) return;
	if(x == layers[level]){
		ret += patty[level];
		x = 0;
		return;
	}
	if(x < layers[level - 1]){
		f(level - 1, x);
		return;
	}
	ret += patty[level - 1];
	x -= layers[level - 1];
	if(x == 0) return;
	x--;
	ret++;
	return;
}

int main(){

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

    int n;
    ll x;
    cin >> n >> x;
    patty[0] = 1;
    bun[0] = 0;
    layers.push_back(1);
    for(int i = 1; i <= n; i++){
    	patty[i] = 1 + 2 * patty[i - 1];
    	bun[i] = 2 + 2 * bun[i - 1];
    	layers.push_back(patty[i] + bun[i]);
    }
    f(n, x);
    cout << ret;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();

        if(a > b){
            System.out.println("a > b");
        }else if(a < b){
            System.out.println("a < b");
        }else{
            System.out.println("a == b");
        }
    }
}

Measured memory_bytes: 26192
#include<iostream>

using namespace std;
#define MAX_INT 1000

int A[MAX_INT];

int selectionSort(int* A, int N)
{
    int count=0;
    for(int i=0;i<N;++i)
    {
        int minj =i;
        for(int j=i;j<N;++j)
        {
            if(A[j]<A[minj])
            {
                minj = j;
            }
        }
        if(minj !=i)
        {
            int tmp;
            tmp = A[i];
            A[i] =A[minj];
            A[minj]=tmp;
            count ++;
        }
    }
    for(int k=0;k<N;k++)
    {
        if(k<N-1) cout << A[k] << " ";
        if(k==N-1) cout<< A[k]<<endl;
    }
    return count;
}

int main()
{
    int N;cin >>N;
    for(int i=0;i<N;++i)
    {
        cin >> A[i];
    }

    cout << selectionSort(A,N)<<endl;
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef struct edge{
  int from, to; long cost;
  edge(int f, int t, long c){
    from = f; to = t; cost = c;
  }
}edge;

int main(){
  int n, m; cin >> n >> m;
  vector<edge> e;
  rep(i, m){
    int a, b; long c; cin >> a >> b >> c;
    e.push_back(edge(a-1, b-1, c));
  }
  long d[n];
  rep(i, n) d[i] = -LONG_MAX;
  d[0] = 0;
  rep(i, 2*n)rep(j, m){
    if(d[e[j].from] == -LONG_MAX) continue;
    if(d[e[j].to] < d[e[j].from] + e[j].cost){
      d[e[j].to] = d[e[j].from] + e[j].cost;
      if(i >= n-1 && e[j].to == n-1){
        cout << "inf" << endl;
        return 0;
      }
    }
  }
  cout << d[n-1] << endl;
}

Measured memory_bytes: 256
S=input()
l=len(S)
A=[0]*(l+1)
B=[0]*(l+1)
for i in range(l):
  if S[i]=='<':
    A[i+1]=A[i]+1
  if S[l-i-1]=='>':
    B[l-i-1]=B[l-i]+1
print(sum([max(a,b) for a,b in zip(A,B)]))

Measured memory_bytes: 31808
A, B, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a)+min(b)
for i in range(m):
  x, y, c = map(int, input().split())
  ans = min(ans, a[x-1]+b[y-1]-c)
print(ans)

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

const int p = 998244353;
const int maxn = 1e5 + 10;

#define int long long

int ans = 1, n;
int a[maxn];

int qpow(int x, int y) {
  int res = 1;
  for (; y; y >>= 1, x = x * x % p) if (y & 1)
    res = res * x % p;
  return res;
}

signed main() {
  scanf("%lld", &n);
  for (int i = 1, x; i <= n; ++ i) {
    scanf("%lld", &x), a[x] ++;
    if (i == 1 && x != 0) return printf("0"), 0;
  }
  if (a[0] != 1) return printf("0"), 0;
  bool isEnd = false;
  for (int i = 1; i <= n; ++ i)
    if (isEnd == false && a[i] == 0) isEnd = true;
    else if (isEnd && a[i]) return printf("0"), 0;
  for (int i = 1; i <= n && a[i] <= n; ++ i) {
    if (a[i] == 0) break;
    ans = qpow(a[i - 1], a[i]) * ans % p;
  }
  printf("%lld", ans);
}

Measured memory_bytes: 896
#include<stdio.h>
int main(void){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b){
		if(b<c){
			printf("Yes\n");
		}else{
			printf("\No\n");
		}
	}else{
		printf("No\n");
	}
	return 0;;
	
}


Measured memory_bytes: 2116
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

bool st[200010];
signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int n;
    cin >> n;
    int numr = 0;
    rep(i, n)
    {
        char c;
        cin >> c;
        if (c == 'R')
        {
            st[i] = true;
            numr++;
        }
    }
    int numhr = 0;
    rep(i, numr)
    {
        if (st[i])
        {
            numhr++;
        }
    }
    cout << abs(numhr - numr) << endl;

    return 0;
}

Measured memory_bytes: 3748
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long C(int a,int b){
	if(a<b||b<0)return 0;
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
long long p[20];
struct wolf{
	int L,R;
	int lk;
	int rk;
	int ks[16];
	wolf(){
		L=R=0;
		for(int i=0;i<16;i++)ks[i]=-1;
	}
};
inline bool operator<(const wolf &a,const wolf&b){
	for(int i=0;i<16;i++){
		if(a.ks[i]!=b.ks[i])return a.ks[i]<b.ks[i];
	}
	if(a.lk!=b.lk)return a.lk<b.lk;
	if(a.rk!=b.rk)return a.rk<b.rk;
	return false;
}
map<wolf,long long>dp;
long long calc(wolf a){
	if(a.L>a.R)return 0LL;
	if(dp.count(a))return dp[a];
	
	long long ret=inf;
	for(int i=a.L;i<=a.R;i++){
		long long ad=a.ks[i]*p[i];
		wolf to1,to2;
		to1.L=a.L;
		to1.R=i-1;
		for(int j=to1.L;j<=to1.R;j++)to1.ks[j]=a.ks[j]+a.lk;
		to1.lk=a.lk;
		to1.rk=a.lk+a.rk;
		to2.L=i+1;
		to2.R=a.R;
		for(int j=to2.L;j<=to2.R;j++)to2.ks[j]=a.ks[j]+a.rk;
		to2.lk=a.lk+a.rk;
		to2.rk=a.rk;
		
		ret=min(ret,ad+calc(to1)+calc(to2));
	}
	//printf("%d %d: ",a.L,a.R);
	//for(int i=a.L;i<=a.R;i++){
//		printf("%d ",a.ks[i]);
//	}printf(": %lld\n",ret);
	return dp[a]=ret;
}
int main(){
	int a;scanf("%d",&a);
	a-=2;
	long long X;scanf("%lld",&X);

	for(int i=0;i<a;i++){
		scanf("%lld",p+i);
	}
	long long Y;
	scanf("%lld",&Y);
	wolf st;
	for(int i=0;i<a;i++)st.ks[i]=2;
	st.L=0;
	st.R=a-1;
	st.lk=st.rk=1;
	long long ret=calc(st);

	printf("%lld\n",ret+X+Y);
}

Measured memory_bytes: 33408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;

int main(){
    int N, K;
    cin >> N >> K;
    vector<i64> V(N);
    rep(i, N) cin >> V[i];

    i64 ans = 0;
    for(int left = 0; left <= min(K, N); left++){
        for(int right = 0; right+left <= min(K, N); right++){
            priority_queue<i64> que;
            i64 MAX = 0; 
            for(int i = 0; i < left; i++){
                MAX += V[i];
                que.push(-V[i]);
            }
            for(int i = N-1; i >= N-right; i--){
                MAX += V[i];
                que.push(-V[i]);
            }

            int k = K - (left + right);

            while(k && !que.empty()){
                if(que.top() < 0) break;
                MAX += que.top(); que.pop();
                k--;
            }

            ans = max(ans, MAX);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int k = fs.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++)
            a[i] = fs.nextInt();
        
        Arrays.sort(a);
        long sum = 0;
        for(int i=0; i<k; i++)
            sum += a[i];
        System.out.print(sum);
    }

    static class FastScanner {
        BufferedReader br = null;
        StringTokenizer st;
    
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
    
        String next() {
            while(st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    
        double nextDouble() {
            return Double.parseDouble(next());
        }
    
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 33024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)

int main()
{
  ll a, b, n;
  cin >> a >> b >> n;
  ll tmp = 0;
  ll ans = 0;
  if (b > n)
  {
    ans = int(a*n/b) - (5*int(n/b));
    cout << ans << endl;
  }
  else
  {
    ans = int(a*(b-1)/b) - (5*int((b-1)/b));
    cout << ans << endl;
  }
}
    

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

int main(){
    vector<int> num(3);
    rep(i,3)cin>>num[i];
    int big = 20021003;
    for(int i = 0; i < 3; i++){
        for(int j = i; j < 3; j++){
            if(i==j)continue;
            int a = num[i]+num[j];
            big = min(big, a);
        }
    }
    cout<<big<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

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

#define PI 3.1415926535897932384626433832795

int main(void)
{
	int a, b;
	while(scanf("%d%d", &a, &b)==2)
	{
		if(a>b) swap(a, b);

		for(int i=0;i<b;i++)
		{
			printf("%d", a);
		}
		printf("\n");
	}
	return 0;
}


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

int main() {
	int A, B;
	cin >> A >> B;
	int max = A+B;
	int other1 = A-B;
	int other2 = A*B;

	if(max < other1){
		max = other1;
	}

	if(max < other2){
		max = other2;
	}

	cout << max << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll mod_pow(ll x, ll n, ll mod) {
	ll bit = 1;
	while (n) {
		if (n & 1)bit = bit * x % mod;
		x = x * x % mod;
		n /= 2;
	}
	return bit;
}
signed main() {
	ll a, b;
	cin >> a >> b;
	if (a <= 9 && b <= 9)cout << a * b << endl;
	else cout << -1 << endl;
	ggr
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const ll mod=998244353;
ll a[1000005];
int main()
{
	ll n,k,cou=0;
	scl(n);scl(k);
	rep(i,1,k){
		scl(a[i]);cou+=a[i];
	}if(cou>n)pf("-1\n");
	else	pf("%lld\n",n-cou);
}


Measured memory_bytes: 3792