akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

int main() {
    std::size_t N, M;
    std::cin >> N >> M;

    std::vector<std::pair<std::size_t, std::size_t>> salary;
    salary.reserve(N);

    for (std::size_t i = 0; i < N; ++i) {
        std::size_t A, B;
        std::cin >> A >> B;
        salary.push_back(std::make_pair(A, B));
    }

    std::sort(salary.begin(), salary.end(), [](const auto& left, const auto& right) {
        if (left.first != right.first) {
            return left.first < right.first;
        } else {
            return left.second > right.second;
        }
    });

    std::size_t sum = 0, pos = 0;
    std::priority_queue<std::size_t> queue;
    for (std::size_t i = 1; i <= M; ++i) {
        while (pos < N) {
            if (salary[pos].first > i) {
                break;
            }
            queue.push(salary[pos].second); 
            ++pos;
        }
        if (!queue.empty()) {
            sum += queue.top();
            queue.pop();
        }
    }

    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const int MX = 300005;
int n, a[MX], cn[MX], s[MX], res[MX];

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

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		cn[a[i]]++;
	}
	sort(cn + 1, cn + n + 1);

	for (int i = 1; i <= n; i++)
		s[i] = s[i-1] + cn[i];

	for (int i = 1; i <= n; i++) {
		int j = lower_bound(cn + 1, cn + n + 1, i) - cn;
		int x = n - j + 1;
		x += s[j - 1] / i;
		res[x] = max(res[x], i);
	}

	for (int i = n - 1; i; i--)
		res[i] = max(res[i], res[i+1]);

	for (int i = 1; i <= n; i++)
		cout << res[i] << endl;

	return 0;
} 

Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  int l = 1;
  int r = N;
  for (int i = 0; i < M; i++) {
    int L, R;
    cin >> L >> R;
    l = max(l, L);
    r = min(r, R);
  }
  cout << max(0, r-l+1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <numeric>
using namespace std;

int main() {
	int n, h, w;
	cin >> n >> h >> w;
	cout << (n - w + 1) * (n - h + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std ;
template< class T > inl T read() {
	T x = 0 ; int f = 1 ; char k = getchar() ;
	for( ; k > '9' || k < '0'; k = getchar() ) if( k == '-' ) f = -1 ;
	for( ; k >= '0' && k <= '9'; k = getchar() ) x = x * 10 + k - '0' ;
	return x * f ;
}
template< class T > inl T read( T &x ) { return x = read<T>() ; }
int _num, _buf[20];
template< class T > il print( T x ) {
   	if( x == 0 ) return putchar( '0' ) ,void() ;
	if( x < 0 ) putchar( '-' ), x = -x ;
	while( x ) _buf[++_num] = x % 10, x /= 10 ;
	while( _num ) putchar( _buf[_num--] + '0' ) ;
}
ll mul( ll a, ll b, ll mod ) { long double c = 1. ; return ( a * b - (ll)( c * a * b / mod ) * mod ) % mod ; }
it qpow( int x, int m, int mod ) {
	int res = 1, bas = x ;
	while(m) {
		if( m & 1 ) res = ( 1ll * res * bas ) % mod ;
		bas = ( 1ll * bas * bas ) % mod, m >>= 1 ;
	}
	return res ;
}
const int N = 5e5 + 5, M = N * 40 ;
int n, q, lst[N], pre[N], col[N];
int num, rt[N], cnt[M], lc[M], rc[M];
il Build( int &cur, int l, int r ) {
	cur = ++num ;
	if( l == r )
		return ;
	Build( lc[cur], l, mid ) ;
	Build( rc[cur], mid + 1, r ) ;
}
il Insert( int &cur, int cmp, int l, int r, int pos ) {
	cur = ++num, lc[cur] = lc[cmp], rc[cur] = rc[cmp], cnt[cur] = cnt[cmp] + 1 ;
	if( l == r )
		return ;
	if( mid >= pos )
		Insert( lc[cur], lc[cmp], l, mid, pos ) ;
	else
		Insert( rc[cur], rc[cmp], mid + 1, r, pos ) ;
}
it Query( int cur, int l, int r, int L, int R ) {
	if( l >= L && r <= R )
		return cnt[cur] ;
	int res = 0 ;
	if( mid >= L )
		res += Query( lc[cur], l, mid, L, R ) ;
	if( R > mid )
		res += Query( rc[cur], mid + 1, r, L, R ) ;
	return res ;
}
int main() {
//	freopen( ".in", "r", stdin ) ;
//	freopen( ".out", "w", stdout ) ;
	n = read<int>(), q = read<int>() ;
	for( ri i = 1; i <= n; ++i ) {
		col[i] = read<int>() ;
		pre[i] = lst[col[i]] ;
		lst[col[i]] = i ;
	}
	Build( rt[0], 0, n - 1 ) ;
	for( ri i = 1; i <= n; ++i )
		Insert( rt[i], rt[i - 1], 0, n - 1, pre[i] ) ;
	for( ri i = 1; i <= q; ++i ) {
		int l = read<int>(), r = read<int>() ;
		print( Query( rt[r], 0, n - 1, 0, l - 1 ) - Query( rt[l - 1], 0, n - 1, 0, l - 1 ) ), puts( "" ) ;
	}
	cerr << 1. * clock() / CLOCKS_PER_SEC << "\n" ;
	return 0;
}

Measured memory_bytes: 136764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  bool issat = true;
  vector<int> v(N);
  rep(i,N) cin >> v[i];
  reverse(all(v));
  int pre = MAX_I;
  rep(i,N){
    if(v[i] <= pre) pre = v[i];
    else if(v[i]-1 == pre) pre = v[i] - 1;
    else{
      issat = false;
      break;
    }
  }
  YesNo(issat);
  return 0;
}


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

int main() {
  int x,y; cin >> x >> y;
  string ans = "No";
  // yが偶数
  if(y%2==0) {
    // yが2xと4xの間
    if(2*x<=y && y<=4*x) ans = "Yes";
  }
  cout << ans << endl;
}


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

bool operator<(const string&a,const string&b) {
   int n=a.size(),m=b.size();
   if(b[0]=='$')return false;
   if(n<m)return true;
   if(n>m)return false;
   if(a<=b)return true;
   return false;
}
signed main()
{
   int N, M; cin >> N >> M;
   set<int> A;
   for(int i = 0; i < M; i++) {
      int a; cin >> a;
      A.insert(a);
   }
   vector<int> num{-1,2,5,5,4,5,6,3,7,6};
   vector<string> dp(N+1, "$");  // dp[i]: the max string using i matches.
                                 //        '$' represents impossible string.
   dp[0] = "";
   for(int i = 0; i < N; i++) {
      for(auto a: A) {
         if (i + num[a] <= N && dp[i + num[a]] < dp[i] + to_string(a)) {
            dp[i + num[a]] = dp[i] + to_string(a);
         }
      }
   }
   cout << dp[N] << endl;
   return 0;
}


Measured memory_bytes: 33024
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define ll long long
#define hh puts("")
#define pc putchar
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
using namespace std;
int n,C,ans;
char s[105];
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-ff;ch=getchar();}
    while(isdigit(ch)){ret=(ret<<3)+(ret<<1)+ch-'0';ch=getchar();}
    return ret*ff;
}
void write(int x){
    if(x<0){x=-x;putchar('-');}
    if(x>9) write(x/10);
    putchar(x%10+48);
}
void writeln(int x){write(x),hh;}
void writesp(int x){write(x),pc(' ');}
signed main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++){
		if(s[i]=='C') C=1;
		if(s[i]=='F'&&C) ans=1;
	}
	printf(ans?"Yes":"No");
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for ( int i=0; i<n; i++ ) {
        cin >> a[i];
    }
    int ans=100100100;
    for ( int x=-100; x<=100; x++ ) {
        int res=0;
        for ( int i=0; i<n; i++ ) {
            res+=(x-a[i])*(x-a[i]);
        }
        ans=min(ans,res);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int mod = 1000000007;
const int N = 21;

int n;
int a[N][N];
int dp[N][1<<N];
int dfs(int d, int mask){
    if(d==n) return 1;
    if(dp[d][mask]>=0) return dp[d][mask];

    int ret = 0;
    rep(i,n)if(!(mask>>i&1) && a[d][i]){
        int nmask = mask|(1<<i);
        (ret += dfs(d+1, nmask)) %= mod;
    }

    return dp[d][mask] = ret;
}

int main(){
    cin >>n;
    rep(i,n)rep(j,n) cin >>a[i][j];

    memset(dp,-1,sizeof(dp));
    cout << dfs(0,0) << "\n";
    return 0;
}


Measured memory_bytes: 172416
#define _CRT_SECURE_NO_WARNINGS
#include <array>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    const char *None = "None";

    array<int, 26> A;
    A.fill(0);

    char S[100001];
    if (scanf("%s", S) < 1) return 0;

    int len = strlen(S);

    for (int i = 0; i < len; i++) A[S[i] - 'a']++;

    bool flg = true;
    for (int i = 0; i < 26; i++)
    {
        if (A[i] == 0)
        {
            printf("%c\n", 'a' + i);
            flg = !flg;
            break;
        }
    }

    if (flg) printf("%s\n", None);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char n = scanner.next().charAt(0);
        if (Character.isUpperCase(n)) {
            System.out.println("A");
        } else {
            System.out.println("a");
        }
    }
}

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

int main(void) {
  long long a, b, v, w, t;
  cin >> a >> v;
  cin >> b >> w;
  cin >> t;

  long long amin = a - t * v;
  long long amax = a + t * v;
  long long bmin = b - t * w;
  long long bmax = b + t * w;

  string result = (amin <= bmin && bmax <= amax) ? "YES" : "NO";
  cout << result << endl;
  return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  printf("%d\n", 800 * n - (n / 15) * 200);

  return 0;
}


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

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) FOR((i),0,(n))

typedef long long ll;

const int INF=1e9+7;

bool is_ok(string s,int i,int j){
	bool ans=true;
	rep(k,s.size()-i){
		bool f=false;
		rep(l,i+1)if(s[k+l]-'a'==j)f=true;
		ans&=f;
	}
	return ans;
}

int data[30];
int main(){
	string s;
	cin>>s;
	int ans=105;
	rep(i,s.size())rep(j,30)if(is_ok(s,i,j))ans=min(ans,i);
	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string stra;
string strb;
string strc;

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

  cin>>stra;
  cin>>strb;
  cin>>strc;

  char now=stra[a];
  a++;

  while(1){

    if(now=='a'){
      if(stra.size()==a){
	cout<<"A"<<endl;
	return 0;
      }
      now=stra[a];
      a++;
    }

    else if(now=='b'){
      if(strb.size()==b){
	cout<<"B"<<endl;
	return 0;
      }
      now=strb[b];
      b++;
    }

    else if(now=='c'){
      if(strc.size()==c){
	cout<<"C"<<endl;
	return 0;
      }
      now=strc[c];
      c++;
    }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        String s = inp.nextLine();

        letterCase(s);
    }

    public static void letterCase(String c) {
        String s = "";
        String[] list = c.split(", ");

        for (int j = 0; j < list.length; j++) {
            for (int i = 0; i < list[j].length(); i++) {
                String tempCh = list[j].charAt(i) + "";
                if (tempCh.equals(tempCh.toUpperCase())) {
                    s += tempCh.toLowerCase();
                } else {
                    s += tempCh.toUpperCase();
                }
            }

            if (j != list.length-1) {
                s += ", ";
            }
        }
        System.out.println(s);
    }

}



Measured memory_bytes: 32076
#include <stdio.h>
#include <stdlib.h>
 
#define newTree() ((PTREE)calloc(1, sizeof(TREE)))
 
int code[128] = { 0 };
 
typedef struct _tree {
    int flag;
    struct _tree *list[4];
} TREE, *PTREE;

void insert(PTREE root, char *str) {
    int i = code[(int)*str];
    if (*str == '\0') {
        root->flag = 1;
        return;
    }
    if (root->list[i] == NULL) {
        root->list[i] = newTree();
    }
    insert(root->list[i], str + 1);
}
 
int find(PTREE root, char *str) {
    int i = code[(int)*str];
    if (*str == '\0') {
        return root->flag;
    }
    if (root->list[i] == NULL) {
        return 0;
    }
    return find(root->list[i], str + 1);
}
 
int main(void) {
    int i, n;
    char cmd[20], str[20];
    PTREE root = newTree();
    code['A'] = 0;
    code['C'] = 1;
    code['G'] = 2;
    code['T'] = 3;
     
    scanf("%d", &n);
     
    for (i = 0; i < n; ++i) {
        scanf("%s %s", cmd, str);
        if (cmd[0] == 'i') {
            insert(root, str);
        } else if (find(root, str)) {
            printf("yes\n");
        } else {
            printf("no\n");
        }
    }
     
    return 0;
}

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

#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 INF 1e9


int main(){ 
  int N;
  cin >> N;
  vector<int> A(N);
  int cnt_odd = 0;
  REP(i, N){
    cin >> A[i];
    if(A[i] % 2){
      cnt_odd++;
    }
  }
  if(cnt_odd % 2){
    cout << "NO" << endl;
  }
  else{
    cout << "YES" << endl;
  }

  return 0;
}



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

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

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

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

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

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

void main()
{
    long N, M;
    scan(N, M);
    auto ab = new Point2[](N);
    auto cd = new Point2[](M);

    foreach (i; 0 .. N)
    {
        long a, b;
        scan(a, b);
        ab[i] = Point2(a, b);
    }
    foreach (i; 0 .. M)
    {
        long a, b;
        scan(a, b);
        cd[i] = Point2(a, b);
    }
    // writeln(cd);
    foreach (i; 0 .. N)
    {
        long dist = long.max;
        long ans;
        foreach (j; 0 .. M)
        {
            long d = abs(ab[i].x - cd[j].x) + abs(ab[i].y - cd[j].y);
            if (d < dist)
            {
                dist = d;
                ans = j;
            }
        }
        writeln(ans + 1);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 998244353  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n, s;
  cin >> n >> s;
  vecll a(n);
  REP(i, n) { cin >> a[i]; }
  vector<vector<ll>> dp(n + 1, vecll(s + 1, 0));
  vecll p2(n + 1, 1);
  REP(i, n) {
    p2[i + 1] = p2[i] * 2LL;
    p2[i + 1] %= MOD;
  }
  REP(i, n) {
    REP(j, s + 1) {
      dp[i + 1][j] = 2LL * dp[i][j];
      dp[i + 1][j] %= MOD;
    }
    if (a[i] <= s) {
      dp[i + 1][a[i]] += p2[i] % MOD;
      dp[i + 1][a[i]] %= MOD;
    }
    REP(j, s + 1) {
      if (j == 0) {
        continue;
      }
      if (j - a[i] >= 0) {
        dp[i + 1][j] += (dp[i][j - a[i]]) % MOD;
      }
      dp[i + 1][j] %= MOD;
    }
  }
  // REP(i, n + 1) {
  //   cout << "i = " << i << endl;
  //   REP(j, s + 1) { cout << dp[i][j] << endl; }
  // }
  cout << dp[n][s] << endl;
}
//////////////////////////////////////////////


Measured memory_bytes: 73640
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n+1],a2[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        a2[a[i]]=i;
    }
    for(int i=1;i<=n;i++){
        cout<<a2[i];
        if(i<n){
            cout<<" ";
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VII vector< vector<int> >
#define VLL vector< vector<LL> >
#define VS  vector<string>
#define VSS vector< vector<string> >
#define PII pair<int,int>
#define PIS pair<int,string>
#define PSI pair<string,int>
#define PLL pair<LL,LL>
const LL MOD = 1000000007;
const LL INF = 1e16;
LL facctorialMethod(int k);
int main(){
    LL n, i, j, k;
    cin >> n;
    map<LL, LL> data;
    for(i=1; i<=100; i++){
        for(j=1; j<=100; j++){
            for(k=1; k<=100; k++){
                data[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }
    
    for(i=1; i<=n; i++){
        cout<<data[i]<<endl;
    }

    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


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

int main() {
  int k;
  cin>>k;
  int x=0,y=0;
  for(int i=1;i<=k;i++)
  {
      if(i%2==0)
        x++;
  }
   for(int i=1;i<=k;i++)
  {
      if(i%2!=0)
        y++;
  }
  cout<<x*y;
  return 0;
}


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

#define int long long
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
int H, W;

int dp[66][33][2];  // dp[i][j][k]=マス(i,j)に足kを置くための最短時間
char A[101][101];
int dist[66][33][2][66][33][2];
void init() {
    REP(i, H) REP(j, W) REP(k, 2) REP(x, H) REP(y, W) REP(l, 2) { dist[i][j][k][x][y][l] = 1e9; }
    REP(i, H) REP(j, W) REP(k, 2) {
        dp[i][j][k] = 1e9;
        // dist[i][j][k][i][j][k] = 0;
    }
}
int dijkstra(int x, int y, int foot) {
    REP(i, H) REP(j, W) REP(k, 2) REP(x, H) REP(y, W) REP(l, 2) { dist[i][j][k][x][y][l] = 1e9; }
    REP(i, H) REP(j, W) REP(k, 2) {
        dp[i][j][k] = 1e9;
        // dist[i][j][k][i][j][k] = 0;
    }
}
using arr4 = array<int, 4>;
bool solve() {
    cin >> W >> H;
    if (W == 0) return false;
    REP(i, H) {
        REP(j, W) { cin >> A[i][j]; }
    }
    init();
    REP(i, H) REP(j, W) REP(k, 2) {
        if (A[i][j] == 'X') continue;
        if (k == 0) {
            REP(x, H) FOR(y, j + 1, W) {
                int l = 1;
                if (A[x][y] == 'X') continue;
                int cost = 0;
                if (isdigit(A[x][y])) {
                    cost = A[x][y] - '0';
                }
                if (abs(x - i) + abs(y - j) <= 3) {
                    dist[i][j][k][x][y][l] = cost;
                }
            }
        } else {
            int l = 0;
            REP(x, H) REP(y, j) {
                if (A[x][y] == 'X') continue;
                int cost = 0;
                if (isdigit(A[x][y])) {
                    cost = A[x][y] - '0';
                }
                if (abs(x - i) + abs(y - j) <= 3) {
                    dist[i][j][k][x][y][l] = cost;
                }
            }
        }
    }
    priority_queue<arr4, vector<arr4>, greater<arr4>> que;
    REP(j, W) {
        if (A[H - 1][j] == 'S') {
            REP(k, 2) {
                dp[H - 1][j][k] = 0;
                que.push({0, H - 1, j, k});
            }
        }
    }
    while (!que.empty()) {
        arr4 ar = que.top();
        que.pop();
        int res = ar[0], i = ar[1], j = ar[2], k = ar[3];
        if (res > dp[i][j][k]) continue;
        REP(x, H) REP(y, W) REP(z, 2) {
            if (res + dist[i][j][k][x][y][z] < dp[x][y][z]) {
                dp[x][y][z] = res + dist[i][j][k][x][y][z];
                que.push({dp[x][y][z], x, y, z});
            }
        }
    }
    int ans = 1e9;
    REP(j, W) {
        if (A[0][j] == 'T') {
            REP(k, 2) { ans = min(ans, dp[0][j][k]); }
        }
    }
    if (ans >= 1e9)
        cout << -1 << endl;
    else
        cout << ans << endl;
    // REP(i, H) {
    //     REP(j, W) { cout << A[i][j] << " "; }
    //     cout << endl;
    // }
    return true;
}
signed main() {
    while (solve())
        ;
}


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

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());

            var d = new Dictionary<string, long>();
            for(var i = 0; i < n; i++){
                var s = Console.ReadLine().Trim();
                if(d.ContainsKey(s)){
                    d[s] += 1;
                }else{
                    d.Add(s, 1);
                }
            }

            Console.WriteLine(d.Count());
        }
    }
}


Measured memory_bytes: 50512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N,M;
ll L;

vector<pair<int,ll>> g[303];
vector<int> v[303];

ll dist[303][303];
ll ans[303][303];
const ll INF=1e15;

void dijkstra(int st){
  rep(i,N) dist[st][i]=INF;
  dist[st][st]=0;
  priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> PQ;
  PQ.push(mkp(0,st));
  while(!PQ.empty()){
    auto f=PQ.top();
    PQ.pop();

    int now=f.second;
    ll c=f.first;
    if(dist[st][now]<c) continue;
    if(c>L) break;
    for(int i=0;i<g[now].size();i++){
      int nex=g[now][i].first;
      ll neco=g[now][i].second;
      if(dist[st][nex]>dist[st][now]+neco){
        dist[st][nex]=dist[st][now]+neco;
        PQ.push(mkp(dist[st][nex],nex));
      }
    }
  }
}

void dijk(int st){
  rep(i,N) ans[st][i]=INF;
  ans[st][st]=0;
  priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> PQ;
  PQ.push(mkp(0,st));
  while(!PQ.empty()){
    auto f=PQ.top();
    PQ.pop();

    int now=f.second;
    ll c=f.first;
    if(ans[st][now]<c) continue;
    for(int i=0;i<v[now].size();i++){
      int nex=v[now][i];
      int neco=1;
      if(ans[st][nex]>ans[st][now]+neco){
        ans[st][nex]=ans[st][now]+neco;
        PQ.push(mkp(ans[st][nex],nex));
      }
    }
  }
}

int main(){
  cin>>N>>M>>L;
  rep(i,M){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    g[a].push_back(mkp(b,c));
    g[b].push_back(mkp(a,c));
  }

  rep(i,N) dijkstra(i);

  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(dist[i][j]<=L){
        v[i].push_back(j);
        v[j].push_back(i);
      }
    }
  }

  rep(i,N) dijk(i);
  
  int Q;
  cin>>Q;
  rep(i,Q){
    int s,t;
    cin>>s>>t;
    s--;t--;
    if(ans[s][t]==INF) cout<<-1<<endl;
    else cout<<ans[s][t]-1<<endl;
  }




  return 0;
}


Measured memory_bytes: 4864
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <bitset>
#include <utility>
#include <assert.h>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
#define tm tmp
//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
const int MAX=5e4+1000;
//const ll MAXN=2e8;
const int MAX_N=MAX;
const ll MOD=1e9+7;
//const long double pi=acos(-1.0);
//const double eps=0.00000001;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
void open()
{
//    freopen("1009.in","r",stdin);
    freopen("out.txt","w",stdout);
}
int a,b,c,d,e,f,now,now2,now3,now4;
double an;
int num1,num2;
int main()
{
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    an=0;
//    num1=num2=0;
    num1=100*a;num2=0;
    double rat=1.0*e/(e+100.0);//不可比此大
    for(int i=0;i*a*100<=f;i++)
    {
        now=i*a*100;
        for(int j=0;now+j*b*100<=f;j++)
        {
            now3=j*b*100+now;//总水
            for(int s=0;s*c+now3<=f;s++)
            {
                now2=s*c;
//                int cnt=(now2+e-1)/e;
//                double tem=1.0*now2/(now3+now4);
//                if(tem>rat)break;
                if(now2*100>now3*e)break;
//                if()
//                    if(cnt*100.0>1.0*now3)break;//水不够
                for(int w=0;w*d+now3+now2<=f;w++)
                {
                    now4=now2+w*d;
                    if(now4*100>now3*e)break;
//                    int cnt=(now4+e-1)/e;
////                    tem=1.0*now4/(1.0*now4+1.0*now3);
//                    if(tem>rat)break;

//                    if(cnt*100.0>1.0*now3)break;//水不够
                    else
                    {
                        double tem=1.0*now4/(now3+now4);
                        if(an<tem)
                        {
                            an=tem;num1=now3+now4;num2=now4;
                        }
                    }
                }
            }
        }
    }
    printf("%d %d\n",num1,num2);
    return 0;
}

/*
1000000000000000000
*/


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

const int MAX_M = 1000, MAX_N = 12;
const ll INF = TEN(10);
int n,m;
int a[MAX_M];
int c[MAX_M];
ll dp[MAX_M+1][1<<MAX_N];

int main()
{
  fastio();

  cin >> n >> m;
  forn(i,m) {
    int b;
    cin >> a[i] >> b;
    int temp = 0;
    forn(j,b) {
      int x; cin >> x;
      temp |= 1<<(x-1);
    }
    c[i] = temp;
  }

  for (int i = 0; i <= m; i++) {
    for (int j = 0; j < (1<<n); j++) {
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < (1<<n); j++) {
      chmin(dp[i][j], dp[i-1][j]);
      chmin(dp[i][j | c[i-1]], dp[i-1][j] + a[i-1]);
    }
  }

  ll ans = dp[m][(1<<n)-1];
  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans << endl;

  return 0;
}


Measured memory_bytes: 32256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#include <bitset>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
#define double long double
using namespace std; const int N=1000010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch-'0'), ch=getchar();
    return s*w;
}
void print(int x) { if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
int n,res; char s[400010];
signed main()
{
    n=read();
    scanf("%s",s+1);
    int a,b; a=b=0;
    for(ri int i=1;i<=n;i++)
    {
        if(s[i]=='R') a++;
        else b++;
    }
    for(ri int i=n;i>=n-b+1;i--) if(s[i]=='W') res++;
    printf("%lld\n",b-res);
    return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, s1, s2, s3;
  cin >> a;
  s1 = a / 100;
  s2 = (a - s1 * 100) / 10;
  s3 = a - s1 * 100 - s2 * 10;
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  lines = [input().strip() for _ in range(int(input()))]
  types = [(int(s[0] == 'B'), int(s[-1] == 'A')) for s in lines]
  count = sum(s.count('AB') for s in lines)

  before = sum(t[0] for t in types)
  after = sum(t[1] for t in types)

  if (0, 1) not in types:
    before -= 1

  if (1, 0) not in types:
    after -= 1

  before = max(before, 0)
  after = max(after, 0)

  print(count + min(before, after))


if __name__ == '__main__':
  main()



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

long long n, m;
vector<int> cnt;

void solve();

int main() {
  cin >> n >> m;
  cnt.assign(n + 1, 0);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    ++cnt[a], ++cnt[b];
  }
  bool res = 1;
  for (int i = 1; i <= n; ++i) res &= !(cnt[i] & 1);
  if (res)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 640
// B - Papers, Please
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n, x, ok = 1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		if (x % 2 == 0 && (x % 3 != 0 && x % 5 != 0)) ok = 0;
	}

	cout << (ok ? "APPROVED" : "DENIED") << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<cassert>
#include<functional>
#include<string>
#include<cassert>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<set>
#include<cctype>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int n, l, q, x[100011], m[100011][18];
ll d[100011];

ll go(int a, int b) {
 if (a > b) swap(a, b);
 ll ans = 0;

 int k = 17;
 while (a < b) {
  for (; k > 0 && m[a][k] >= b; k--);
  a = m[a][k];
  ans += 1LL<<k;
 }

 return ans;
}

inline int Next(int i) {
 int le = i+1, ri = n, ret = i+(i<n);
 while (le <= ri) {
  int mid = (le + ri) >> 1;
  int d = x[mid] - x[i];
  if (d <= l) ret = mid, le = mid+1;
  else ri = mid-1;
 }
 return ret;
}

int main()
{
 scanf("%d", &n);
 for (int i = 1; i <= n; i++) scanf("%d", x+i);
 scanf("%d%d", &l, &q);

 for (int i = 1; i <= n; i++) {
  m[i][0] = Next(i);
 }

 for (int j = 1; j <= 17; j++) {
  for (int i = 1; i <= n; i++)
   m[i][j] = m[m[i][j-1]][j-1];
 }

 for (int i = 1; i <= q; i++) {
  int u, v; scanf("%d%d", &u, &v);
  printf("%lld\n", go(u, v));
 }

 return 0;
}


Measured memory_bytes: 8192
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iterator>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n; cin >> n;
  
  vector<int> vc(n);
  
  rep(i, n) cin >> vc[i]; 
  
  // 累積和
  vector<int> s(n+1, 0);
  for (int i = 0; i < n; ++i) s[i+1] = s[i] + vc[i];
  
  // 区間 [left, right) の総和を求める
  int left, right;
  
  int res;
  rep(i, n) {
    if (i == 0) continue;
    
    // 左側
    int left = 0;
    int right = i;
    
    int sum1 = s[right] - s[left];
    
    // 右側
    left = i;
    right = n;
    
    int sum2 = s[right] - s[left];
    
    if (i == 1) {
      res = abs(sum1-sum2);
    } else {
      res = min(res, abs(sum1-sum2));
    }
  }
  
  cout << res;
  
}

Measured memory_bytes: 256
s = str(input())
alist = ["dream", "dreamer", "erase", "eraser"]
ans = False

def backwards(x):
  return x[::-1]
s = backwards(s)
alist = [backwards(i) for i in alist]

t = ""
start = 0
for i in range(len(s)+1):
  if s[start:i] in alist:
    t+=s[start:i]
    start = i
if s==t:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 9220
import math

N=int(input())
listA = list(map(int, input().strip().split()))
saisyou=listA[N]
saidai=listA[N]
i=N-1
k=0
count=1
kiroku = 1
listsum=0
while k<=N:
  listsum=listsum+listA[k]
  k=k+1

while i>=0:
  saisyou = math.ceil(saisyou/2)+listA[i]
  i=i-1
if(saisyou != 1):print(-1)
#print(saisyou)
if(saisyou == 1):
  i=0
  while i<N:
    listsum=listsum-listA[i]
    kiroku = min(2*(kiroku-listA[i]),listsum)
    count = count+kiroku
    i=i+1
  print(count)


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

#define ll long long
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;

int main() {
   string s;
   cin >> s;
   string t = s[0] + string(s.size()-1, '9');
   ll a = stoll(s), b = stoll(t);
   ll sum = s[0] - '0' + (s.size() - 1)*9;

   if (a == b) {
      cout << sum << endl;
   } else {
      cout << sum -1 << endl;
   }

   return 0;
}

Measured memory_bytes: 256
#include <cstdio>
const int MAXN = 1e5+5;
bool good[MAXN];
int H[MAXN];
int a, b, M, N;

int main() {
  scanf(" %d%d", &N, &M);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &H[i]);
    good[i] = true;
  }
  for (int i = 0; i < M; ++i) {
    scanf(" %d%d", &a, &b);
    good[a] &= (H[a] > H[b]);
    good[b] &= (H[b] > H[a]);
  }
  int ret = 0;
  for (int i = 1; i <= N; ++i) {
    if (good[i]) ++ret;
  }
  printf("%d\n", ret);
  return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll N, X;
	cin >> N >> X;
	vector<ll> L(N);
	rep(i, N) cin >> L[i];

	ll ans = 0;
	ll cur = 0;
	for(ll i = 0; i < N; i++) {
		if(cur <= X) {
		ans++;
		}
		cur += L[i];
	}
		if(cur <= X) {
		ans++;
		}
	cout << ans << endl;
}



Measured memory_bytes: 3640
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_asc(const void* a, const void* b) {
    return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_i64_desc(const void* a, const void* b) {
    return *((int64_t*)a) > * ((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
    return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
    return *((char*)a) > * ((char*)b) ? -1 : 1;
}

static size_t powSz(const size_t base, const size_t exp) {
    if (exp == 0) {
        return 1;
    }

    if (exp == 1) {
        return base;
    }

    if (exp % 2 == 0) {
        return powSz(base * base, exp / 2);
    }
    else {
        return base * powSz(base, exp - 1);
    }
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    uint64_t N;

    scanf("%"PRIu64, &N);

    uint64_t maxH = 0;
    bool ableToAdjust = true;

    for (uint64_t i = 0; i < N; i++) {
        uint64_t H;
        scanf("%"PRIu64, &H);

        if (0 <= i && H + 1 < maxH) {
            ableToAdjust = false;
            break;
        }

        if (maxH < H) {
            maxH = H;
        }
    }

    puts(ableToAdjust ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b<c){
        cout<<"NA"<<endl;
    }
    else if(a<c){
        cout<<c-a<<endl;
    }
    else if(a>c){
        cout<<"0"<<endl;
    }
}


Measured memory_bytes: 3116
program probB
  implicit none
  character(len=200000) :: S, T
  integer :: i, c
  read(*,*) S, T

  c = 0
  do i = 1, len_trim(S)
     if (S(i:i) /= T(i:i)) then
        c = c + 1
     end if
  end do
  write(*,'(i0)') c
  stop
end program probB


Measured memory_bytes: 3556
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
int main() {
	int n, k;
	cin >> n >> k;
	vector<int>a(n);

	rep(i, k) {
		int d;
		cin >>d;
		rep(j, d) {
			int buffer;
			cin >> buffer;
			a[buffer-1]++;
		}
	}
	int c(0);
	rep(i, n) {
		if (a[i] == 0) {
			++c;
		}
	}
	cout << c;

	return 0;
}

Measured memory_bytes: 3624
// Problem : B - Distance 
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Delete the dynamically allocated memory

#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define pr              pair<long long,long long>
#define mp(a,b)         make_pair(a,b)
#define vr              vector<long long>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define fill(a,b)       memset(a, b, sizeof(a))
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)
ll power(ll base, ll exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base);
       base=(base*base);
       exp/=2;
    }
    return res;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	ld d;
	cin>>n>>d;
	ll cnt=0;
	while(n--){
		ld x,y;
		cin>>x>>y;
		ld v=sqrt((x*x)+(y*y));
		if(v<=d){
			cnt++;
		}
	}
	cout<<cnt<<"\n";
	return 0;
	}

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

struct card
{
  int n;
  int p;
  char c;
} typedef card;

card A[100000];
int stableFlag = 0;

int Partition(int p, int r)
{
  int i, j;
  card tmp;

  i = p - 1;
  for(j = p; j < r; j++)
    {
      if(A[j].n <= A[r].n)
	{
	  i = i + 1;
	  tmp = A[i];
	  A[i] = A[j];
	  A[j] = tmp;
	}
    }
  tmp = A[i + 1];
  A[i + 1] = A[r];
  A[r] = tmp;
  
  return i + 1;
}

void QuickSort(int p, int r)
{
  int q;

  if(p < r)
    {
      q = Partition(p, r);
      QuickSort(p, q - 1);
      QuickSort(q + 1, r);
    }
}

int StableOrNot(int n)
{
    int i;
    
    for(i = 0; i < n; i++)
    {
        if(A[i].n == A[i + 1].n &&
           A[i].p >= A[i + 1].p) return 0;
    }
    return 1;
}

int main()
{
  int i;
  int n;

  scanf("%d", &n);
  for(i = 0; i < n; i++)
    {
      while(1)
        {
        A[i].c = getchar();
        if(A[i].c != ' ' && A[i].c != '\n') break;
        }
      A[i].p = i + 1;
      scanf("%d", &A[i].n);
    }

  QuickSort(0, n - 1);

  if(StableOrNot(n) == 1) printf("Stable\n");
  else printf("Not stable\n");
  for(i = 0; i < n; i++)
    {
      printf("%c %d\n", A[i].c, A[i].n);
    }

  return 0;
}

Measured memory_bytes: 1784
def n_gram(s, n):
	return [s[i:i+n] for i in range(len(s)-n+1)]

s = input()
k = int(input())

subs = set()
for k_i in range(1, k+1):
	subs = subs | set(n_gram(s, k_i))
print(sorted(subs)[k-1])

Measured memory_bytes: 4872
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::*;
use std::ops::*;
use std::*;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused)]
fn rl() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused)]
fn rw<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|word| T::from_str(word).unwrap())
        .collect()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

#[allow(unused)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = &[
                $((
                    &stringify!($arg).to_string() as &fmt::Debug,
                    &($arg) as &fmt::Debug,
                )),*
            ];
            eprintln!("{:?}", DebugMap(entries));
        }
    };
}

#[allow(unused)]
struct DebugMap<'a>(&'a [(&'a fmt::Debug, &'a fmt::Debug)]);

impl<'a> std::fmt::Debug for DebugMap<'a> {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        let mut m = fmt.debug_map();
        for &(key, value) in self.0.iter() {
            m.entry(key, value);
        }
        m.finish()
    }
}

// -----------------------------------------------
// Polyfill
// -----------------------------------------------

#[derive(PartialEq, Eq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

#[allow(unused)]
macro_rules! eprintln {
    ($($arg:expr),*) => { _eprintln(format_args!($($arg),*)) }
}

fn _eprintln(args: fmt::Arguments) {
    let err = std::io::stderr();
    let mut err = err.lock();
    err.write_fmt(args).unwrap();
    err.write(b"\n").unwrap();
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn f(mut n: i64) -> i64 {
    let mut i = 0;
    loop {
        if n > 0 && n % 2 == 0 {
            i += 1;
            n /= 2;
        } else {
            return i;
        }
    }
}

pub fn main() {
    let w = rw::<i64>();
    let A = w[0];
    let B = w[1];
    let C = w[2];

    let d = f(max(A, B) - min(A, B));
    let e = f(max(B, C) - min(B, C));
    let n = if A % 2 != 0 || B % 2 != 0 || C % 2 != 0 {
        0
    } else if min(d, e) == 0 {
        -1
    } else {
        min(d, e)
    };
    println!("{}", n);
    return;
}

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

    #[test]
    fn test_ok() {
        assert_eq!(7, 1 + 2 * 3);
    }
}


Measured memory_bytes: 4352
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),h=s.nextInt(),w=s.nextInt(),r=0;
		for(int i=0;i<n;++i) {
			boolean b=s.nextInt()>=h;
			boolean c=s.nextInt()>=w;
			if(b&&c)
				++r;
		}
		System.out.println(r);
	}
}


Measured memory_bytes: 25172