akhauriyash/Code-Regression huggingface dataset:
// C++ program to find count of divisors in n!
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;

// allPrimes[] stores all prime numbers less
// than or equal to n.
vector<ull> allPrimes;

// Fills above vector allPrimes[] for a given
ull MOD = 1e9 + 7 ;
void sieve(int n)
{
    // Create a boolean array "prime[0..n]" and
    // initialize all entries it as true. A value
    // in prime[i] will finally be false if i is
    // not a prime, else true.
    vector<bool> prime(n+1, true);

    // Loop to update prime[]
    for (int p=2; p*p<=n; p++)
    {
        // If prime[p] is not changed, then it
        // is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p
            for (int i=p*2; i<=n; i += p)
                prime[i] = false;
        }
    }

    // Store primes in the vector allPrimes
    for (int p=2; p<=n; p++)
        if (prime[p])
            allPrimes.push_back(p);
}

// Function to find all result of factorial number
ull factorialDivisors(ull n)
{
    sieve(n);  // create sieve

    // Initialize result
    ull result = 1;

    // find exponents of all primes which divides n
    // and less than n
    for (int i=0; i < allPrimes.size(); i++)
    {
        // Current divisor
        ull p = allPrimes[i];

        // Find the highest power (stored in exp)'
        // of allPrimes[i] that divides n using
        // Legendre's formula.
        ull exp = 0;
        while (p <= n)
        {
            exp = exp + (n/p);
            p = p*allPrimes[i];
        }

        // Multiply exponents of all primes less
        // than n
        result = (result*(exp+1)) % MOD ;
    }

    // return total divisors
    return result % MOD;
}

// Driver program to run the cases
int main()
{
int n ;
cin>>n;
    cout << factorialDivisors(n)<< endl;
    return 0;
}

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

int main() {
    int x[100], y[100], a[3][3];
    x[0] = 0;

    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }

    for(int i = 0; i < 3; i++) {
        y[i] = a[0][i] - x[0];
    }

    for(int i = 0; i < 3; i++) {
        x[i] = a[i][0] - y[0];
    }
    
    bool good = true;
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            if(x[i] + y[j] != a[i][j]) {
                good = false;
            }
        }
    }
    if(good) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3608
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    usize n, l;
    std::cin >> n >> l;
    vec<std::string> a(n);
    for (std::string& s: a) std::cin >> s;
    std::sort(ALL(a));
    for (std::string& s: a) std::cout << s;
    std::cout << '\n';
}


Measured memory_bytes: 256
program sample
    implicit none
  
    integer(8) :: i,j,m,n,x(0:100000),b
    integer(8),allocatable :: a(:),y(:)
  
    read(*,*) n
    allocate(a(n))
    read(*,*)a
    x(:)=0
    do i=1,n
        b=a(i)
        x(b)=x(b)+1
    end do
    m=0
    do i=0,100000-2
        if (x(i)+x(i+1)+x(i+2)>m)then
            m=x(i)+x(i+1)+x(i+2)
        endif
    end do


    write(*,*) m
  
    stop
end program sample
  



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

using namespace std;

int N, D, prf[500009], suf[500009], x[500009];
bool ok[500009];

void print ()
{
    int Queries;
    scanf ("%d", &Queries);
    while (Queries --)
    {
        int x;
        scanf ("%d", &x);
        if (!ok[x]) printf ("YES\n");
        else printf ("NO\n");
    }
}

int modul (int x)
{
    if (x < 0) return -x;
    return x;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &D);
for (int i=1; i<=N; i++)
    scanf ("%d", &x[i]);

prf[0] = D;
for (int i=1; i<=N; i++)
    prf[i] = min (prf[i - 1], modul (prf[i - 1] - x[i]));

suf[N + 1] = 0;
for (int i=N; i>=1; i--)
{
    int D2 = suf[i + 1], currX = x[i];
    if (D2 < currX / 2) suf[i] = D2;
    else suf[i] = D2 + currX;
    if (suf[i] > D) suf[i] = D;
}

for (int i=1; i<=N; i++)
    ok[i] = (prf[i - 1] <= suf[i + 1]);
print ();

return 0;
}


Measured memory_bytes: 8320
n = gets.to_i
t, a = gets.strip.split.map(&:to_i)
ary = gets.strip.split.map(&:to_i)
ave_temp = []
ary.each do |i|
  ave_temp << t-i*0.006.to_f
end
num = ave_temp.min_by{|x| (x-a).abs}
puts ave_temp.index(num)+1

Measured memory_bytes: 1788
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int max = 0;
		Map<Integer,Integer> map = new HashMap<Integer,Integer>();
		int a[] = new int[N-1];
		int count =0;
		int before =0;
		Main main = new Main();
		Node[] node = new Node[N-1];
		for (int i=0;i<N-1;i++) {
			Node temp = main.new Node();
			temp.start  = sc.nextInt();
			temp.end = sc.nextInt();
			temp.num = i;
			node[i] = temp;
		}
		Arrays.sort(node);
		for (int i=0;i<N-1;i++) {
			if (node[i].start != before) {
				count = 1;
				before = node[i].start;
			} else {
				count++;
			}
			if (map.get(node[i].start)!=null&&map.get(node[i].start)==count) {
				count++;
			}
			map.put(node[i].end, count);
			if (count>max ) {
				max = count;
			}
			a[node[i].num]= count;
		}
		System.out.println(max);
		for (int i=0;i<a.length;i++) {
			System.out.println(a[i]);
		}
	}

	public class Node implements Comparable<Node>{
		int start;
		int end;
		int num;
		@Override
		public int compareTo(Node o) {
			if (this.start!=o.start) {
				return this.start-o.start;
			}
			return this.end-o.end;
		}

	}
}

Measured memory_bytes: 78540
// Virtual

#include <bits/stdc++.h>
using namespace std;

// Utility
#define ALL(X) (X).begin(), (X).end()
#define RANGE(I, X, Y) for (int I = (X); I < (Y); I++)
using ll = int64_t;
using ull = uint64_t;
namespace std {
template<class ...Ts>        istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >> ys), ...); }, x); return i; }
template<class T1, class T2> istream& operator>>(istream& i, pair<T1, T2>& x) { i >> x.first >> x.second; return i; }
template<class T>            istream& operator>>(istream& i, vector<T>& x)    { for (auto& y : x) { i >> y; } return i; }
}

// Debugging
#define DD(X) std::cout << #X ": " << (X) << std::endl << std::flush
namespace std {
template<class ...Ts>        ostream& operator<<(ostream& o, const tuple<Ts...>& x) { o << "("; apply([&](auto&& y, auto&&... ys){ o << y; ((o << ", " << ys), ...); }, x); o << ")"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const pair<T1, T2>& x) { o << tie(x.first, x.second); return o; }
template<class T>            ostream& operator<<(ostream& o, const vector<T>& x)    { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const set<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
}

// Main
void mainCase() {
  int x;
  cin >> x;
  x %= 10;

  string res;
  if (set<int>({2, 4, 5, 7, 9}).count(x)) {
    res = "hon";
  }
  if (set<int>({0, 1, 6, 8}).count(x)) {
    res = "pon";
  }
  if (set<int>({3}).count(x)) {
    res = "bon";
  }
  cout << res << endl;
}

int main() {
  mainCase();
  return 0;
}

Measured memory_bytes: 3608
//#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <cstdlib>      // srand,rand


using namespace std;
#define modd 1000000007



typedef pair<long long, long long> pl;


typedef string::const_iterator State;
class ParseError {};




#define ll long long




class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


class SegmentTree {
private:
	int n;
	vector <ll> node;

public:
	// 元の配列　v をセグメントツリーで表現する。
	SegmentTree(vector<ll> v) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく。
		//セグ木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1; 
		while (n < sz)n *= 2;

	}

};




long long N, M, K, a, b, c, d, e, H, W, L,T;
ll A[300005] = {};
ll B[100005] = {};
ll C[2][300005] = {};
bool f, ff;
string S,SS;
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <long long>vll;
vector <pl>vpl;
vector <string> vs;
set<ll> llset[50];
multiset<ll> llmset;


struct ST
{
	ll first;
	ll second;
	ll kaisuu;
	

	bool operator<(const ST& another) const
	{
		return first < another.first;//比較
	};

};



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;
double ansa;

ll zettai(ll aa) {

	if (aa < 0) {
		aa *= -1;
	}
	return aa;

}



int main() {
	
	cin >> N;

	a = 0;
	b = N;

	while (b>0)
	{
		a += b % 10;
		b /= 10;

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

	//cout << fixed << setprecision(10) << ansa << endl;
	return 0;



}


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

int main(){
	int n;
	cin >> n;
	string x;
	for(int i = 1; i <= n; i++){
		x = to_string(i);
		if( i%3 == 0){
			cout << " " << i;
			continue;
		}
		if( x.find("3",0) != string::npos){
			cout << " " << i;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3304
//最大最小ヒープ
#include <iostream>
using namespace std;

int H, A[2000001];

void maxHeapify(int i) {
    int l, r, largest;
    l = i * 2;
    r = i * 2 + 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]);
        maxHeapify(largest);
    }
}

int main() {
    
    cin >> H;

    for (int i = 1; i <= H; i++)
        cin >> A[i];

    for (int i = H / 2; i >= 1; i--)
        maxHeapify(i);
    
    for (int i = 1; i <= H; i++)
        cout << " " << A[i];
    
    cout << endl;
    
    return 0;
}


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

int main(){
	string S;
	cin>>S;
	
	int ans=700;
	for(int i=0;i<3;i++){
		if(S[i]=='o')
			ans+=100;
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,x,L=0;
  cin >> N >> K;
  
  while(N--){
    cin >> x;
  	if(x <= K-x){
    	L += x*2;
    }else{
    	L += (K-x)*2;
    }
  }
 
  cout << L << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
 
public class Main {    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        String[] list = new String[26];
        char temp = 'a';
        for(int i=0;i<26;i++){
            list[i] = String.valueOf(temp++);
        }

        String ans = "";
        while(n>0){
            n--;
            int mod = (int) (n%26);
            ans +=list[mod];
            n/=26;
        }
        
        StringBuffer str =  new StringBuffer(ans);
        String s = str.reverse().toString();
        System.out.println(s);
    }
}

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

ll fact(ll n)
{
    if (n==1) {return 1;}
    return n*fact(n-1);
}

int main() {
    ll n,i,p,q,l; vector<ll>a,b,c; cin>>n;
    for(i=0;i<n;i++) {cin>>l; a.pb(l);c.pb(i+1);}
    for(i=0;i<n;i++) {cin>>l; b.pb(l);}
    l=fact(n);
    for(i=0;i<l;i++)
    {
        if (a==c) {p=i;}
        if (b==c) {q=i;}
        next_permutation(c.begin(),c.end());
    }
    cout<<abs(p-q);
	return 0;
}

Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <functional>
#include <map>

#define M 200000 + 5

int a[M], ans;
bool flag[M];
int n, k;

using namespace std;

int main()
{
	set <int> s;

	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];

	int tot = 1;
	int num = 0;
	for (int i = 1; i < n; i++)
	{
		if (a[i] < a[i + 1])
			tot++;
		else
			tot = 1;
		if (tot >= k)
		{
			num++;
			flag[i + 1] = true;
			ans = 1;
		}
	}

	for (int i = 1; i < k; i++)
		s.insert(a[i]);

	int index = 1;
	int front = (int)1e9;

	for (int i = k; i <= n; i++)
	{
		int minl = *s.begin(), maxl = *s.rbegin();

		if ((flag[i] == true) || (front < minl && a[i] > maxl))
			;
		else
			ans++;

		front = a[index];
		s.erase(s.find(a[index]));
		s.insert(a[i]);

		index++;
	}

	cout << ans << endl;

	return 0;
}

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

int main()
{
	int h,n;
	cin>>h>>n;
	int a[n+1],sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>=h)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 640
n = int(input())
A = list(map(int, input().split()))

minus_odd = len(list(filter(lambda x: x < 0, A))) % 2 != 0

a = list(map(lambda x: abs(x), A))
if minus_odd:
  mini = min(a)
  print(sum(a) - mini * 2)
else:
  print(sum(a))

Measured memory_bytes: 14224
#include "stdio.h"
#include "stdlib.h"

int a[100];
int N;
int count;

void printResult(){
    for(int i=0; i<N; i++){
        if(i != N-1){
            printf("%d ", a[i]);
        }
        else{
            printf("%d\n", a[i]);
        }
    }
}

int main(){
    //freopen("D:\\zhouyu\\study\\codes\\SortSample.txt", "r", stdin);
    scanf("%d", &N);
    for(int i=0; i<N; i++){
        scanf("%d", &a[i]);
    }
    count = 0;
    int minIndex;
    for(int i=0; i<N; i++){
        minIndex = i;
        for(int j=i+1; j<N; j++){
            if(a[j] < a[minIndex]){
                minIndex = j;
            }
        }
        if(minIndex != i){
            count++;
            a[i] = a[i] ^ a[minIndex];
            a[minIndex] = a[i] ^ a[minIndex];
            a[i] = a[i] ^ a[minIndex];
        }
    }
    printResult();
    printf("%d\n", count);
    return 0;
}




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

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

	cin >> a >> b >> c;
	for(int i=a; i<=b; i++)
	{
		if(c%i == 0)
		{
			ans+=1;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, m, a[11], b[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6}, dp[10010];

signed main() {
	cin >> n >> m;
	rep(i,m) cin >> a[i];
	sort(a,a+m), reverse(a,a+m);
	reps(i,1,10010) dp[i] = -1145141919;
	rep(i,10001) rep(j,m) chmax(dp[i+b[a[j]]], dp[i] + 1);
	int d = dp[n];
	rep(i,d) rep(j,m) {
		int nn = n-b[a[j]];
		if (nn<0 || dp[nn]!=dp[n]-1) continue;
		cout << a[j];
		n = nn;
		break;
	}
	cout << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect
import heapq



N, K = list(map(int, input().split()))
S = input()
    
def main():
    res = N
    past = S[0]
    cnt = K
    cnt2= 0
    if N == 1:
        return print(0)
    flg = False
    for n in range(1, N):
        now = S[n]
        #print(past, now, res)
        if past == "R" and now == "L":
            #print(n, ": BAD")
            res -= 2
            flg = True
        if past == "L" and now == "R" and flg == True:
            if 0 < cnt:
                #print("reverse")
                res += 2
                cnt -= 1
                cnt2 += 1
            flg = False
        past = now
    
    if flg == True and 0 < cnt:
        res += 1
    #print("Reach edge: ", res)
    if S[0] == "L":
        #print(0, ": edge BAD")
        res -= 1
        if 0 < cnt and ("R" in S) :
            #print("reverse")
            res += 1
            cnt -= 1        
    if S[-1] == "R":
        res -= 1
        #print(N-1, ": edge BAD")
        
    return print(res)
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n, m; cin >> n >> m;
        vector<vector<int>> grid(n, vector<int>(m));
        int c; cin >> c;
        vector<int> a(c); cin >> a;
        int row = 0, col = 0, color = 0, dir = 1;
        int t = n * m;
        while (t--) {
                while (!a[color]) color++;
                grid[row][col] = color + 1;
                a[color]--;
                //check right 1
                if (dir == 1 && (col + 1 >= m || grid[row][col + 1])) dir = 2;
                //check down 2
                if (dir == 2 && (row + 1 >= n || grid[row + 1][col])) dir = 3;
                //check left 3
                if (dir == 3 && (col - 1 < 0 || grid[row][col - 1])) dir = 4;
                //check up 4
                if (dir == 4 && (row - 1 < 0 || grid[row - 1][col])) dir = 1;
                if (dir == 1) col++;
                if (dir == 2) row++;
                if (dir == 3) col--;
                if (dir == 4) row--;
        }

        for (int i = 0; i < n; i++) cout << grid[i] << '\n';
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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


int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int n,i,t,s=0,a[100001];
	fill(a,a+100001,0);
	cin>>n;
	for (i=0;i<n;i++){
		cin>>t;
		a[t]++;
	}
	t=0;
	for (i=1;i<100001;i++){
		if (a[i]>0){
			s++;
			t=a[i]%2==0?t+1:t;
		}
	}
	s=(t%2==1)?s-1:s;
	cout<<s;
	return 0;
}

Measured memory_bytes: 640
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val countUp = s.count { it.isUpperCase() }
    if (s[0] == 'A' && countUp == 2 && s.indexOf("C") in 2..(s.length-2)) {
        println("AC")
    } else {
        println("WA")
    }
}

Measured memory_bytes: 31140
s = input()

l = list(s)
l.reverse()
str = "".join(l)

words = [
    "maerd",
    "remaerd",
    "esare",
    "resare"
]

r = "YES"
i = 0
while True:
    if i >= len(str):
        break
    found = False
    for w in words:
        if str[i:i+len(w)] == w:
            found = True
            i += len(w)
            break
    if not found:
        r = "NO"
        break
print(r)


Measured memory_bytes: 50032
import numpy as np
N,K=list(map(int,input().split()))
dp_list=np.full(N,10**10,dtype=int)
h=list(map(int,input().split()))
h=np.array(h)
dp_list[0]=0
for i in range(1,N):
        dp_list[i:i+K] = np.fmin(dp_list[i:i+K], dp_list[i-1] + np.abs(h[i:i+K] - h[i-1]))
print(dp_list[-1])

Measured memory_bytes: 23684
package main

import (
	"fmt"
)

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)

	x := a[0:1]
	a = a[1:]
	for {
		switch x {
		case "a":
			if a == "" {
				fmt.Println("A")
				return
			}
			x = a[0:1]
			a = a[1:]
		case "b":
			if b == "" {
				fmt.Println("B")
				return
			}
			x = b[0:1]
			b = b[1:]
		case "c":
			if c == "" {
				fmt.Println("C")
				return
			}
			x = c[0:1]
			c = c[1:]
		}
	}

}


Measured memory_bytes: 512
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    string s;
    in1(s);

    rep(i, s.size())
    {
        if (s[i] == '1') s[i] = '9';
        else if (s[i] == '9') s[i] = '1';
    }

    outl(s);

    return 0;
}


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

void swap(int &, int &);

int main()
{
    int a[3], i, j;
    cin >> a[0] >> a[1] >> a[2];

    for(i = 0; i < 3; i++) {
        for(j = 0; j < 2; j++) {
            if(a[j] > a[j+1]) {
                swap(a[j], a[j+1]);
            }
        }
    }

    cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;

    return 0;
}

void swap(int &x, int &y)
{
    int z;

    z = y;
    y = x;
    x = z;

    return;

}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long ll;

using namespace std;

int main() {

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

    int N;
    cin>>N;
    int a[10]={0};
    REP(i,N){
        cin>>a[i];
    }
    sort(a,a+N,greater<int>());
    int ans=0;
    REP(i,N){
        if(i==0)ans+=a[i]/2;
        else ans+=a[i];
    }
    cout<<ans<<endl;
}

/*
g++ code.cpp
./a.out
*/

Measured memory_bytes: 3612
#include<stdio.h>

#define N 200000
int main(){

  int max;
  int min;
  int R[N];
  int i, j;
  int n;

  scanf("%d",&n);

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

  

  for(j=1;j<=n-1;j++){
    for(i=0;i<=j-1;i++){
      if(max<R[j]-R[i]){
	max=R[j]-R[i];
      }
    }
  }

  min=R[0];
  max=R[1]-R[0];
  for(j=1;j<=n-1;j++){
    if(max<R[j]-min){
      max=R[j]-min;
    }
    if(min>R[j]){
      min=R[j];
    }
  }

  printf("%d\n",max);






  return 0;
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#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 show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int q;
    cin >> q;
    vector<P> lr(q);
    rep(i, q){ cin >> lr[i].first >> lr[i].second;}

    bool sosu[100001] = {0};
    bool sim2017[100001] = {0};


    rep1(i, 100000){
        bool issosu = true;
        for(int j=2; j*j <= i; j++){
            if ((i%j)==0){
                issosu = false;
                break;
            }
        }
        if (i==1 || !issosu) continue;
        sosu[i] = true;
        if (sosu[i] && sosu[(i+1)/2]){
            sim2017[i] = true;
        }
    }

    // rep1(i, 100){
    //     cout << i << sosu[i] << ":" << sim2017[i] << endl;
    // }

    int sum = 0;
    int sim2017_sum[100002] = {0};
    rep1(i, 100000){
        sim2017_sum[i+1] = sim2017[i] + sim2017_sum[i];
    }


    // rep1(i, 100){
    //     cout << sim2017_sum[i] << endl;
    // }

    rep(i, q){
        cout << sim2017_sum[lr[i].second+1] - sim2017_sum[lr[i].first] << endl;
    }

}



Measured memory_bytes: 2048
N, M = map(int, input().split())
AB = []
cons = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    cons[a - 1].append(b - 1)
    cons[b - 1].append(a - 1)
visited = [False for _ in range(N)]
visited[0] = True
Q = [0]
sirusi = [0 for _ in range(N)]
while Q:
    v = Q.pop(0)
    for i in cons[v]:
        if visited[i]: continue
        visited[i] = True
        sirusi[i] = v
        Q.append(i)
print("Yes")
for i in range(1, N):
    print(sirusi[i] + 1)

Measured memory_bytes: 34676
K = int(input())
if (K % 5 == 0) | (K % 2 == 0):
  print(-1)

else:
  a = 7
  for i in range(K):
    if a % K == 0:
      print(i + 1)
      exit()
    a = (10 * a + 7) % K
  print(-1)

Measured memory_bytes: 9112
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main()
{
    uint N, M;
    cin >> N >> M;
    vector<int> H(N+1, 0);
    vector<vector<int>> G(N+1);
    for (size_t i=1; i<H.size(); i++)
        cin >> H[i];

    for (size_t r=0; r<M; r++) {
        uint i;
        uint j;
        cin >> i >> j;
        G[i].push_back(j);
        G[j].push_back(i);
    }
    int good = 0;
    for (size_t i=1; i<G.size(); i++) {
        if (G[i].size() == 0) {
            ++good;
            continue;
        }
        else {
            bool judge = true;
            for (size_t j=0; j<G[i].size(); j++) {
                if (H[i] <= H[G[i][j]]) {
                    judge = false;
                    break;
                }
            }
            if (judge) ++good;
        }
    }
    cout << good << endl;
}


Measured memory_bytes: 8804
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

from collections import Counter

N,M = II()
A = []
for _ in range(N):
    A.append(III())

used = [False]*(M+1)
place = [0]*N
elements = [0]*N
for i in range(N):
    elements[i] = A[i][0]

ans = float('inf')
for i in range(M):
    c = Counter(elements)
    val = c.most_common(1)[0][0]
    num = c.most_common(1)[0][1]
    if num<ans:
        ans = num
    used[val] = True
    index_list = []
    for j,e in enumerate(elements):
        if e==val:
            index_list.append(j)
    for index in index_list:
        for p in range(place[index],M):
            if used[A[index][p]]:
                continue
            else:
                elements[index] = A[index][p]
                place[index] = p+1
                break

print(ans)

Measured memory_bytes: 47324
import bisect

A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]
"""
def bsr(a, v, lo=0, hi=None):
	if None == hi:
		hi = len(a) - 1
	while lo <= hi:
		mi = (lo + hi) // 2
		if a[mi] <= v:
			lo = mi + 1
		else:
			hi = mi - 1
	return lo
"""
bsr = bisect.bisect_right

INF = 10 ** 18
s = [-INF] + S + [INF]
t = [-INF] + T + [INF]

for x in X:
	sp = bsr(s, x)
	tp = bsr(t, x)
	cost = []
	cost += [abs(s[sp - 0] - x) + abs(s[sp - 0] - t[tp - 0])]
	cost += [abs(s[sp - 1] - x) + abs(s[sp - 1] - t[tp - 0])]
	cost += [abs(s[sp - 0] - x) + abs(s[sp - 0] - t[tp - 1])]
	cost += [abs(s[sp - 1] - x) + abs(s[sp - 1] - t[tp - 1])]
	cost += [abs(t[tp - 0] - x) + abs(s[sp - 0] - t[tp - 0])]
	cost += [abs(t[tp - 1] - x) + abs(s[sp - 0] - t[tp - 1])]
	cost += [abs(t[tp - 0] - x) + abs(s[sp - 1] - t[tp - 0])]
	cost += [abs(t[tp - 1] - x) + abs(s[sp - 1] - t[tp - 1])]
	print(min(cost))


Measured memory_bytes: 18336
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<int> a(n);
int m = INT_MIN;
  for(int i=0; i<n; i++){
cin>>a[i];
  m = max(m, a[i]);
}
  int c = 0;
  int secondMax = INT_MIN;
  for(int i=0; i<n; i++){
  if(a[i]==m){
  c++;}
    else{
    secondMax = max(secondMax, a[i]);
    }
  } 
  for(int i=0; i<n; i++){
  if(a[i]!=m){
  cout<<m<<endl;}
   else{
  if(c==1){
  cout<<secondMax<<endl;
  }
    else{
    cout<<m<<endl;}
  }
  }
  return 0;
}

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

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using ml = map<ll,ll>;

#define ff first
#define ss second
#define endl '\n'
#define ins insert
#define eb emplace_back
#define sz(c) (ll) c.size()
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define itr(x,c) for(auto &x : c)
#define tc ll t; cin >> t; while (t--)
#define rep(i,a,n) for(ll i = a ; i < n ; ++i)
#define per(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) itr(x,c) cout << x << " "; cout << endl;
#define dm(m) itr(x,m) cout << x.ff << " -> " << x.ss << endl;
#define godspeed cin.tie(0) -> sync_with_stdio(0);

int main() {
    godspeed;
    ll n, m; cin >> n >> m;
    cout << n*m;
}

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

using namespace std;
using ll = long long;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    d = abs(d);
    ll diva = min(x / d, k);
    ll mina = x - d * diva;
    if(diva == k)
        cout << mina << endl;
    else{
        ll minb = abs(mina - d);
        diva++;
        if((k - diva) % 2 == 0){
            cout << minb << endl;
        }else
            cout << mina << endl;
    }
            
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

ll power_modulo_fast(ll a, ll b) {    // zwraca (a^b) % MOD
	ll i;
	ll result = 1;
	ll x = a%MOD;

	for (i=1; i<=b; i<<=1) {
		x %= MOD;
		if ((b&i) != 0) {
			result *= x;
			result %= MOD;
		}
		x *= x;
	}

	return result;
}

ll get(ll a, ll b, ll d) {
    ll r = b%d;
    b -= r;
    r = a%d;
    if (r != 0) a += d-r;
    if (a > b) return 0LL;

    return (b-a)/d + 1;
}

ll n, k;
ll s[MAX_N];

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

    cin >> n >> k;
    ll ans = 0LL;

    for (ll i = k; i >= 1; i--) {
        ll cnt = get(1LL, k, i);
        //cout << "D: " << i << " " << cnt << "\n";
        s[i] = power_modulo_fast(cnt, n);
        //cout << i << ": " << s[i] << "\n";
    }

    for (ll i = k; i >= 1; i--) {
        for (ll j = i+i; j <= k; j += i) {
            s[i] -= s[j];
            if (s[i] < 0) s[i] += MOD;
        }
    }

    for (ll i = 1LL; i <= k; i++) {
        ll tmp = (s[i] * i) % MOD;
        ans += tmp;
        ans %= MOD;
    }


    cout << ans;



    return 0;
}


Measured memory_bytes: 4432
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    n2 = 2**n
    a = LI()
    t = [[0,0] for _ in range(n2)]
    ii = [2**i for i in range(18)]
    M = n2
    for i in range(n2):
        ti = t[i]
        ti[0] = a[i] * M + i
        for j in range(18):
            if not i & ii[j]:
                continue
            for c in t[i^ii[j]]:
                if ti[0] < c:
                    ti[1] = ti[0]
                    ti[0] = c
                elif ti[1] < c and ti[0] != c:
                    ti[1] = c

    r = [0]
    for i in range(1,n2):
        tr = sum(map(lambda x: x//M, t[i]))
        if tr > r[-1]:
            r.append(tr)
        else:
            r.append(r[-1])
    return '\n'.join(map(str, r[1:]))



print(main())


Measured memory_bytes: 85952
#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>;

const ll MAXV = 1e18;

int main()
{
    int n;
    ll ans = 1;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }

    for (int i = 0; i < n; i++)
    {
        if ( __int128(ans) * a[i] > MAXV )
        {
            ans = -1;
            break;
        }
        ans *= a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4036
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

struct Point {
    double x;
    double y;
};

void koch(int depth,Point start,Point end) {
    if (depth == 0) return;
    double th = M_PI * 60.0 / 180.0;

    Point s{.x = (start.x*2.0 + end.x)/3.0, .y = (start.y*2.0 + end.y)/3.0};
    Point u{.x = (end.x*2.0 + start.x)/3.0, .y = (end.y*2.0 + start.y)/3.0};
    Point t{.x = (u.x-s.x)*cos(th) - (u.y - s.y) * sin(th) + s.x, .y = (u.x - s.x) * sin(th) + (u.y - s.y) * cos(th) + s.y};

    koch(depth-1,start,s);
    cout << s.x << " " << s.y << endl;
    koch(depth-1, s,t);
    cout << t.x << " " << t.y << endl;
    koch(depth-1,t,u);
    cout << u.x << " " << u.y << endl;
    koch(depth-1,u,end);
}

void solve() {
    int n;
    cin >> n;
    Point a {.x = 0, .y = 0};
    Point b {.x = 100.0, .y = 0.0};
    cout << fixed << setprecision(12);
    cout << a.x << " " << a.y << endl;
    koch(n,a,b);
    cout << b.x << " " << b.y << endl;
}

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


Measured memory_bytes: 3296
sum = 0
stack  = []
stack2 = []

str_inpt = input()

for i in range(len(str_inpt)):
  if str_inpt[i] == '\\':
    stack.append(i)
  elif str_inpt[i] == '/':
    if len(stack) < 1: continue
    pop_index = stack.pop(-1)
    area = i - pop_index
    sum += area
    while True:
      if len(stack2) < 1: break
      if stack2[-1][0] < pop_index: break
      if pop_index < stack2[-1][0]:
        pop_stack2 = stack2.pop(-1)
        area += pop_stack2[-1]

    stack2.append([pop_index, area])

print(sum)

if len(stack2) == 0:
  print('0')
else:
  print(str(len(stack2)) + ' ' + ' '.join([str(e[1]) for e in stack2]))


Measured memory_bytes: 6188
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 10000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int graph[n][n] = { };
	REP(i, m){
		int a, b;
		cin >> a >> b;
		graph[a-1][b-1] = 1;
		graph[b-1][a-1] = 1;
	}
	int ans = 0;
	REP(i, n){
		FOR(j, i, n){
			if(graph[i][j] == 1){
				queue<int> q;
				q.push(i);
				int check[n][n] = { };
				check[i][j] = 1;
				int bridge = 1;
				while(q.size()){
					int x = q.front();
					q.pop();
					REP(k, n){
						if(graph[x][k] == 1 && check[x][k] == 0){
							if(j == k) bridge = 0;
							else q.push(k);
							check[x][k] = 1;
						}
					}
				}
				if(bridge == 1) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
ll n, M = 1e9 + 7, ans = 1, s[30];
string a;
int main()
{
	ll i;
	cin >> n;
	cin >> a;
	for (i = 0; i < n; i++) {
		s[a[i] - 'a']++;
	}
	for (i = 0; i < 26; i++) {
		ans = (ans * (s[i] + 1)) % M;
	}
	cout << (ans - 1 + M) % M;
    return 0;
}


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

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<pair<int,int> > ms;
	for(int i=0;i<m;i++){
		int x,y; scanf("%d%d",&x,&y);
		ms.push_back(make_pair(y,x));
	}
	vector<int> br;
	sort(ms.begin(),ms.end());
	br.push_back(ms[0].first-1);
	for(int i=1;i<m;i++){
		int lower=(lower_bound(br.begin(),br.end(),ms[i].second))-br.begin();
		if(lower<(int)br.size() && br[lower]<ms[i].first) continue;
		br.push_back(ms[i].first-1);
	}
	printf("%d\n",(int)br.size());
	return 0;
}

Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;
class MainClass
{
	static void Main(string[] args)
	{
		Answer();
	}
	public static void Answer()
	{
      var s = ReadLine();
      WriteLine($"{s[0]}{s.Length - 2}{s[s.Length-1]}");
	}
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

int main(){
    int x = 0;
    int max = 0;
    int n;
    string s;
    cin >> n >> s;
    for(int i = 0; i < n; i++)
    {
        x += s[i] == 'I' ? 1 : -1;
        max = x > max ? x : max;
    }
    cout << max << "\n";
}

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

#define ll long long
#define all x.begin(),x.end()
#define MAX 200005

ll pen[MAX];
ll ac[MAX];

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

	ll n, m, p;
	cin >> n >> m;

	string dum;

	ll correct=0;
	for(int i=0;i<m;i++)
	{
		cin >> p >> dum;

		if(ac[p]) continue;

		if(dum=="AC") ac[p]++;
		else
		{
			pen[p]++;
		}
	}

	ll sum=0;
	for(int i=0;i<=n;i++)
	{
		if(ac[i]) correct++, sum+=pen[i];
	}

	cout << correct <<  " " <<  sum << endl;


	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

vector<mint> fac(2000003, 1);

void calc(int n){
  rep(i, n){
    fac.at(i+1) = fac.at(i) * (i+1);
  }
  return;
}

mint f(int r, int c){ // (r+c)!/(r!c!)
  mint a = fac.at(r+c);
  mint b = fac.at(r);
  mint d = fac.at(c);
  mint ans = a / (b * d);
  return ans;
}

mint mpow(ll a, ll b){ // a^b
  if(b == 0){
    return 1;
  }
  mint p = 1;
  if(b % 2 == 0){
    p = mpow(a, b/2) * mpow(a, b/2);
  }
  else{
    p = mpow(a, b/2) * mpow(a, b/2) * a;
  }
  return p;
}

vector<mint> mp(2000003, 1);

void calc2(ll x, ll y){
  rep(i, y){
    mp.at(i+1) = mp.at(i) * x;
  }
  return;
}
  
int main(){
  ll N, M, K;
  cin >> N >> M >> K;
  calc(N);
  calc2(M-1, N);
  mint ans = 0;
  rep2(i, N-1-K, N){
    ans += f(N-1-i, i) * M * mp.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 34268