akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

string S;
ll K;

// i: 何文字目か
// j; N未満か
// k: 0が何回出て来たか
ll dp[110][2][110];

int main() {
    cin >> S >> K;
    dp[0][0][0] = 1;

    ll N = S.size();

    for (int i = 0; i < N; i++) {
        int D = S[i] - '0';

        for (int j = 0; j < 2; j++) {
            for (int k = 0; k <= K; k++) {
                int target = (j == 1 ? 9 : D);

                for (int d = 0; d <= target; d++) {
                    int cnt = 0;
                    if (d != 0) cnt++;

                    dp[i + 1][j || (d < D)][k + cnt] += dp[i][j][k];
                }
            }
        }
    }

    ll ans = 0;
    ans += dp[N][0][K];
    ans += dp[N][1][K];

    cout << ans << endl;
}

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

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

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

string t[4] = {"dreamer","eraser","erase","dream"};
string h[4] = {"dream","eraser","erase","dreamer"};

string s;

bool match(int i, int k){
  REP(j,t[k].size()){
    if(i>=s.size()) return false;
    if(s[i] != t[k][j]) return false;
    i++;
  }
  return true;
}

bool dfs(int i){
  if(i>=s.size()) return true;
  REP(j,4){
    if(match(i,j)){
      if(dfs(i+t[j].size())) return true;
    }
  }
  return false;
}


int main(){
  cin >> s;
  if(dfs(0)){
    cout << "YES" <<endl;
  }else{
    cout <<"NO"<<endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll h,w;cin>>h>>w;
    ll kk;cin>>kk;
    string s[h];rep(i,0,h-1)cin>>s[i];
    ll tot[h];
    ll b[h];
    ll ans;
    ll mini=inf;
    rep(i,0,pow(2,h-1)-1){
        rep(j,0,h-1){
            tot[j]=0;
        }
        ans=0;
        rep(j,0,h-1){
            if(j<h-1){
                if(((i>>j)&1)==1){
                    ans++;
                }
            }
        }
        bool bol=true;
        rep(j,0,w-1){
            if(ans>1010){
                bol=false;
                break;
            }
            ll c=0;
            rep(k,0,h-1){
                b[k]=tot[k];
            }
            bool bolbol=true;
            rep(k,0,h-1){
                if(s[k][j]=='1'){
                    if(b[c]+1<=kk){
                        b[c]++;
                    }else{
                        //cout<<i<<' '<<c<<' '<<b[c]<<endl;
                        j--;
                        rep(i,0,h-1){
                            tot[i]=0;
                        }
                        ans++;
                        bolbol=false;
                        break;
                    }
                }
                if(k<h-1){
                    if(((i>>k)&1)==1){
                        c++;
                    }
                }
            }
            if(bolbol){
                rep(k,0,h-1){
                    tot[k]=b[k];
                    //cout<<i<<' '<<j<<' '<<k<<' '<<b[k]<<endl;
                }
            }
        }
        if(bol){
            mini=min(ans,mini);
            //cout<<mini<<endl;
        }else{
            continue;
        }
        
    }
    cout<<mini<<endl;
    
    
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define int long long
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repr(i, a, b) for(int i = a - 1; i >= b; i--)
#define iter(m) for(auto it = m.begin(); it != m.end(); it++)
#define iterr(m) for(auto it = m.rbegin(); it != m.rend(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
signed main(){
    speed;
    int h, n; cin >> h >> n;
    vector<pair<int, int>> v(n);
    vector<int> dp(h + 1, INT_MAX);
    rep(i, 0, n) {
        cin >> v[i].first;
        cin >> v[i].second;
    }
    dp[0] = 0;
    for(int i = 0; i < h; i++) {
        if(dp[i] != INT_MAX) {
            for(int j = 0; j < n; j++) {
                int k = i + v[j].first;
                if(k > h) k = h;
                if(dp[k] > dp[i] + v[j].second) {
                    dp[k] = dp[i] + v[j].second;
                }
            }
        }
    }
    cout << dp[h] << endl;
    return 0;
}

Measured memory_bytes: 3692
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
// #include <bits/stdc++.h>
using namespace std;

#define size_t int
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define debug(x) cerr << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug1(i, x) cerr << "(" << (i) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug2(i, j, x) cerr << "(" << (i) << ", " << (j) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
template <typename T> class vec2d : public vector<vector<T>> {
public:
    vec2d(int H, int W): vector<vector<T>> (H, vector<T>(W)) {
    }
};
template <typename T> istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template <typename T> ostream& operator << (ostream& os, vector<T>& vec){
  REP(i, vec.size()) {
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0);
        // cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

signed main(signed argc, char **argv) {
  int A, B, C;
  cin >> A >> B >> C;
  cout << (B / A > C ? C : B / A) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = int(1e6) + 100;

int main() {
   // sieve
   int X;
   cin >> X;
   int prime[N];
   for (int i = 0; i < N; ++i)
     prime[i] = 1;
   prime[0] = prime[1] = 0;
   for (int p = 2; p < N; ++p) {
     if (prime[p]) {
       for (int j = 2; j * p < N; ++j)
         prime[j*p] = 0;
     }
   }
   int idx = X;
   while (!prime[idx])
     ++idx;
   cout << idx << "\n";
	return 0;
}

Measured memory_bytes: 4096
N, A = map(int, input().split())
X = [int(x) for x in input().split()]

# DPテーブルを初期化
dp = [[0] * (50*N+1) for x in range(N+1)]
dp[0][0] = 1

# ループを回す
for i in range(N):
    for k in range(N, 0, -1):
        for pt in range(50*N, 0, -1):
            if pt >= X[i]:
                dp[k][pt] += dp[k-1][pt-X[i]]

# print(dp[3])

ans = 0
for i in range(1, N+1):
    ans += dp[i][A*i]
print(ans)


Measured memory_bytes: 42476
#include <string>
#include <iostream>
#include <cstdlib>
#include <algorithm>

int main(void)
{
  std::string a, b, c;
  std::cin >> a >> b >> c;

  transform (a.begin (), a.end (), a.begin (), toupper);
  transform (b.begin (), b.end (), b.begin (), toupper);
  transform (c.begin (), c.end (), c.begin (), toupper);

  std::cout << a[0] << b[0] << c[0] << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#define Pi 3.1415926535898
#define ll long long
#define P pair <int ,int>

using namespace std;

struct Lis
{
    static inline int index_of(const std::vector<int>& as, int x)
    {
        return (int)std::distance(as.begin(), lower_bound(as.begin(), as.end(), x));
    }
    
    static std::vector<int> solve(const std::vector<int>& a) {
        const int n = (int)a.size();
        const int inf = 1 << 30;
        std::vector<int> A(n, inf);
        std::vector<int> id(n);
        for (int i = 0; i < n; ++i) {
            id[i] = (int)index_of(A, a[i]);
            A[ id[i] ] = a[i];
        }
        int m = *std::max_element(id.begin(), id.end());
        std::vector<int> b(m+1);
        for (int i = n-1; i >= 0; --i)
            if (id[i] == m) b[m--] = a[i];
        return b;
    }
};


int main(){
    cout << fixed << setprecision(15);
    int x1,y1,x2,y2,n,xs=1,ys=1;
    cin >> x1 >> y1;
    cin >> x2 >> y2;
    if(x1>x2)xs=-1,x1*=-1,x2*=-1;
    if(y1>y2)ys=-1,y1*=-1,y2*=-1;
    cin >> n;
    vector<pair<int,int>> ps;
    for(int i=0;i<n;++i){
        int x,y;
        cin >> x >> y;
        x*=xs,y*=ys;
        if(x<x1||x2<x||y<y1||y2<y)continue;
        ps.push_back({x,y});
    }
    int count = 0;
    if(ps.size() > 0)
    {
        
        std::sort(ps.begin(),ps.end());
        
        vector<int> yarray;
        for(auto e: ps)
        {
            yarray.push_back(e.second);
        }
        count = Lis::solve(yarray).size();
    }
    double val=0;
    if(std::min(y2-y1,x2-x1)+1==count){
        val+=10*acos(-1)-20;
        count--;
    }
    val+=(y2-y1+x2-x1)*100.0-(20-acos(-1)*5)*count;
    cout << val << endl;
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int ans = 0, count = 0;
    for (char c : s) {
        if (c == 'R') count++;
        else {
            ans = max(ans, count);
            count = 0;
        }
    }
    ans = max(ans, count);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <climits>
#include <cstdint>
using namespace std;

inline namespace atcoder {
    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;

    constexpr int64_t mpow(int64_t a, int64_t b, int64_t mod = 1000000007) {
        if (b <= 0) return 1; if (b == 1) return a % mod; if (b == 2) return (a * a) % mod;
        return (max(a * (b & 1), (int64_t)1) * mpow(mpow(a, b / 2, mod), 2, mod)) % mod;
    }
    constexpr int64_t mdiv(int64_t a, int64_t b, int64_t mod = 1000000007) {
        return (a * mpow(b, mod - 2, mod)) % mod;
    }
}

int main() {
    int l, r; cin >> l >> r;
    int ans = INT_MAX;
    for (int i = l % 2019; i < min(r - l + 1, 2019) + l % 2019; ++i) {
        for (int j = i + 1; j < min(r - l + 1, 2019) + l % 2019; ++j) {
            ans = min(ans, (i * j) % 2019);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a <= c && c <= b) {
    cout << min(b - c, d - c) << endl;
  }
  else if (c <= a && a <= d) {
    cout << min(b - a, d - a) << endl;
  }
  else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

void dfs(int digit, int maxi, string &s, int n) {
  if (digit == n) {
    cout << s << "\n";
    return;
  }
  rep1 (i, 0, maxi) {
    s.push_back('a' + i);
    dfs(digit + 1, max(maxi, i + 1), s, n);
    s.pop_back();
  }
}

int main(void) {
  int n;
  cin >> n;
  string s;
  dfs(0, 0, s, n);
  return 0;
}

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

int main(){
    using namespace std;
    unsigned long N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    --N;
    A = max(A, B) - min(A, B);
    B = C + D;
    puts(A <= D * N && (A + B - C * N % B) % B <= N * (D - C) ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){

  char num[10];
  int n[10];
  while( cin >> num[0] ){
    n[0] = num[0] - '0';
    for( int i = 1 ; i < 10 ; i++ ){
      cin >> num[i];
      n[i] = num[i] - '0';
    }

    int m = 9;
    while(m--){
      for( int i = 0 ; i <= m ; i++ ){
	if( n[i] + n[i+1] >= 10 ){
	  int N = (n[i] + n[i+1]) % 10;
	  n[i] = N;
	  //cout << " " << n[i] << " ";
	}
	else{
	  n[i] = n[i] + n[i+1]; 
	  // cout << " " << n[i] << " ";
	}
	//if( i == m )cout << endl;
      }
    }
    cout << n[0] << endl; 
  }
  return 0;
}

Measured memory_bytes: 1140
import heapq

n, m = map(int, input().split())
pay = sorted([[-int(i) for i in input().split()] for _ in range(n)])

res = 0
pq = []
for i in range(1, m+1):
    while pay and -pay[-1][0] <= i:
        a, b = pay.pop()
        heapq.heappush(pq, b)
    if pq:
        res -= heapq.heappop(pq)

print(res)


Measured memory_bytes: 22448
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;
int B[MAX], T[VMAX + 1];

int solve()
{
  int ans = 0;

  bool V[MAX];
  for (int i = 0; i < n; i++)
  {
    B[i] = A[i];
    V[i] = false;
  }
  sort(B, B + n);
  for (int i = 0; i < n; i++)
  {
    T[B[i]] = i;
  }
  for (int i = 0; i < n; i++)
  {
    if (V[i])
      continue;
    int cur = i;
    int S = 0;
    int m = VMAX;
    int an = 0;
    while (1)
    {
      V[cur] = true;
      an++;
      int v = A[cur];
      m = min(m, v);
      S += v;
      cur = T[v];
      if (V[cur])
        break;
    }
    ans += min(S + (an - 2) * m, m + S + (an + 1) * s);
  }
  return ans;
}

int main()
{
  cin >> n;
  s = VMAX;
  for (int i = 0; i < n; i++)
  {
    cin >> A[i];
    s = min(s, A[i]);
  }

  int ans = solve();
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3184
/*
AizuOnline A0238
Title
@kankichi573
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int t,n,s,f;
//
main()
{
        int i;

        while(EOF!=scanf("%d",&t) && t)
        {
                scanf("%d",&n);
                for(i=0;i<n;i++)
                {
                        scanf("%d %d",&s,&f);
                        t -= (f-s);
                }
                if(t <= 0)
                        printf("OK\n");
                else
                        printf("%d\n",t);
        }
        return(0);
}

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

int main() {
  string sa, sb, sc;

  cin >> sa;
  cin >> sb;
  cin >> sc;

  int i = 1, j = 0, k = 0;
  string x;
  x = sa[0];
  while (true) {
    if (i == sa.size() + 1) {
      cout << "A" << endl;
      break;
    }
    else if (j == sb.size() + 1) {
      cout << "B" << endl;
      break;
    }
    else if (k == sc.size() + 1) {
      cout << "C" << endl;
      break;
    }
    if (x == "a") {
      x = sa[i];
      i++;
    }
    else if (x == "b") {
      x = sb[j];
      j++;
    }
    else if (x == "c") {
      x = sc[k];
      k++;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
//#define int long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
const int INF=1001001001;

int n, m;
int s[5002][5002];
//?????????????????????http://imoz.jp/algorithms/imos_method.html

int solve()
{
        int ans = 0;
        rep(i,n)rep(j,i+1)s[i][j+1] += s[i][j];
        rep(i,n)rep(j,i+1) s[i+1][j] += s[i][j];
        rep(i,n)rep(j,i+1)s[i+1][j+1] += s[i][j];
		rep(i,n)rep(j,i+1)if(s[i][j])ans++;

        return ans;
}


int main()
{
          scanf("%d%d", &n, &m);
        int a, b, x;
        for (int i = 0; i < m; i++) {
                scanf("%d%d%d", &a, &b, &x);
                a--; b--;
                s[a][b]++;
                s[a][b+1]--;
                s[a+x+1][b]--;
                s[a+x+2][b+1] ++;
                s[a+x+1][b+x+2]++;
                s[a+x+2][b+x+2]--;
        }
        printf("%d\n", solve());
        return 0;
}

Measured memory_bytes: 69568
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



const int MAX_PRIME = 10000;
bool is_prime[MAX_PRIME + 1];
void sieve(int n = MAX_PRIME)
{
	fill_n(is_prime, n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i * i <= n; ++i)
	{
		if (is_prime[i])
		{
			for (int j = 2 * i; j <= n; j += i)
				is_prime[j] = false;
		}
	}
}
vector<int> make_primes(int n = MAX_PRIME)
{
	vector<int> res;
	for (int i = 2; i <= n; ++i)
		if (is_prime[i])
			res.push_back(i);
	return res;
}
int main()
{
	sieve();
	vector<int> p = make_primes();

	static int res[10000 + 1];
	for (int i = 0; i < p.size(); ++i)
	{
		int s = p[i];
		++res[s];
		for (int j = i + 1; j < p.size() && s + p[j] <= 10000; ++j)
		{
			s += p[j];
			++res[s];
		}
	}
	int n;
	while (scanf("%d", &n), n)
		printf("%d\n", res[n]);
}

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

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int t = sc.nextInt();
			int n = sc.nextInt();
			if(t == 0 && n == 0)break;
			else calc(t, n);
			
		}
	}
	public void calc(int t, int n){
		int[][] map = new int[161][161];
		for(int i = 0; i < n; i ++){
			int x = sc.nextInt() + 80;
			int y = sc.nextInt() + 80;
			map[x][y] = -1;
		}
		int x = sc.nextInt() + 80;
		int y = sc.nextInt() + 80;
		
		map[x][y] = 1;
		ArrayList<int[]> list = new ArrayList<int[]>();
		list.add(new int[]{x, y});
		
		while(!list.isEmpty()){
			x = list.get(0)[0];
			y = list.get(0)[1];
			list.remove(0);
			if(map[x][y] < t + 1){
				if(x > 0 && map[x-1][y] == 0){
					map[x-1][y] = map[x][y] + 1;
					list.add(new int[]{x-1, y});
				}
				if(x < 160 && map[x+1][y] == 0){
					map[x+1][y] = map[x][y] + 1;
					list.add(new int[]{x+1, y});
				}
				if(y > 0 && map[x][y-1] == 0){
					map[x][y-1] = map[x][y] + 1;
					list.add(new int[]{x, y-1});
				}
				if(y < 160 && map[x][y+1] == 0){
					map[x][y+1] = map[x][y] + 1;
					list.add(new int[]{x, y+1});
				}
				if(x > 0 && y > 0 && map[x-1][y-1] == 0){
					map[x-1][y-1] = map[x][y] + 1;
					list.add(new int[]{x-1, y-1});
				}
				if(x < 160 && y < 160 && map[x+1][y+1] == 0){
					map[x+1][y+1] = map[x][y] + 1;
					list.add(new int[]{x+1, y+1});
				}
			}
		}
		int sum = 0;
		for(int i = 0; i < 161; i++){
			for(int j = 0; j < 161; j++){
				if(map[i][j] <= t+1 && map[i][j] > 0) sum++;
			}
		}
		System.out.println(sum);
	}

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

Measured memory_bytes: 63832
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;

struct sushi{
    int t, d;
    bool operator<(const sushi other) const{
        return d < other.d;
    }
};

int main(){
    int n, k, t, d;
    cin >> n >> k;

    vector<sushi> v(n);
    for(int i = 0; i < n; i++){
        cin >> t >> d;
        v[i] = sushi({t, d});
    }

    sort(v.rbegin(), v.rend());

    ll ans = 0;
    vector<int> ate(n+1, 0);
    ll kind = 0, sum = 0;
    priority_queue<pair<int,int>> pq;

    for(int i = 0; i < k; i++){
        sum += v[i].d;
        ate[v[i].t]++;
        if(ate[v[i].t] == 1)    kind++;
        pq.push({-v[i].d, v[i].t});
    }

    ans = kind*kind + sum;

    for(int i = k; i < n; i++){
        sushi now = v[i];
        if(ate[now.t] != 0)    continue;
        while(!pq.empty()){
            auto p = pq.top();  pq.pop();
            if(ate[p.second] == 1)  continue;
            ate[p.second]--;
            ate[now.t]++;
            sum += p.first;
            sum += now.d;
            kind++;
            pq.push({-now.d, now.t});
            break;
        }
        ans = max(ans, kind*kind+sum);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2552
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  int gn = n;
  for (;; gn++) {
    string s = to_string(gn);
    string t = s;
    reverse(all(t));
    if (s == t) break;
  }
  int ln = n;
  for (; ln; ln--) {
    string s = to_string(ln);
    string t = s;
    reverse(all(t));
    if (s == t) break;
  }
  cout << (n - ln <= gn - n ? ln : gn) << endl;
}

Measured memory_bytes: 3240
# coding: utf-8
# Your code here!

try:
   while True:
      cards = input()
      if cards == "-": break
      m = int(input())
      
      for i in range(m):
         h = int(input())
         neworder = cards[h:len(cards)]
         for j in range(h):
            neworder += cards[j]
         cards = neworder

      print(cards)

except EOFError:
   pass


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

int main() {

    int n;
    cin >> n;

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

    int even_flag = 1;
    int num = 0; 
    while (even_flag){
        
        for (i=0; i<n; i++){
            if( a[i]%2 >= 1 ){
                even_flag = 0;
                break;
            }
            else{
                a[i] = a[i]/2;
            }
        }

        if(even_flag == 0) break;
        num++;
        //cout << num << endl;
    }

    cout << num << endl;

}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){
  ll n, m;
  cin >> n >> m;
  if (n==1ll or m==1ll) {
    cout<<1;
    return;
  }
  ll ans = n * (m/2ll);
  if (m%2ll) ans += (n+1ll)/2ll;
  cout << ans;

}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
322123


n - 1
0 ... (n-1) [res ... res] S - (n-1) ... S


 */

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(var, limit) for (int var = 0; var < (limit); var++)

void rotate(int& vx, int& vy)
{
    int x = vx, y = vy;
    vx = -y;
    vy = x;
}

int main()
{
    int x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    int vx = x2 - x1;
    int vy = y2 - y1;
    rotate(vx, vy);
    x3 = x2 + vx; y3 = y2 + vy;
    rotate(vx, vy);
    x4 = x3 + vx; y4 = y3 + vy;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}


Measured memory_bytes: 256
prize=["null","one pair","two pair","three card",
        "straight","full house","four card"]

try:
    while True:
        hand = map(int,raw_input().split(","))
        x = sorted(list(set(hand)))
        a = len(x)
        b = max([hand.count(e) for e in x])
        if b==4: p=6
        elif b==3:
            if a==2: p=5
            else: p=3
        elif b==2:
            if a==3: p=2
            else: p=1
        elif b==1:
            e = x[0]
            if x==[1,10,11,12,13] or x==range(e,e+5): p=4
            else: p=0
        print prize[p]
except:
    pass

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

typedef long long int ll;
const ll maxn = 100010;
const ll mod = 1000000007;
vector <ll> adj[maxn];
ll dp[maxn][3];

ll dfs(ll node, ll col, ll par){
    if(dp[node][col] != -1) return dp[node][col];
    ll ans = 1;
    for(auto x: adj[node]){
        if(x != par){
            if(col == 1){
                ans *= dfs(x,0,node);
                ans %= mod;
            }
            else{
                ans = ans * (dfs(x,0,node) + dfs(x,1,node));
                ans %= mod;
            }
        }
    }

    return dp[node][col] = ans;
}
int main(){
    memset(dp,-1,sizeof dp);
    ll n;
    scanf("%lld",&n);

    for(ll i = 1; i < n; i++){
        ll u,v;
        scanf("%lld %lld",&u,&v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    printf("%lld\n",(dfs(1,0,-1)+dfs(1,1,-1))%mod);
}


Measured memory_bytes: 14976
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
#define int ll
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif
 
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
 
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
 
using pi=pair<int,int>;
using vi=vc<int>;
 
template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}
 
template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}
 
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	int n,k;cin>>n>>k;
	k*=n;
	vi a(n);
	map<int,vi> idx;
	rep(i,n){
		cin>>a[i];
		idx[a[i]].pb(i);
	}
	vi w(n);
	for(auto kv:idx){
		int s=kv.b.size();
		kv.b.pb(kv.b[0]+n);
		rep(i,s){
			w[kv.b[i]]=kv.b[i+1]-kv.b[i]+1;
		}
	}
	const int inf=LLONG_MAX/3;
	const int L=60;
	vc<vi> nx{w};
	rep(_,L){
		vi&x=nx.back();
		vi y(n);
		rep(i,n)y[i]=min(inf,x[i]+x[(i+x[i])%n]);
		nx.pb(y);
	}
	int cur=0;
	per(i,L+1){
		if(cur+nx[i][cur%n]<=k)
			cur+=nx[i][cur%n];
	}
	if(cur==k)
		return 0;
	vi ans;
	set<int> has;
	rng(i,cur%n,n){
		if(has.count(a[i])){
			while(1){
				int v=ans.back();
				ans.pop_back();
				has.erase(v);
				if(v==a[i])break;
			}
		}else{
			ans.pb(a[i]);
			has.insert(a[i]);
		}
	}
	rep(i,ans.size()){
		cout<<ans[i];
		if(i<int(ans.size())-1)
			cout<<" ";
		else
			cout<<endl;
	}
}

Measured memory_bytes: 132836
MOD = 10 ** 9 + 7


def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs


def comb(n, r):
    global MOD, modFacts, invs
    return (modFacts[n] * invs[n - r] * invs[r]) % MOD


def perm(n, r):
    global MOD, modFacts, invs
    return (modFacts[n] * invs[n - r]) % MOD


N, M = map(int, input().split())
modFacts, invs = prepare(M)
ans = 0
flag = 1
for i in range(N + 1):
    a = comb(N, i)
    b = perm(M, i)
    c = pow(perm(M - i, N - i), 2, MOD)
    cnt = (a * b * c) % MOD
    ans = (ans + flag * cnt) % MOD
    flag *= -1
print(ans)


Measured memory_bytes: 95528
import heapq

n = int(input())
item = [int(i) for i in input().split()]
heapq.heapify(item)

while (len(item) != 1):
    a = heapq.heappop(item)
    b = heapq.heappop(item)
    heapq.heappush(item, (a + b) / 2)

print(item[0])


Measured memory_bytes: 3060
import heapq

N, M = map(int, input().split())
jobs = [[] for _ in range(M)]

for i in range(N):
    a, b = map(int, input().split())
    if a > M:
        continue
    jobs[M-a].append(-b)

q = []
heapq.heapify(q)

ans = 0
for i in range(M-1, -1, -1):
    for j in jobs[i]:
        heapq.heappush(q, j)
    if len(q) != 0:
        ans += q[0]
        heapq.heappop(q)

print(-ans)

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;

const ll longinf=1LL<<60 ;

vector<int> g[100005];

int main() {
    int N, M;
    cin >> N >> M;

    vector<int> P(M), Y(M);
    REP(i, M) {
        cin >> P[i] >> Y[i];
        g[P[i]].push_back(Y[i]);
    }
    REP(i, N) if(!g[i + 1].empty()) sort(all(g[i + 1]));

    REP(i, M) {
        int d = (upper_bound(all(g[P[i]]), Y[i]) - g[P[i]].begin());
        printf("%06d%06d\n", P[i], d);
    }

    return 0;
}


Measured memory_bytes: 7808
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string s;
  cin >> s;
  ll n = s.size();
  ll ans = LONG_LONG_MAX;

  rep(i, 26) {
    char c = i + 'a';
    ll mcnt = 0;
    ll tmp = 0;
    rep(j, n) {
      if (s[j] != c)
        tmp++;
      else {
        chmax(mcnt, tmp);
        tmp = 0;
      }
      if (tmp > 0) chmax(mcnt, tmp);
    }
    chmin(ans, mcnt);
  }

  cout << ans << endl;

  return 0;
}


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

const int MOD=1e9+7;

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
//-------------------------↓↓↓↓↓↓------------------------

int main(void){
    int n; cin >> n;
    int c[n + 10] = {};

    rep(i, n){
        cin >> c[i];
        if(i != 0 and c[i] == c[i - 1]){
            i--;
            n--;
        }
    }

    int dp[n + 10] = {}, be[2 * 100000 + 10] = {};
    dp[0] = 1;
    be[c[0]] = 1;
    rrep(i, 1, n){
        (dp[i] = dp[i - 1] + be[c[i]]) %= MOD;
        be[c[i]] = dp[i];
    }

    cout << dp[n - 1] << "\n"; 
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define mp make_pair
#define ins insert
#define sz size
#define whoami(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); whi(_it, args); }

void whi(istream_iterator<string> it) { cerr<<"\n"; }

template<typename T, typename... Args>
void whi(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<" "<<a<<" "; whi(++it, args...); }

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;
const ll INF = 4e18;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	int mm1 = h1 * 60 + m1;
	int mm2 = h2 * 60 + m2;
	int df = (mm2 - mm1 - k);
	cout<<df<<"\n";
	return;
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var a = ab[0];
            var b = ab[1];
            if (a < b) 
            {
                Console.WriteLine("a < b");
            }else{
                if (a > b) 
                {
                    Console.WriteLine("a > b");
                }else{
                    Console.WriteLine("a == b");
                }
            }

            
            

        }
    }
}

Measured memory_bytes: 9280
#include<stdio.h>
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  int i; 
  if(a<=b){for(i=0;i<b;i++){printf("%d",a);}}
  if(b<a){for(i=0;i<a;i++){printf("%d",b);}}return 0;
}


Measured memory_bytes: 2124
#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int n, m;

int cnt[100000];
bool maybe[100000];

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

	cin >> n >> m;
	rep(i, n)cnt[i] = 1;
	maybe[0] = true;
	rep(i, m) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		if (maybe[x]) {
			maybe[y] = true;
			if (cnt[x] == 1)maybe[x] = false;
		}
		cnt[x]--;
		cnt[y]++;
	}
	cout << count_if(maybe, maybe + n, [](bool f) {return f; }) << endl;

	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include "algorithm"
#include "math.h"
#include "vector"

typedef long long ll;

using namespace std;

void print_v(vector<ll> tmp){
    for(int i=0; i<tmp.size(); i++){
        if(i) cout << " ";
        cout << tmp[i];
    }
    cout << endl;
}

int main(){

    while(1){
    int N, M; cin >> N >> M;
    if(!N && !M) break;
    vector<ll> h(N), w(M), sh(N+1), sw(M+1);
    for(int i=0; i<N; i++){
        cin >> h[i];
        sh[i+1] = sh[i]+h[i];
    }
    for(int i=0; i<M; i++){
        cin >> w[i];
        sw[i+1] = sw[i] + w[i];
    }

    // print_v(sh);
    // print_v(sw);


    vector<ll> sa;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N+1; j++){
            sa.push_back(sh[j] - sh[i]);
        }
    }
    sort(sa.begin(), sa.end());
    // print_v(sa);

    ll ans = 0;
    for(int i=0; i<M; i++){
        for(int j=i+1; j<M+1; j++){
            ll tmp = sw[j] - sw[i];
            ll a = distance(sa.begin(), lower_bound(sa.begin(), sa.end(), tmp));
            ll b = distance(sa.begin(), upper_bound(sa.begin(), sa.end(), tmp));
            // cout << tmp << "," << a << "," << b << endl;
            ans += b - a;
        }
    }

    cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 27860
n = int(input())
s = input()

freq = {'R': 0, 'G': 0, 'B': 0}
for x in s:
    freq[x] += 1

ans = freq['R'] * freq['G'] * freq['B']
for i in range(n-2):
    for j in range(i+1, n-1):
        k = j + (j-i)
        if k < n and s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            ans -= 1

print(ans)


Measured memory_bytes: 9176
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int gcd(long long int a, long long int b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

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

	cin >> N >> M >> L >> R;
	long long int ans = 0;
	ans = M - N + 1;
	ans -= M / L;
	ans += (N - 1) / L;
	ans -= M / R;
	ans += (N - 1) / R;
	L = L / gcd(L, R)*R;
	ans += M / L;
	ans -= (N - 1) / L;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    double s = 0;
    for (int i = 0; i < n; ++i)
    {
        int a;
        cin >> a;
        s += 1.0 / a;
        
    }
    printf("%.10f\n",(1.0/s));
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var i int
	fmt.Scan(&i)

	arr := scanNums(i)

	sort.Ints(arr)

	i1 := arr[i/2-1]
	i2 := arr[i/2]

	fmt.Println(i2 - i1)
}

func scanNums(len int) []int {
	var num int
	nums := make([]int, 0, len)
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return nums
}


Measured memory_bytes: 5504
const MOD: usize = 998244353;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner(s.lock());
    let n: usize = sc.read();
    let s = sc.chars();

    let mut red = vec![];
    let mut green = vec![];
    let mut blue = vec![];
    for (i, c) in s.iter().cloned().enumerate() {
        match c {
            'R' => red.push(i),
            'G' => green.push(i),
            'B' => blue.push(i),
            _ => unreachable!(),
        }
    }

    let mut left = vec![];
    let mut center = vec![];
    let mut right = vec![];
    for i in 0..n {
        let mut x = [red[i], blue[i], green[i]];
        x.sort();

        left.push(x[0]);
        center.push(x[1]);
        right.push(x[2]);
    }

    let mut ans = 1;
    let mut head = 0;
    for (i, &c) in center.iter().enumerate() {
        while head < n && left[head] < c {
            head += 1;
        }
        ans *= head - i;
        ans %= MOD;
    }

    let mut head = 0;
    for (i, &c) in center.iter().rev().enumerate() {
        while head < n && right[n - 1 - head] > c {
            head += 1;
        }
        ans *= head - i;
        ans %= MOD;
    }

    for i in 0..n {
        ans *= i + 1;
        ans %= MOD;
    }

    println!("{}", ans);
}

pub struct Scanner<R>(R);

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 16636