akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
int dx[4]={0,1,0,-1};

class FF
{
public:
  struct edge{int to,cap,rev;};
  vector<vector<edge>>G;
  vector<bool> used;
  FF(int maxv)
  {
    G.resize(maxv);
    used.resize(maxv);
  }
  void add_edge(int from,int to,int cap,bool directed=1)
  {
    G[from].push_back({to,cap,(int)G[to].size()});
    G[to].push_back({from,cap*(!directed),(int)G[from].size()-1});
  }
  int dfs(int v,int t,int f)
  {
    if(v==t)return f;
    used[v]=1;
    for(auto &nv:G[v])
    {
      if(!used[nv.to] && nv.cap>0)
      {
        int d=dfs(nv.to,t,min(f,nv.cap));
        if(d>0)
        {
          nv.cap-=d;
          G[nv.to][nv.rev].cap+=d;
          return d;
        }
      }
    }
    return 0;
  }
  int solve(int s,int t)
  {
    int res=0;
    while(1)
    {
      for(int i=0;i<used.size();i++)used[i]=0;
      int f=dfs(s,t,(1<<30)-1);
      if(f==0)break;
      res+=f;
    }
    return res;
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h,w;
  cin>>h>>w;
  vector<string> hw(h);
  rep(i,h)cin>>hw[i];
  FF ff(h*w*2+2);
  int s=h*w*2,t=h*w*2+1;
  rep(i,h)rep(j,w)rep(k,4)
  {
    int y=i+dx[k^1],x=j+dx[k];
    if(y<0||y>=h||x<0||x>=w)
    {
      ff.add_edge((i*w+j)*2+1,t,10000,1);
      //cout<<h*w+1<<" "<<i*w+j<<endl;
    }
    else
    {
      ff.add_edge((i*w+j)*2+1,(y*w+x)*2,10000,1);
    }
  }
  rep(i,h)rep(j,w)
  {
    if(hw[i][j]=='X')
    {
      if(i==0||i==h-1||j==0||j==w-1)
      {
        cout<<-1<<endl;
        return 0;
      }
      ff.add_edge(s,(i*w+j)*2+1,10000,1);
    }
    else
    {
      ff.add_edge((i*w+j)*2,(i*w+j)*2+1,1,1);
    }
  }
  cout<<ff.solve(s,t)<<endl;

  return 0;

}


Measured memory_bytes: 2944
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, X, x):

    x.reverse()
    sa = [0]
    for a in x:
        sa.append(sa[-1]+a)

    ans = sys.maxsize
    for k in range(1, N+1):
        t = X*N
        for j in range(1, math.ceil(N/k)+1):
            s = (j-1)*k
            e = (j)*k
            if e >= len(sa):
                e = len(sa)-1

            if j == 1:
                t += 5*(sa[e]-sa[s])
            else:
                t += (2*j+1)*(sa[e]-sa[s])

        t += k*X
        ans = min(ans, t)
    return ans


def main():
    N, X = read_int_n()
    x = read_int_n()
    print(slv(N, X, x))


if __name__ == '__main__':
    main()


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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> v(n);
  vector<string> ans(m);

  for (int i = 0; i < m; i++) {
    int p, y;
    cin >> p >> y;
    v[p - 1].emplace_back(y, i);
  }

  for (int i = 0; i < n; i++) {
    sort(begin(v[i]), end(v[i]));
    for (int j = 0; j < int(v[i].size()); j++) {
      stringstream ss;
      ss << setw(6) << setfill('0') << i + 1
         << setw(6) << setfill('0') << j + 1;
      ans[v[i][j].second] = ss.str();
    }
  }

  for (auto&& e : ans) {
    cout << e << endl;
  }
}


Measured memory_bytes: 12416
#include <stdio.h>
int main(void)
{
  int W, H, x, y, r;
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  if(x < r||y < r) printf("No\n");
  else if(W - x < r||H - y < r) printf("No\n");
  else printf("Yes\n");
  return(0);
}

Measured memory_bytes: 584
mod=10**9+7
S=int(input())
'''
数列はN項
1<=N<=S//3
A1,...,ANとしたとき
Bk=Ak-3は0以上であって、
B1+...+BN=S-3*N
S-3NをN-1個の隙間で分ける
S-2N-1 C N-1
'''
MAX_N=2020
Fact=[0 for i in range(MAX_N+1)]
Finv=[0 for i in range(MAX_N+1)]
Fact[0]=1
for i in range(MAX_N):
    Fact[i+1]=(i+1)*Fact[i]
    Fact[i+1]%=mod
Finv[MAX_N]=pow(Fact[MAX_N],mod-2,mod)
for i in range(MAX_N-1,-1,-1):
    Finv[i]=(i+1)*Finv[i+1]
    Finv[i]%=mod
def C(n,k):
    return (Fact[n]*Finv[k]*Finv[n-k])%mod
ans=0
for N in range(1,1+S//3):
    ans+=C(S-2*N-1,N-1)
    ans%=mod
print(ans)


Measured memory_bytes: 67368
#include <iostream>
using namespace std;
int main(){
	int num;
	cin >> num;
	int count;
	for(count=0; count<num; count++){
	    int a,b,c;
	    cin >> a >> b >> c;
	    //using Pythagorean theorem
	    if(a*a+b*b==c*c || b*b+c*c==a*a || c*c+a*a==b*b){
		cout << "YES" << endl;
	    }else{
		cout << "NO" << endl;
	    }
	}
	return 0;
}

Measured memory_bytes: 3056
#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 FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int x,y;
    cin >> x >> y;
    if( abs(x - y) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll a[200001];
map<ll,ll> mp; 
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[i];
    ll sum=0;
    ++mp[0];
    rep(i,n){
        sum+=a[i];
        ++mp[sum];
    }
    ll ans=0;
    for(auto it:mp){
        ans+=it.second*(it.second-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 14336
import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
N  = int(input())
(S,T)  = input().split()
# print(S,T)
for i in range(0,N):
    print(S[i], end="")
    print(T[i], end="")
print()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define len(arr) (int)(sizeof(arr)/sizeof((arr)[0]))
#define Sort(arr) sort(arr,arr+len(arr))
#define For(i,s,n) for(ll i=s;i<n;i++)	
#define Rep(i,n) for(int i=0;i<n;i++)
#define Per(i,n) for(int i=n;i>=0;i--)
#define All(x) (x).begin(),(x).end()
#define in(arr,n) Rep(i,n) cin >> arr[i];
#define in2(arr1,arr2,n) Rep(i,n) cin >> arr1[i] >> arr2[i];
#define in3(arr1,arr2,arr3,n) Rep(i,n) cin >> arr1[i] >> arr2[i] >> arr3[i];
#define LL_MAX 9223372036854775807
#define LL_MIN -9223372036854775808
#define MOD 1000000007
#define MOD9 1000000009

//{ ライブラリ

// 標準出力の高速化
#define endl "\n"

// 出力
template<typename Type>
void print(Type a[],int n){
	Rep(i,n) cout << a[i] << endl;
}
template<typename Type1,typename Type2>
void print(Type1 a[],Type2 b[],int n){
	Rep(i,n) cout << a[i] << " " << b[i] << endl;
}
template<typename Type1,typename Type2,typename Type3>
void print(Type1 a[],Type2 b[],Type3 c[],int n){
	Rep(i,n) cout << a[i] << " " << b[i] << " " << c[i] << endl;
}

// 配列の最大値
template<typename Type>
Type max(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=max(ret,a[i]);
	return ret;
}

// 配列の最小値
template<typename Type>
Type min(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=min(ret,a[i]);
	return ret;
}

// 最大公約数
template<typename Type>
Type gcd(Type a,Type b){return(b==0)?a:gcd(b,a%b);}
template<typename Type>
Type gcd(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=gcd(ret,a[i]);
	return ret;
}

// 最小公倍数
template<typename Type>
Type lcm(Type a,Type b){return (a/gcd(a,b))*b;}
template<typename Type>
Type lcm(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=lcm(ret,a[i]);
	return ret;
}

// aを元にしてペアでソート
template<typename Type1,typename Type2>
void PairSort(Type1 a[],Type2 b[],int left,int right){
	int i=left,j=right;
	Type1 p=a[(left+right)/2];
	while(true){
		while(a[i]<p) i++;
		while(p<a[j]) j--;
		if(i>=j) break;
		swap(a[i],a[j]);
		swap(b[i],b[j]);
		i++;j--;
	}
	if(left<i-1) PairSort(a,b,left,i-1);
	if(j+1<right) PairSort(a,b,j+1,right);
}
template<typename Type1,typename Type2,typename Type3>
void PairSort(Type1 a[],Type2 b[],Type3 c[],int left,int right){
	int i=left,j=right;
	Type1 p=a[(left+right)/2];
	while(true){
		while(a[i]<p) i++;
		while(p<a[j]) j--;
		if(i>=j) break;
		swap(a[i],a[j]);
		swap(b[i],b[j]);
		swap(c[i],c[j]);
		i++;j--;
	}
	if(left<i-1) PairSort(a,b,c,left,i-1);
	if(j+1<right) PairSort(a,b,c,j+1,right);
}

// 配列を逆順にする
template<typename Type>
void Reverse(Type a[],int n){Rep(i,n/2) swap(a[i],a[n-i-1]);}

// 文字列を逆順にする
// reverse(All(str));

//}

int main(){
	ll L,R;
	cin >> L >> R;
	
	if(R-L>=2019){
		cout << 0;
		return 0;
	}
	else{
		ll ret=2018;
		For(i,L,R+1){
			For(j,i+1,R+1){
				//cout << i << "," << j << "," << (i*j)%2019 << endl;
				ret=min(ret,(i*j)%2019);
			}
		}
		cout << ret;
	}
}

Measured memory_bytes: 256
import sys
import bisect

N = int(sys.stdin.readline())
L = list(map(int, sys.stdin.readline().split()))
L = sorted(L)

count = 0
for a_i in range(N-1):
    for b_i in range(a_i+1, N):
        max_c = bisect.bisect_left(L, L[a_i]+L[b_i])
        if max_c > b_i:
            count += max_c - b_i - 1
        
print(count)

Measured memory_bytes: 42972
import java.util.Scanner;

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

        int A = scanner.nextInt();
        int B = scanner.nextInt();

        int tapCount = 0;
        int ifCount = 1;

        while (ifCount < B) {
            ifCount = ifCount + A - 1;
            tapCount++;
        }

        System.out.println(tapCount);
    }
}


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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define FORR(v, c) for (auto &v : c)
#define F first
#define S second
#define SQ(x) (x)*(x)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define dbg(x) cerr<<#x<<" = " << (x) << endl
#define pnl(x) cout << x << '\n'
#define pns(x) cout << x << ' '
#define read(x) cin >> x
#define read2(x,y) cin >> x >> y
#define read3(x, y, z) cin >> x >> y >> z
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define readv(v) FORR(c,v) read(c)

struct Arrete { int v, c;};
struct Point {int x, y; double distance(Point other) const {return sqrt(SQ(x-other.x)+SQ(y-other.y));}};

typedef	vector<int>	vi;
typedef pair<int,int>	ii;
typedef vector<string>	vs;
typedef vector<ii>	vii;
typedef vector<Arrete>	vg;
typedef vector<long long>	vl;
typedef	long long ll;

const int MAXN = 3000;

ll maximise[MAXN][MAXN];
ll minimise[MAXN][MAXN];
int N;
ll values[MAXN];

void run(int left, int right, int sign)
{
	if (minimise[left][right] != -1) return ;
	if (left == right)
	{
		minimise[left][right] = maximise[left][right] = sign*values[left];
		return ;
	}
	run(left + 1, right, -sign);
	run(left, right - 1, -sign);
	minimise[left][right] = min( sign * values[left] + maximise[left+1][right], 
								sign * values[right] + maximise[left][right - 1]);
	maximise[left][right] = max( sign * values[left] + minimise[left+1][right],
								sign * values[right] + minimise[left][right-1]);
}

int		main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	FOR(i,0, MAXN) FOR(j,0, MAXN) maximise[i][j] = minimise[i][j] = -1;

	read(N);
	FOR(i,0,N) read(values[i]);
	run(0, N-1, 1);
	pnl(maximise[0][N-1]);
}



Measured memory_bytes: 141184
#include<bits/stdc++.h>
#define Re read()
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define fd(i,a,b) for(register int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
const int N = 1e6;

inline int read(int n=0) {
    register char ch;while(!isdigit(ch=getchar()));
    for(n=ch^48;isdigit(ch=getchar());n=(n<<3)+(n<<1)+(ch^48));return n;
}
int a,b;
int main() {
	cin>>a>>b;
    if(a>9||b>9)cout<<-1;
	else cout<<a*b;
    return 0;
}

Measured memory_bytes: 256
<?php

$line = fgets(STDIN);

$lines = explode(" ", $line);

$h = floor($line / 3600);
$m = floor(($line % 3600) / 60);
$s = $line % 60;

echo $lines[0] * $lines[1] . " ". ($lines[0] + $lines[1])*2;
?>

Measured memory_bytes: 15320
#include<bits/stdc++.h>
using namespace std;
int64_t a, b, c, d;

int main() {
    cin >> a >> b >> c >> d;
    int64_t ans = LLONG_MIN;
    ans = max(ans, a * c);
    ans = max(ans, b * d);
    if (a <= 0 && b >= 0) ans = max(ans, int64_t(0));
    if (c <= 0 && d >= 0) ans = max(ans, int64_t(0));
    ans = max(ans, b * c);
    ans = max(ans, a * d);
    cout << ans << '\n';
}


Measured memory_bytes: 3588
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0)break;
			else calc(n , m);
			
		}
	}
	public void calc(int n, int m){
		ArrayList<int[]> list = new ArrayList<int[]>();
		for(int i = 0; i < m; i++){
			int t = sc.nextInt();
			int s = sc.nextInt();
			int d = sc.nextInt();
			list.add(new int[]{t,s,d});
		}
		list = mergeSort(list);
		
		int[] pc = new int[n+1];
		pc[1] = 1;
		int sum = 1;
		for(int i = 0; i < list.size(); i++){
			int[] item = list.get(i);
			if(pc[item[1]] == 1 && pc[item[2]] == 0){
				pc[item[2]] = 1;
				sum++;
			}
			
		}
		System.out.println(sum);
	}

	public ArrayList<int[]> mergeSort(ArrayList<int[]> list){
		if(list.size() > 1){
			int n = list.size() / 2;
			int m = list.size() - n;
			ArrayList<int[]> a1 = new ArrayList<int[]>();
			ArrayList<int[]> a2 = new ArrayList<int[]>();
			for(int i = 0; i < n; i++) a1.add(list.get(i));
			for(int i = 0; i < m; i++) a2.add(list.get(i + n));
			a1 = mergeSort(a1);
			a2 = mergeSort(a2);
			return merge(a1, a2);
		}
		else return list;
	}
	public ArrayList<int[]> merge(ArrayList<int[]> a1, ArrayList<int[]> a2){
		int i = 0;
		int j = 0;
		ArrayList<int[]> a = new ArrayList<int[]>();
		while(i < a1.size() || j < a2.size()){
			if(j >= a2.size() || (i < a1.size() && a1.get(i)[0] < a2.get(j)[0])){
				a.add(a1.get(i));
				i++;
			}
			else {
				a.add(a2.get(j));
				j++;
			}
		}
		return a;
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 254064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	ll n;
	cin >> n;
	if(n==0) break;
	int m = 1;
	if(n < 0) {
	    m *= -1;
	    n *= -1;
	}
	vector<int> ans;
	while(n != 0){
	    int p = 0;
	    if(m>0){
		p = n % 10;
		n /= 10;
	    }else if(n%10>0){
		p = 10 - n % 10;
		n /= 10;
		n++;
	    }else n /= 10;
	    ans.PB(p);
	    m *= -1;
	}
	reverse(ALL(ans));
	REP(i,ans.size()) cout << ans[i];
	cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#define SORT(v) sort(v.begin(), v.end())
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <algorithm>
#include <cstdarg>
#include <cstdio>
#include <numeric>

// #include "ane.cpp"

#define INF (int)1e9
#define INFLL (long long)1e18
#define NMAX 200
#define MMAX 200
#define MOD 100000
using namespace std;

// コメントアウトするとdb_printf()を実行しない
#define DEBUG
// デバッグ用printf
void db_printf(const char* format, ...){
    #ifndef DEBUG
    return;
    #endif
    va_list arg;
    va_start(arg, format);
    vprintf(format, arg);  // コンソールに出力
    va_end(arg);
}
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
typedef pair<int, int> p;
typedef long long ll;

ll N,M,K,A,B,C,E;
std::vector<int> D;
int dp[NMAX][MMAX] = {};

static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

ll ans = 0;

bool check(int p){
    while(p) {
        int digit = p % 10;
        p /= 10;

        if (find(D.begin(), D.end(), digit) != D.end())
        {
            return false;
        }
    }
    return true;
}
void solve(){
    // 解答アルゴリズム
    for (int price = N; ; ++price)
    {
        if (check(price))
        {
            ans = price;
            break;
        }
    }
}
void debug(){
    // デバッグ用出力
}
void answer(){
    // 解答出力
    printf("%lld\n", ans);
}
int main(int argc, char const *argv[])
{
    // 入力の読み込み，番兵法

    Fill(dp, -1);

    scanf("%lld%lld", &N, &M);
    for (int i = 0; i < M; ++i)
    {
        int x; scanf("%d", &x);
        D.push_back(x);
    }
    solve();
    #ifdef DEBUG
    debug();
    #endif
    answer();

    return 0;
}

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

import java.util.List;
import java.util.Stack;

public class Main {

    public static void main(String[] args) throws IOException {
        Writer writer = new Writer();
        Reader reader = new Reader();

        Stack<Integer> stack = new Stack<>();
        while (reader.isReadable()) {
            final int index = reader.readInt();

            if (index == 0) {
                writer.write(stack.pop() + "\n");
            } else {
                stack.push(index);
            }
        }

        writer.print();
    }

}

class Writer {

    private StringBuilder stringBuilder;

    public Writer() {
        this.stringBuilder = new StringBuilder();
    }

    public <T> void write(T text) {
        this.stringBuilder.append(text);
    }

    public void print() {
        System.out.print(stringBuilder);
    }

}

class Reader {

    private InputStreamReader inputReader;
    private BufferedReader bufferedReader;
    private StringTokenizer tokenizer;
    private String delim;

    public Reader() {
        this.inputReader = new InputStreamReader(System.in);
        this.bufferedReader = new BufferedReader(inputReader);
        this.tokenizer = new StringTokenizer("");
        this.delim = null;
    }

    public void setDelim(String delim) {
        this.delim = delim;
    }

    public boolean isReadable() throws IOException {
        try {
            checkTokenizer();
        } catch (NullPointerException e) {
            return false;
        }

        return true;
    }

    public int readInt() throws IOException {
        return Integer.parseInt(read());
    }

    public double readDouble() throws IOException {
        return Double.parseDouble(read());
    }

    public String read() throws IOException {
        try {
            checkTokenizer();
        } catch (NullPointerException e) {
            return null;
        }

        if (delim == null) {
            return this.tokenizer.nextToken();
        } else {
            return this.tokenizer.nextToken(delim);
        }
    }

    private void checkTokenizer() throws IOException, NullPointerException {
        if (this.tokenizer.hasMoreTokens()) { return; }

        final String line = this.bufferedReader.readLine();
        this.tokenizer = new StringTokenizer(line);
    }

}

Measured memory_bytes: 24056
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 4005;
int R[MAX],G[MAX],B[MAX];
int main (){
    string S;
    ll n,res=0;cin >> n >> S;
    S = "#" + S;
    for(int i=1;i<=n;i++){
            R[i] = R[i-1] + (S[i]=='R');
            G[i] = G[i-1] + (S[i]=='G');
            B[i] = B[i-1] + (S[i]=='B');
//            cout<<i<<" red "<<R[i]<<endl;
//            cout<<i<<" green "<<G[i]<<endl;
//            cout<<i<<" blue "<<B[i]<<endl;
    }
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(S[j]==S[i])continue;
            int df = j-i;
            if(S[i]=='R'&&S[j]=='G'){
                res+=B[n]-B[j];
                if(df+j<=n){

                    if(S[df+j]=='B')res--;
                }
            }
            if(S[i]=='G'&&S[j]=='R'){
                res+=B[n]-B[j];
                if(df+j<=n){

                    if(S[df+j]=='B')res--;
                }
            }
            if(S[i]=='B'&&S[j]=='R'){
                res+=G[n]-G[j];
                if(df+j<=n){

                    if(S[df+j]=='G')res--;
                }
            }
            if(S[i]=='R'&&S[j]=='B'){
                res+=G[n]-G[j];
                if(df+j<=n){

                    if(S[df+j]=='G')res--;
                }
            }
            if(S[i]=='G'&&S[j]=='B'){
                res+=R[n]-R[j];
                if(df+j<=n){

                    if(S[df+j]=='R')res--;
                }
            }
            if(S[i]=='B'&&S[j]=='G'){
                res+=R[n]-R[j];
                if(df+j<=n){

                    if(S[df+j]=='R')res--;
                }
            }
        }
    }
    cout<<res;
    //main();
    return 0;
}


Measured memory_bytes: 3680
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main() {
	int n = 0, x = 0, m = 0;
	int count[2] = {};
	int a[100] = {};
	std::cin >> n >> m >> x;
	for (int i = 0; i < m; i++) { std::cin >> a[i]; }
	for (int i = 0; i < m; i++) {
		if (a[i] < x) {
			count[0]++;
		}
		else {
			count[1]++;
		}
	}
	std::cout << std::min(count[0], count[1]) << std::endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

u64 pw(i32 n) {
  u64 ans = 1;
  while (n--) ans <<= 1ull;
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  u64 a, b;
  cin >> a >> b;
  a--;
  vu64 c1(62, 0), c2(62, 0);
  rep(i, 62) {
    c1[i] = (b / pw(i + 1)) * pw(i);
    u64 rest = b - c1[i] * 2 + 1;
    if (rest > pw(i)) {
      c1[i] += rest - pw(i);
    }
  }
  rep(i, 62) {
    c2[i] = (a / pw(i + 1)) * pw(i);
    u64 rest = a - c2[i] * 2 + 1;
    if (rest > pw(i)) {
      c2[i] += rest - pw(i);
    }
  }
  u64 ans = 0;
  rrep(i, 62) {
    ans <<= 1ull;
    if ((c1[i] - c2[i]) % 2 == 1) {
      ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<int,int>cnt;
    int n;
    cin>>n;
    int i,a,ans=0;
    for(i=1;i<=n;i++){
            cin>>a;
        cnt[a]++;
    }
    for(auto u:cnt){
        if(u.second>=u.first)
            ans+=(u.second-u.first);
        else
            ans+=u.second;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8072
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var ABC = ReadSplit();
            YESOrNO(ABC[0].Last() == ABC[1].First() && ABC[1].Last() == ABC[2].First());
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 13268
N = int(input())
S = [s for s in input()]
ans = S.count("R") * S.count("G") * S.count("B")

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = j + (j - i)
        if N - 1 < k:
            continue
        if S[k] != S[i] and S[k] != S[j] and S[i] != S[j]:
            ans -= 1

print(ans)


Measured memory_bytes: 9152
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int main() {
	int n[5];
	scanf(" %d %d %d %d %d", &n[0], &n[1], &n[2], &n[3], &n[4]);
	qsort(n, 5, sizeof(int), compare);
	printf("%d %d %d %d %d\n", n[0], n[1], n[2], n[3], n[4]);
	return 0;
}

Measured memory_bytes: 600
// ABC079A - 

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

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	string S;
	cin >> S;

	if ((S[0] == S[1])&&(S[1] == S[2])) {
		cout << "Yes" << endl;
		return 0;
	}

	if ((S[1] == S[2])&&(S[2] == S[3])) {
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int h, w;char c[110][110];
signed main(){
  cin>>h>>w;
  rep(i,h)rep(j,w)cin>>c[i][j];
  cout << string(w+2, '#') << endl;
  rep(i,h){
    cout << '#';
    rep(j,w){
      cout << c[i][j];
    }
    cout << '#' << endl;
  }
  cout << string(w+2, '#') << endl;
}


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

int main(){
  int w,h;
  int dx[8] = {1,1,0,-1,-1,-1,0,1};
  int dy[8] = {0,1,1,1,0,-1,-1,-1};
  while(true){
  cin>>w>>h;
  if(!w&&!h)break;
  w+=2,h+=2;
  int island[w][h];
  for(int x=0;x<w;x++){
    island[x][0] = 0;
    island[x][h-1] = 0;
  }
  for(int y=1;y<h-1;y++){
    island[0][y] = 0;
    island[w-1][y] = 0;
    for(int x=1;x<w-1;x++){
      cin>>island[x][y];
    }
  }
  int count = 0;
  queue<int> qu;
  for(int y=1;y<h-1;y++){
    for(int x=1;x<w-1;x++){
      if(island[x][y]){
	qu.push(y*w+x);
	while(!qu.empty()){
	  if(island[qu.front()%w][qu.front()/w]){
	    island[qu.front()%w][qu.front()/w] = 0;
	    for(int i=0;i<8;i++)
	      qu.push(qu.front()+dy[i]*w+dx[i]);
	  }
	  qu.pop();
	}
	count++;
      }
    }
  }
  cout<<count<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
using namespace std;
const int maxd=1000000007,N=100000;
const double pi=acos(-1.0);
typedef long long ll;
int n;

int read()
{
	int x=0,f=1;char ch=getchar();
	while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
	while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
	return x*f;
}

int main()
{
	n=read();
	int i,sum=0,maxl=0;
	for (i=1;i<=n;i++) 
	{
		int x=read();
		maxl=max(maxl,x);
		sum+=x;
	}
	sum-=maxl;
	if (maxl<sum) cout << "Yes"; else cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 30
#define NIL -1
struct node{
	int p,l,r;
}; 
struct node t[MAX];
void preOrder(int u){
	printf(" %d",u);
	if(t[u].l!=NIL)
	preOrder(t[u].l);
	if(t[u].r!=NIL)
	preOrder(t[u].r);
}
void inOrder(int u){
	if(t[u].l!=NIL)
	inOrder(t[u].l);
	printf(" %d",u);
	if(t[u].r!=NIL)
	inOrder(t[u].r);
}
void postOrder(int u){
	if(t[u].l!=NIL)
	postOrder(t[u].l);
	if(t[u].r!=NIL)
	postOrder(t[u].r);
	printf(" %d",u);
}
int main(){
	int i,j,n;
	for(i=0;i<MAX;i++){
		t[i].p=NIL;
		t[i].l=NIL;
		t[i].r=NIL;
	}//初始化
	scanf("%d",&n);
	int id[n+1];
	for(i=0;i<n;i++){
		scanf("%d",&id[i]);
		scanf("%d%d",&t[id[i]].l,&t[id[i]].r);
		if(t[id[i]].l+1)
		t[t[id[i]].l].p=id[i];
		if(t[id[i]].r+1)
		t[t[id[i]].r].p=id[i];
	}//输入
	for(i=0;i<n;i++){
		if(t[i].p==NIL)
		break;
	}
	printf("Preorder\n");
	preOrder(i);
	printf("\n");
	printf("Inorder\n");
	inOrder(i);
	printf("\n");
	printf("Postorder\n");
	postOrder(i);
	printf("\n");
	return 0;
} 


Measured memory_bytes: 2088
H,W=map(int,input().split())
p=[['.']*(W+2)]*(H+2)
for i in range(H):
  s=input()
  p[i+1]='.'+s+'.'
for i in range(1,H+1):
  for j in range(1,W+1):
    if p[i][j]=='#':
      flag=False
      for x,y in ([-1,0],[1,0],[0,-1],[0,1]):
        if p[i+x][j+y]=='#':
          flag=True
          break
      if not flag:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 9088
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-6-10 21:04:50
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

set<int> S;
int X[100010];

int main()
{
  int N;
  cin >> N;
  fill(X, X + 100010, 200010);
  int x = 1;
  while (x < 100010)
  {
    S.insert(x);
    x *= 6;
  }
  x = 1;
  while (x < 100010)
  {
    S.insert(x);
    x *= 9;
  }
  X[0] = 0;
  for (auto i = 0; i < N; i++)
  {
    for (auto x : S)
    {
      if (i + x < 100010)
      {
        X[i + x] = min(X[i + x], X[i] + 1);
      }
    }
  }
  cout << X[N] << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<cmath>
#include<map> 
#include<string>
#include<queue>
#include<stack> 
#include<bitset>
#include<list>
#include<set>
#include<utility>
#include<functional>
#include<iomanip>
#define IO ios::sync_with_stdio(false)
#define eps 1e-7
#define int long long
using namespace std;
int x;
signed main()
{
	cin>>x;
	cout<<!x;
 } 

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

#define ll long long
#define ar array


ll solve()
{
    ll t=0,a=100,x;
    cin>>x;
    while(a<x){
    a+=a/100;
    t++;
    }
    cout<<t<<endl;
  return 0;
}

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

    
        solve();

    
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <iostream>
// #include <unordered_map>
#define vi vector <ull>
#define ii pair<ull,ull>
#define vii vector<ii>
 
#define seti set<ull>
#define mii map<ull,ull>
#define um unordered_map
#define ll long long
#define ull  long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MAX 100100
#define _ << " " <<
 
using namespace std;
 
vector<int> g[100100];
bool used[100100];

int dp[100100];
 
void dfs(int v){
	used[v] = true;

	for(int to: g[v]){
		if(used[to]){
			dp[v] = max(dp[v], dp[to]+1);
		}else{
			dfs(to);
			dp[v] = max(dp[v], dp[to]+1);
		}
	}
}

 
void solve(){
	for(int i = 0 ; i < 100100; i++){
		used[i] = 0;
		dp[i] = 0;
	}

	int n, m;
	cin >> n >> m;

	for(int i = 0 ; i< m; i++){
		int x,y;
		cin >> x >> y;
		g[x].push_back(y);

	}

	for(int i = 1; i <= n; i++){
		if(!used[i]){
			dfs(i);
		}
	}

	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans = max(dp[i], ans);
	}
	cout << ans;

}
 
 
int main(){
	// freopen("data.in", "r", stdin);
	// freopen("data.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ull q;
	// cin >> q;
	q = 1;
	for(ull i = 0; i < q; i++){
		// cout << "Case #" << i+1 << ":" << endl;
 
		solve();
		// cout << endl;
	}
 
	
 
	return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int64_t ans, r = 0, g = 0, b = 0;
  for (char c : s) {
    switch (c) {
      case 'R':
        r++;
        break;
      case 'G':
        g++;
        break;
      case 'B':
        b++;
        break;
    }
  }
  ans = r * g * b;
  for (int d = 1; 2 * d < n; d++) {
    for (int i = 0; i + 2 * d < n; i++) {
      if (s[i] != s[i + d] && s[i] != s[i + 2 * d] && s[i + d] != s[i + 2 * d]) {
        ans--;
      }
    }
  }
  cout << ans << endl;
}


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

int main (){
	int x[100001];
	int n,k,q;
	cin>>n>>k>>q;
	for(int i=1;i<=n;i++)x[i]=k;
	for(int k=1;k<=q;k++){
		int z;
		scanf("%d",&z);
		x[z]++;
	}
	for(int i=1;i<=n;i++){
		if(x[i]<=q)puts("No");
		else puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
	if (a > 0) return a % MOD;
	if (a % MOD == 0) return 0;
	ll x = -a / MOD + 1;
	a += x * MOD;
	return a % MOD;
}

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

bool used[1145134] = {};

int main() {
	IOS();
	ll s;
	cin >> s;
	ll ans = 1;
	while (1) {
		if (used[s]) {
			cout << ans << endl;
			return 0;
		}
		used[s] = true;
		if (s % 2 == 0)
			s = s / 2;
		else
			s = 3 * s + 1;
		ans++;
	}
}

Measured memory_bytes: 256
/*.....Bismillahir Rahmanir Rahim.....*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld long double
#define   pb push_back
#define  sz(x)  (int)x.size()
#define  ff first
#define  ss second
#define  pii  pair<int,int>
using namespace std;

int  gcd(int a,int b) {
	return  (b==0)? a: gcd(b,a%b);
}

void solve(){ 
	ld  n;  cin >> n ;
	printf("%.7Lf\n",(n/3*n/3*n/3)); 
}

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


Measured memory_bytes: 256
#include<iostream>
#include<stack>
using namespace std;
int main() {
    int n, q; cin >> n >> q;
    stack<int> s[n];
    for (int i = 0; i < q; i++) {
        int a, b; cin >> a >> b;
        if (a == 0) {
            int c; cin >> c;
            s[b].push(c);
        } else if (a == 1) {
            if (!s[b].empty() ) cout << s[b].top() << endl;
        } else {
            if (!s[b].empty() ) s[b].pop();
        }
    }
}



Measured memory_bytes: 4364
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int n;
vector<string> a;

void input() {
  cin >> n;

  a.resize(n);
  for (auto&& i : a)
    cin >> i;
}

int count(string_view where, string_view what) {
  int ans = 0;

  int pos = (int)where.find(what);

  while (pos != -1) {
    ++ans;

    pos = (int)where.find(what, pos + 1);
  }

  return ans;
}

void solve() {
  int ans = 0;

  for (auto&& i : a)
    ans += count(i, "AB");

  int cnt1 = 0;
  int cnt2 = 0;
  int cnt3 = 0;

  for (auto&& i : a) {
    if (i[0] == 'B' && i.back() == 'A') {
      ++cnt1;

      continue;
    }

    cnt2 += i[0] == 'B';
    cnt3 += i.back() == 'A';
  }

  if (cnt1 > 0) {
    if (cnt2 + cnt3 > 0) {
      ans += cnt1 + min(cnt2, cnt3);
    } else {
      ans += cnt1 - 1;
    }
  } else {
    ans += min(cnt2, cnt3);
  }

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

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  cin >> _times;
#endif

  while (_times--) {
    input();
    solve();
  }
}
#include <cmath>



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

int main()
{
	long long int a;
	long long int i=1;
	scanf("%lld",&a);
	while(i<=sqrt(a))
	{
		i++;
	}
	i--;
	printf("%lld\n",i*i);
	return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
wv = []
for _ in range(N):
  wv += list(map(int, input().split()))
MAX_N, MAX_V = 110, 100100
dp = [[10e+09 for i in range(MAX_V)] for j in range(MAX_N)]
dp[0][0] = 0
for i in range(N):
  for v in range(MAX_V):  
    if v-wv[2*i+1] >= 0:
      dp[i+1][v] = min(dp[i+1][v], dp[i][v-wv[2*i+1]]+wv[2*i])
    dp[i+1][v] = min(dp[i+1][v], dp[i][v])
for v in range(MAX_V):
  if dp[N][v] <= W: res = v
print(res)

Measured memory_bytes: 339792
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;

int main(){

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	int n,m;
	cin>>n>>m;
	int low = 1;
	int high = n;
	int l,r;
	for(int i=0;i<m;i++){
		cin>>l>>r;
		if(l>low)
			low = l;
		if(r<high)
			high = r;
	}
	if(high-low+1>=0)
		cout<<high-low+1;
	else
		cout<<0;
	return 0;

}

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

int main(){
    int n;
    cin >> n;
    if(n%2 != 0){
        cout << "No";
        return 0;
    }
    string s;
    cin >> s;
    string z = s.substr(0,n/2), y = s.substr(n/2,n/2);
    if(z == y)cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3556
INF = 10 ** 20

def get_dist(r1, r2):
  return ((r1 + r2) ** 2 - (r1 - r2) ** 2) ** (1 / 2)

def minimum_width(rest, r, dic):
  if (rest, r) in dic:
    return dic[(rest, r)]
  if rest == ():
    return r

  ret = INF
  lenr = len(rest)
  for c in rest:
    next_rest = list(rest)
    next_rest.remove(c)
    ret = min(ret, minimum_width(tuple(next_rest), c, dic) + get_dist(r, c))
  dic[(rest, r)] = ret
  return ret


while True:
  try:
    lst = list(map(int, input().split()))
    w = lst[0]
    cakes = lst[1:]
    cakes.sort()
    lenc = len(cakes)
    dic = {}
    ans = INF
    for c in cakes:
      tmp = cakes[:]
      tmp.remove(c)
      ans = min(ans, minimum_width(tuple(tmp), c, dic) + c)
    if w >= ans:
      print("OK")
    else:
      print("NA")
  except EOFError:
    break


Measured memory_bytes: 7084
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int digits(long long n) {
	int digits = 0;

	while (n > 0) {
		n /= 10;
		digits++;
	}
	return digits;

}
int main() {

	long long n;
	cin >> n;

	int ans = digits(n);

	for (long long a = 1; a * a <= n; a++) {

		if (n % a != 0) continue;

		long long b = n / a;
		int mx = max(digits(a), digits(b));

		if (ans > mx) {
			ans = mx;
		}
	}

	cout << ans << endl;
	return 0;
}

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

int main(){
	vi a(3);
	bool f1=false,sv=false,f2=false;
	rep(i,3){
		cin>>a.at(i);
		if(a.at(i)==5){
			if(!f1)f1=true;
			else f2=true;
		}else if(a.at(i)==7)sv=true;
	}
	if(f1&&sv&&f2)
		cout<<"YES\n"s;
	else
		cout<<"NO\n"s;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vii;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip> vip;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 :1e9;
#define MAX 50010
int dp[110][MAX];
int mo[110][MAX];
void f(int a,int b,int c,int d){
    if(dp[a][b]<c){
        dp[a][b]=c;
        mo[a][b]=d;
    }else if(dp[a][b]==c)
        mo[a][b]=min(mo[a][b],d);
}
int main(){
    int n;
    while(cin>>n,n){
        vi in(n);
        rep(i,n)cin>>in[i];
        rep(j,110)rep(k,MAX)dp[j][k]=-inf;
        dp[0][0]=mo[0][0]=0;
        rep(i,n)rep(j,MAX)if(dp[i][j]!=-inf){
            f(i+1,j,dp[i][j],mo[i][j]);
            int a=in[i]%1000;
            int t=1000-a;
            if(a)f(i+1,j+t%500,dp[i][j]+(t>=500),mo[i][j]+in[i]);
            else if(j>=500)f(i+1,j-500,dp[i][j]+1,mo[i][j]+in[i]);
            t=500+j-a;
            if(t>=0&&a>=500)f(i+1,t,dp[i][j]+1,mo[i][j]+in[i]);
        }
 
        int outc=0,out=inf;
        rep(i,MAX)if(dp[n][i]!=-inf){
            if(outc<dp[n][i]){
                outc=dp[n][i];
                out=mo[n][i];
            }else if(outc==dp[n][i])
                out=min(out,mo[n][i]);
        }
        cout<<outc<<" "<<out<<endl;
    }
}


Measured memory_bytes: 34712
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();

		int[] xn = new int[N+1];
		xn[0] = X;
		for(int i=1;i<=N;i++) {
			xn[i] = sc.nextInt();
		}

		int[] ym = new int[M+1];
		ym[0] = Y;
		for(int i=1;i<=M;i++) {
			ym[i] = sc.nextInt();
		}

		Arrays.sort(xn);
		Arrays.sort(ym);

		if (xn[N]<ym[0]) {
			System.out.print("No War");
		} else {
			System.out.print("War");
		}

	}
}

Measured memory_bytes: 23508
#include <iostream>

using namespace std;

int main()
{
    long long int a, b, x;

    cin >> a >> b >> x;

    long long int m = a / x;
    long long int n = b / x;

    long long int ans = n - m;

    if (m * x >= a)
        ans++;

    cout << ans << endl;

    return 0;
}

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

typedef struct {
    int loc;
    int len; 
    struct {
        int min;
        int max;
    } r;
} Robot;

int cmprobot(const void *a, const void *b) {
    Robot *rba = (Robot *)a;
    Robot *rbb = (Robot *)b;
    return rba->r.max - rbb->r.max;
}

int main(void) {
    unsigned int nrobots, res = 1;
    scanf("%u", &nrobots);

    Robot robomap[nrobots];

    for(unsigned int i = 0; i < nrobots; i++) {
        int loc, len;
        scanf("%d %d", &loc, &len);
        robomap[i] = (Robot){loc, len, {loc - len, loc + len}};
    }

    qsort(robomap, nrobots, sizeof(Robot), cmprobot);

    /*
    for(int i = 0; i < nrobots; i++) {
        printf("%d: %d ~ %d\n", robomap[i].loc, robomap[i].r.min, robomap[i].r.max);
    }*/

    int base = robomap[0].r.max;
    for(int i = 1; i < nrobots; i++) {
        if(base > robomap[i].r.min) continue;
        if(robomap[i].r.max > base) base = robomap[i].r.max;
        res++;
    }

    printf("%d\n", res);
}


Measured memory_bytes: 3324