akhauriyash/Code-Regression huggingface dataset:
/*
author: Apoorv Singh
*/

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

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }

double pi = 3.14159265358979323846264338327950288419716939937510582097494459230;
int modulo = 1e9 + 7;

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n; cin >> n;
    int arr[n];
    FOR(i,0,n) cin >> arr[i];
    sort(arr, arr+n);
    int a = arr[(n-1)/2];
    int b = arr[n/2];
    cout << (b-a);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int main(){
int n,x;
cin >> n;
//n = 333;

for(int i = 1; i<=n; i++){
    if(i%3 ==0 || i%10 == 3){
          cout << ' ' << i;
    }else{
          x = i;
          while(x/10 !=0){
                 x /= 10;
                 if(x%10 == 3){
                      cout << ' ' << i;
                      break;
                 }
          }
     }
}
cout << endl;
return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define MOD 2019
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int ct[2019], nct[2019];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	ct[0] = 1;
	int cur = 0;
	ll ans = 0;
	for(int i = 0; i < s.length(); i++){
		cur = (cur * 10 + (s[i] - '0')) % MOD;
		memset(nct, 0, sizeof(nct));
		for(int j = 0; j < 2019; j++){
			nct[j * 10 % MOD] += ct[j];
		}
		for(int j = 0; j < 2019; j++){
			ct[j] = nct[j];
		}
		ans += ct[cur];
		ct[cur]++;
	}
	cout << ans << '\n';
}

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

#define DEBUG 1

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
  #define DFUNC(fname, ...) fname(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFUNC(fname, ...)
#endif

ll N, K;

long double dmax(long double x, long double y) {
  if (x < y) { return y; }
  else { return x; }
}

ll ceilJ(ll j) {
  ll pow = 1 << j;
  return min(N+1, (K + (pow-1)) / pow);
}

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> N >> K;

  long double sum = dmax(0.0, (long double)(N+1 - K) / (long double)N);
  long double p = 0.5;
  for (ll j = 1; 1; j++) {
    long double thisX = (long double)(ceilJ(j-1) - ceilJ(j)) / (long double)N;
    if (ceilJ(j) == 1 && ceilJ(j-1) == 1) break;
    long double thisY = p * thisX;
    DLOG("%lld, %Lf, %Lf\n", j, thisX, thisY);
    sum += thisY;

    p *= 0.5;
  }
  printf("%5.18Lf\n", sum);
  return 0;
}



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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int h, w, n;
    cin >> h >> w >> n;
    int arr[100100];
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    int ret[110][110];
    int color = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (i % 2)
                ret[i][j] = color + 1;
            else
                ret[i][w - j - 1] = color + 1;
            arr[color]--;
            if (arr[color] == 0)
                color++;
        }
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cout << ret[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 512
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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

  int N; cin>>N;
  vi A(N-1),B(N-1);
  REP(i,N-1) {
    cin>>A[i]>>B[i];
    A[i]--;B[i]--;
  }

  vvi eg(N);
  map<pii, int> col;
  vector<pii> vec;
  REP(i,N-1) {
    eg[A[i]].push_back(B[i]);
    eg[B[i]].push_back(A[i]);
    col[pii(A[i],B[i])] = -1;
    col[pii(B[i],A[i])] = -1;
    vec.push_back(pii(A[i],B[i]));
  }

  queue<int> que;
  que.push(0);
  int colMax = 0;
  vb vis(N, false);
  while(!que.empty()) {
    int x = que.front(); que.pop();
    vis[x] = true;
    int cl = 1;

    set<int> cs;
    for(int nx : eg[x]) {
      if (col[pii(x,nx)]>0) cs.insert(col[pii(x,nx)]);
    }

    for(int nx : eg[x]) {
      if (vis[nx]) continue;
      
      while (cs.count(cl)>0) cl++;

      col[pii(x,nx)] = cl;
      col[pii(nx,x)] = cl;
      colMax = max(colMax, cl);
      cs.insert(cl);
      cl++;
      que.push(nx);
    }
  }

  cout << colMax << endl;  
  for(pii v : vec) cout << col[v] << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e2 + 5;
const int M = 1e5 + 5;

ll n, W, w[N], v[N], dp[M];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    cin >> n >> W;

    for (int i = 0; i < n; ++i)
        cin >> w[i] >> v[i];

    for (int i = 0; i < n; ++i)
        for (int j = W; j >= w[i];--j)
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);

    cout << dp[W] << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
#include <map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>
 
class DisjointSet {
    public:
    std::vector<int> p;
    DisjointSet() {}
    DisjointSet(int n){
        p.resize(n, 0);
        for(int i = 0; i < n; i++){
            p[i] = i;
        }
    }
    
    bool same(int x, int y){
        return findSet(x) == findSet(y);
    }
    
    int findSet(int x){
        if(x != p[x]){
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
    
    void unite(int x, int y){
        link(findSet(x), findSet(y));
    }
    
    void link(int x, int y){
        p[y] = x;
    }
};

const int MAX_N = 200050;
const int MAX_K = 100050;

int N, K, L;
int p[MAX_K], q[MAX_K], r[MAX_K], s[MAX_K];

DisjointSet ds1 = DisjointSet(MAX_N);
DisjointSet ds2 = DisjointSet(MAX_N);
 
int main(void){
    std::cin >> N >> K >> L;

    for (int i = 1; i <= K; i++) {
        std::cin >> p[i] >> q[i];
    }
    for (int i = 1; i <= L; i++) {
        std::cin >> r[i] >> s[i];
    }
    
    for(int i = 1; i <= K; i++){
        if(!ds1.same(p[i], q[i])) ds1.unite(p[i], q[i]);
    }
    
    for(int i = 1; i <= L; i++){
        if(!ds2.same(r[i], s[i])) ds2.unite(r[i], s[i]);
    }
    
    std::map<std::pair<int, int>, int> S;
    for(int i = 1; i <= N; i++){
        S[std::pair<int, int>({ds1.findSet(i), ds2.findSet(i)})] += 1;
    }
    
    for(int i = 1; i <= N; i++){
        std::cout << S[std::pair<int, int>({ds1.findSet(i), ds2.findSet(i)})] << " ";
    }
    std::cout << std::endl;
    
    return 0;
}

Measured memory_bytes: 15104
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll MOD3=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

map<ll,ll> M;


int main(){
    ld N,A,B,v[107],T=0,dp[107][107],i,j;
    ld sum=0;
    cin >> N >> A >> B;

    rep(i,N+1){
    dp[i][0]=1;
  }
  dp[1][1]=1;
  Rep(i,2,N+1){
    rep(j,N+1){
      if(i<j){
        break;
      }
      if(j>0){
        dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
      }
    }
  }

    rep(i,N){
        cin >> v[i];
        M[v[i]]++;
    }
    sort(v,v+(int)N);
    reverse(v,v+(int)N);
    rep(i,A){
        sum+=v[i];
        if(A!=N){
            if(v[i]==v[i+1]){
                T++;
            }
            else{
                T=0;
            }
        }
    }
    ld ave=sum/A;
    if(A==N){
        cout << stpr(10) << ave << endl;
        cout << 1 <<  endl;
        return 0;
    }
    cout << stpr(10) << ave << endl;
    if(v[0]!=v[(int)A]){
        cout << dp[M[v[(int)A-1]]][(ll)T] << endl;
        return 0;
    }
    ll C=0;
    Rep(i,A,min((ll)B,(ll)M[v[0]])+1){
        C+=dp[M[v[0]]][i];
    }
    cout << C << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for(int i = 0; i < N; ++i){
		cin >> a[i];
		--a[i];
	}
	int cnt = 0;
	for(int i = 0; i < N; ++i){
		if(a[a[i]] == i){
			++cnt;
		}
	}
	cout << cnt / 2 << endl;
	return 0;
}


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

int main()
{
    int n;scanf("%d",&n);
    string st,st1,st2="";cin>>st>>st1;
    for(int i=0;i<n;i++){
        st2+=st[i];st2+=st1[i];
    }
    cout<<st2;
    return 0;
}

Measured memory_bytes: 256
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = n / 500 * 1000;
    n %= 500;
    ans += n / 5 * 5;
    cout << ans << endl;
    return 0;

}



Measured memory_bytes: 256
n,m = map(int, input().split())
wa = [0]*n
ac = [0]*n
for i in range(m):
    p,s = input().split()
    p = int(p)
    if ac[p-1]==1 :
        continue
    else:
        if s == 'AC':
           ac[p-1]+=1
        else :
            wa[p-1]+=1            

for i in range(n):
    if ac[i]==0:
        wa[i] = 0

print(sum(ac), sum(wa))

Measured memory_bytes: 4596
#include<iostream>

using namespace std;

int main() {

    int house[4][3][10] = {0};

    int n;

    std::cin >> n;

    for(int i = 0; i < n; i++) {
        int b, f, r, v;
        std::cin >> b >> f >> r >> v;

        house[b - 1][f - 1][r - 1] += v;
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                std::cout << " " << house[i][j][k];
            }
            std::cout << endl;
        }
        if (i != 3) {
            std::cout << "####################" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3100
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< int > A(N);
	vector< int > C(1e5 + 10, 0);
	rep(i, N) cin >> A[i];
	rep(i, N) {
		C[A[i]]++;
	}
	int l = 0, r = C.size() - 1;
	int ans = N;
	while (l <= r) {
		while (l < C.size() && C[l] <= 1)
			++l;
		while (r >= 0 && C[r] <= 1)
			--r;
		if (l < C.size())
			ans -= 2;
		else
			break;
		C[l]--;
		C[r]--;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int a = 0, b = 0, k = 0, i = 0, x = 0, s = 0;
    cin >> a >> b >> k;
    for(i = a; i <= b; i++)
    {
        cout << i << endl;
        x++;
        if(x == k)
        {
            break;
        }
    }
    if(b - k + 1 > a + k - 1)
    {
        s = b - k + 1;
    }
    else
    {
        s = a + k;
    }

    for(i = s; i <= b; i++)
    {
        cout << i << endl;
    }


return 0;
}

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

typedef long long ll;
typedef pair<double, int> ticket_index;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  ll a[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  priority_queue<ticket_index> que;
  double price_array[n];
  for(int i = 0; i < n; i++) {
    que.push(ticket_index((double) a[i], i));
    price_array[i] = (double) a[i];
  }
  for(int i = 0; i < m; i++) {
    ticket_index ti = que.top();
    que.pop();
    int index = ti.second;
    double price = ti.first;
    double new_price = price / 2.0;
    price_array[index] = new_price;
    que.push(ticket_index(new_price, index));
  }
  ll sum = 0;
  for(int i = 0; i < n; i++) {
    sum +=  (ll) price_array[i];
  }
  cout << sum << "\n";
  return 0;
}





Measured memory_bytes: 3700
// 参考 -> 提出 #4178631

import java.util.Scanner;

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

        int d = sc.nextInt();
        int g = sc.nextInt();
        int[] p = new int[d];
        int[] c = new int[d];

        for (int i = 0; i < d; i++) {
            p[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        System.out.println(dfs(p, c, g, 0, 0, 0, new boolean[d]));
    }

    // 引数(p, c, g, score:現在のスコア, cnt:今まで解いた問題数, point:今調べている問題, isCheck:利用した問題)
    static int dfs(int[] p, int[] c, int g, int score, int cnt, int point, boolean[] isCheck) {
        int min = 100000;

        for (int i = 0; i < p.length; i++) {
            if (isCheck[i])     // すでに利用済みの問題はスキップ
                continue;

            int needScore = g - score;      // 目標値に必要な値
            int num = (i + 1) * 100;    // １問ごとの得点
            // 目標値に到達するために解く必要のある問題数
            int needNum = needScore / num + (needScore % num == 0 ? 0 : 1);

            // 必要な問題数が足りる場合、今まで解いた数に足せばいい
            if (needNum <= p[i]) {
                min = Math.min(min, cnt + needNum);
            }
            // ボーナススコアを合わせることで目標値に到達できるならば、すべて解く
            else if (num * p[i] + c[i] >= needScore) {
                min = Math.min(min, cnt + p[i]);
            }
            // さらに深く探索
            else {
                isCheck[i] = true;
                min = Math.min(min, dfs(p, c, g, score + num * p[i] + c[i], cnt + p[i], i+1, isCheck));
                isCheck[i] = false;
            }
        }

        return min;
    }
}


Measured memory_bytes: 21972
#include<iostream>
using namespace std;
int main() {

	int r, c;

	cin >> r >> c;

	int ans[101][101] = {0};
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> ans[i][j];
		}
	}

	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			ans[i][c] += ans[i][j];
		}
	}
	for (int j = 0; j < c; j++) {
		for (int i = 0; i < r; i++) {
			ans[r][j] += ans[i][j];
		}
	}
	for (int i = 0; i < c; i++) {
		ans[r][c] += ans[r][i];
	}

	for (int i = 0; i <= r; i++) {
		for (int j = 0; j <= c; j++) {
			cout << ans[i][j];
			if (j != c)cout << " ";
		}
		cout << endl;
	}
	return 0;

}



Measured memory_bytes: 3136
program main
	implicit none
    integer(8)::n
    read(*,*)n
    if(mod(n,2)==0)then
    	write(*,*) 0.5
    else if(n==1)then
    	write(*,*) 1
    else
    	write(*,*) (n/2 +1)/real(n,8)
    end if
    stop
end program main


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

int main() {
  
  int n;
  cin >> n;
  
  while (n) {
      vector<int> s(n,0);
      int sum = 0;
      for (int i=0; i<n; i++) {
          cin >> s.at(i);
          sum += s.at(i);
      }
      double m = (double)sum/n;
      double a2=0;
      for (int i=0; i<n; i++) {
          a2 += (s.at(i) - m)*(s.at(i) - m)/n; 
      }
      double a = sqrt(a2);
      printf("%.10f\n", a);
      
      cin >> n;
  }
  
  return 0;
}




Measured memory_bytes: 3148
S = input()
ans=0
for i in range(1<<len(S)-1):
    f =S[0]
    for j in range(len(S)-1):
        if i &(1<<j):
            f +="+"
        f +=S[j+1]
    ans += sum(map(int, f.split("+")))
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

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

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 50;

int main() {
	int n;cin>>n;
	string s[N],x;
	int t[N];
	rep(i,n) cin>>s[i]>>t[i];
	cin>>x;
	int i=0;
	while(s[i]!=x) i++;
	i++;
	int ans=0;
	while(i<n){
		ans+=t[i];
		i++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
"""
author : halo2halo
date : 8, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

week = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
date = readline().decode('utf8').rstrip()

print(len(week)-week.index(date))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    deque<int> q;
    int flag = 1;
    rep(i,n) {
        int x; cin >> x;
        if (flag == 1) q.push_front(x);
        else q.push_back(x);
        flag *= -1;
    }
    if (flag == -1) {
        while (!q.empty()) {
            int x = q.front(); q.pop_front();
            cout << x << " ";
        }
        cout << endl;
    } else {
        while (!q.empty()) {
            int x = q.back(); q.pop_back();
            cout << x << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 2944
/**
 *    author:  FromDihPout
 *    created: 2020-07-29
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int sum = 0;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    
    if (sum % 10 != 0) {
        cout << sum << '\n';
    }
    else {
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if ((sum - a[i]) % 10 != 0) {
                ans = max(ans, sum - a[i]);
            }
        }
        cout << ans << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 3636
A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())

print(A[K-1])

Measured memory_bytes: 3060
def find_even(text):
    chars = list(text)
    tail_index = (len(chars) + 1) // 2
    pre = 0
    while tail_index > 0:
        tail_index -= 1
        pre = 0
        post = tail_index
        while chars[pre] == chars[post]:
            pre += 1
            post += 1
            if pre == tail_index:
                return 2 * tail_index
    raise("Error")

if __name__ == "__main__":
    # run_test(find_even, test_pair)
    print(find_even(raw_input()))

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    
    set<int> water_set, sugar_set;

    //water
    for(int i=0;i<30;i++){
        for(int j=0;j<=30;j++){
            if(i==0&&j==0) continue;
            int w = 100*a*i+100*b*j;
            if(w>f)break;
            if(w<=f)water_set.insert(w);
        }
    }

    //sugar
    for(int i=0;i<=3000;i++){
        for(int j=0;j<=3000;j++){
            int s = c*i+d*j;
            if(s>f)break;
            if(s<=f)sugar_set.insert(s);
        }
    }
    
    double maxratio = -1.0;
    int sw=0,s=0;
    for(int x:water_set){
        for(int y:sugar_set){
            if(x+y>f)break;
            if((x/100)*e<y)break;
            double ratio = (double)y/(x+y);
            if(maxratio<ratio){
                maxratio = ratio;
                sw = (x+y);s = y;
            }
        }
    }
    cout << sw << " " << s << endl;
    return 0;
}  


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	int x = n / 100;
	if (x * 100 + x * 10 + x < n) ++x;
	cout << x * 100 + x * 10 + x << endl;
}

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

int main()
{
	long long q, h, s, d, n, jwb;
	cin >> q >> h >> s >> d >> n;
	h = min(h, 2*q);
	s = min(s, 2*h);
	d = min(d, 2*s);
	jwb = d*(n/2)+s*(n%2);
	cout << jwb << endl;
	return 0;
}

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

int main() {
//fast io
  ios::sync_with_stdio(0);
    cin.tie(0);
    int k, n;
    cin >> k >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int d = a[0] + k - a[n - 1];
    for (int i = 0; i < n - 1; i++) {
        d = max(d, a[i + 1] - a[i]);
    }
    cout << k - d << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPP(i, n) for(int i = 1; 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 ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;

int main() {
    int n, m; cin >> n >> m;
    int x = (n-m)*100 + 1900*m;
    int p = pow(2,m);
    int ans = x*p;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int N, K;
string S, T;

int a[110] = {};
int b[110] = {};
int c[200010] = {};
int d[200010] = {};

bool last;

int main()
{
	cin >> S >> T;
	int N = S.size();

	for (int i = 0; i < N; i++)
	{
		a[S[i] - 'a']++;
		b[T[i] - 'a']++;
	}
	//入れ終わる

	//a[i]は0がaでそこからなんこあるか
	for (int i = 0; i < 26; i++)
	{
			c[a[i]]++;
			d[b[i]]++;
	}

	for (int i = 0; i < N; i++)
	{
		if (c[i] != d[i])
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define MODD 1000000007
#define ll long long
using namespace std;

int main() {
    int N,M;
    cin>>N>>M;
    string ans;
    for(int i=0;i<N;i++)
        for(int j=0;j<M;j++)
        {
            string S;
            cin>>S;
            if (S=="snuke") {
                printf("%c%d\n",j+'A',i+1);
            }
        }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        while (n > 0) {
            if (n - 1000 <= 0) {
                System.out.println(1000 - n);
                return;
            }
            n -= 1000;
        }
    }
}

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

using namespace std;
int solve(int ind,vector<int>&dp,vector<vector<int> >&G){
   // cout << ind << " "<<dp[ind] <<endl;
   if(dp[ind]!= -1){
    return dp[ind];
   }
   dp[ind]=1;
   for(int i=0;i<(int)G[ind].size();++i){
      int val=G[ind][i];
        dp[val]=solve(val,dp,G);
   }
   for(int i=0;i<(int)G[ind].size();++i)
    dp[ind]=max(dp[ind],1+dp[G[ind][i]]);
   return dp[ind];
}
int main()
{
    int n,m;
    cin >> n>> m;
    vector<vector<int> >G(n+1);
    for(int i=0;i<m;++i){
        int x,y;
        cin >> x >> y;
        G[x].push_back(y);
    }
    vector<int>dp(n+1,-1);
    for(int i=1;i<=n;++i){
        if(dp[i]==-1){
            dp[i]=solve(i,dp,G);
        }
    }
    int ans=1;
    for(int i=1;i<=n;++i){
        if(dp[i]>ans)
            ans=dp[i];
    }
    cout << ans-1 <<endl;
    return 0;

}


Measured memory_bytes: 11932
[x1,y1,x2,y2] = [int(i) for i in input().split()]

vector = [x2 - x1, y2 - y1]
vector_t = [y1 - y2,x2 - x1]
x3 = x2 + vector_t[0]
y3 = y2 + vector_t[1]
x4 = x3 - vector[0]
y4 = y3 - vector[1]

print(x3,y3,x4,y4)


Measured memory_bytes: 38384
// Try AtCoder
/// author: Leonardone @ NEETSDKASU
import std.stdio    : readln, writeln;
import std.string   : chomp;
import std.array    : split;
import std.conv     : to;
import std.typecons : Tuple;
import std.math     : abs;

auto getVals(T)() { return readln.chomp.split.to!(T[]); }

void main() {
    Tuple!(int,"x",int,"a",int,"b") t = getVals!int()[0..3];
    writeln(abs(t.x - t.a) < abs(t.x - t.b) ? "A" : "B");
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
B.append(0)
ans = 0
for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
    else:
        ans += A[i]
        if A[i+1] <= B[i]-A[i]:
            ans += A[i+1]
            A[i+1] = 0
        else:
            ans += B[i]-A[i]
            A[i+1] -= B[i]-A[i]

print(ans)


Measured memory_bytes: 24028
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
using ll=long long;

int main(){
    ll N, K;
    cin >> N >> K;
    ll one;
    
    for(ll i = 0; i < N; ++i){
        ll tmp1;
        cin >> tmp1;
        if(tmp1 == 1) one = i;
    }
    if((N - 1) % (K - 1) == 0) cout << (N - 1) / (K - 1) << endl;
    else cout << (N + K - 2) / (K - 1) << endl;
    /*if(N == K) cout << "1" << endl;
    else if (N - one < K || one + 1 > K) cout << (N + 1) / (K - 1) << endl;
    else cout << (N + 2 * K - 5) / (K - 1) << endl;*/
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; cin >> N; 
	long long A[100010], B[100010]; 
	bool MA[100010], MB[100010]; 
	long long X[200010]; 
	for(int i = 0; i < N; i++){
		cin >> A[i] >> B[i]; 
		X[i*2] = A[i]; X[i*2+1] = B[i];  
	}
	if(N == 2){
		cout << min(A[0], B[1]) + min(A[1], B[0]) << endl; 
		return 0; 
	}
	sort(X, X+N*2); 
	long long border = X[N];
	int num = N - (lower_bound(X, X+N*2, border) - X);  
	for(int i = 0; i < N; i++){
		if(A[i] < border) MA[i] = true; 
		else if(A[i] == border && num > 0){
			MA[i] = true; num--; 
		}
		if(B[i] < border) MB[i] = true; 
		else if(B[i] == border && num > 0){
			MB[i] = true; num--; 
		}
	}
	long long ans = 0; 
	int SS = 0; int SL = 0; int LS = 0; int LL = 0; 
	for(int i = 0; i < N; i++) ans += X[i]; 
	for(int i = 0; i < N; i++){
		if(MA[i] && MB[i]) SS++; 
		else if(MA[i] && !MB[i]) SL++; 
		else if(!MA[i] && MB[i]) LS++; 
		else if(!MA[i] && !MB[i]) LL++;
	}
	if(SS > 0 || SL == N || LS == N){
		cout << ans << endl; return 0; 
	}
	if(X[N] == X[N-1]){
		if(X[N+1] == border || X[N-1] == border){
			cout << ans << endl; return 0;  
		}
		int cnt[100010] = {}; 
		for(int i = 0; i < N; i++){
			if(A[i] == border) cnt[i] ++; 
			if(B[i] == border) cnt[i] ++; 
			if(cnt[i] == 2){
				cout << ans + min(X[N+1] - X[N-1], X[N] - X[N-2]) << endl; 
				return 0; 
			} 
		}
		cout << ans << endl; return 0; 
	}
	if(X[N] == X[N+1] || X[N-1] == X[N-2]){
		cout << ans + X[N] - X[N-1] << endl; 
	}
	for(int i = 0; i < N; i++){
		if((A[i] == X[N] || A[i] == X[N-1]) && (B[i] == X[N] || B[i] == X[N-1])){ 
			cout << ans + min(X[N+1] - X[N-1], X[N] - X[N-2]) << endl; 
			return 0; 
		}
	}
	cout << ans + X[N] - X[N-1] << endl; 
}

Measured memory_bytes: 3584
/*input
6 5
1 2 -1000000000
2 3 -1000000000
3 4 -1000000000
4 5 -1000000000
5 6 -1000000000	
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (int)(lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=1005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

ll dp[maxn];

vector<pair<pii,ll>> edge;


void cal(){
	for(auto i:edge){
		dp[i.F.S]=max(dp[i.F.S],dp[i.F.F]+i.S);
	}
}

int main(){
	IOS;
	int n,m;
	cin>>n>>m;
	REP(i,m){
		int u,v,d;
		cin>>u>>v>>d;
		u--;v--;
		edge.eb(MP(u,v),d);
	}
	REP(i,n) dp[i]=-INF64;
	dp[0]=0;

	REP(i,m+2) cal();
	ll ans=dp[n-1];
	REP(i,m+2) cal();
	if(dp[n-1]!=ans){
		cout<<"inf\n";
	}
	else{
		cout<<ans<<'\n';
	}

	return 0;
}


Measured memory_bytes: 384
/*
  coded by: mi_ni_
  "LIVE LONG AND PROSPER"
*/
 
#include <bits/stdc++.h>
using namespace std;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define newl '\n'
#define TEST_CASE(fun) int tc; cin>>tc; while(tc--){ fun(); }
#define TEST_CASE_2 int tc; cin>>tc; for(int i=1;i<=tc;i++)
#define TEST_CASE_3(fun) int tc; cin>>tc; for(int i=1;i<=tc;i++){ cout<<"Case #"<<i<<": "; fun(); }
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define forab(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define forabr(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define trav(i,x) for(auto& i:x)

using ll=long long int;
using ull=unsigned long long int;
using ld=long double;
using pii=pair<int, int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using vii=vector<pii>;
using vll=vector<pll>;

const ld pi=acosl(-1);
const int inf=(int)1e9+7;
const ll llinf=(ll)1e18+7;
const ld eps=1e-7;

//other
template<typename T> inline bool powerof2(T a){ return (a&&(!(a&(a-1)))); }
template<typename T> inline T log_2(T a){ T res=-1; while(a){ a/=2; res++; } return res; }

//make sure to choose TEST_CASE in main for multiple test cases
void solve(){
	int n;
	ld d;
	cin>>n>>d;
	int x,y,cnt=0;
	while(n--){
		cin>>x>>y;
		if(sqrtl(powl(x,2)+powl(y,2))<=d) cnt++;
	}
	cout<<cnt<<newl;
}

int main(){
	FAST_IO
	cout<<fixed<<setprecision(15);
	cerr<<fixed<<setprecision(10);
	//init_fact();
	//TEST_CASE(solve)
	//TEST_CASE_2{}
	//TEST_CASE_3(solve)
	solve();
	return 0;
}

Measured memory_bytes: 3800
N = int(input())
P = list(map(int,input().split()))
count = 0
minlist = []

for i,p in enumerate(P) :
    if i == 0 :
        minlist.append(p)
        continue

    if p < minlist[i-1] :
        minlist.append(p)
    else:
        minlist.append(minlist[i-1])
    
for i,p in enumerate(P) :
    pj_min = minlist[i]
    if p <= pj_min :
        count += 1
    
print(count)

Measured memory_bytes: 32296
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramB
    {
        static void Main()
        {
            int n = NextInt, d = NextInt;
            var matrix = TakeLine(n).ToArray();
            int count = 0;

            for (int i = 0; i < n; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    long tmp = matrix[i].Zip(matrix[j], (x, y) => (x - y) * (x - y)).Sum();
                    long sqrt = MyMath.Sqrt(tmp);
                    if (sqrt * sqrt == tmp) count++;
                }
            }

            System.Console.WriteLine(count);
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}
namespace Library
{
    class MyMath
    {
        public static long Gcd(long a, long b)
        {
            return b == 0 ? a : Gcd(b, a % b);
        }

        public static long Sqrt(long n)
        {
            if (n < 0) return 0;
            long a = 0, tmp = 0, b = 0;
            for (int i = 62; i >= 0; i -= 2)
            {
                tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0;
                a = a << 1 | tmp;
                n -= (((b << 1) + 1) * tmp) << i;
                b = (b << 1) + tmp + tmp;
            }
            return a;
        }

        public static long Nck(int n, int k)
        {
            if (k == 0) return 1;
            if (n == 0) return 0;
            return n * Nck(n - 1, k - 1) / k;
        }
    }
}


Measured memory_bytes: 13652
#include <stdio.h>

void north (int *d) {
    int tmp;

    tmp=d[0];
    d[0]=d[1];
    d[1]=d[5];
    d[5]=d[4];
    d[4]=tmp;
}

void east (int *d) {
    int tmp;

    tmp=d[0];
    d[0]=d[3];
    d[3]=d[5];
    d[5]=d[2];
    d[2]=tmp;
}

void curl (int *d) {
    int tmp;

    tmp=d[1];
    d[1]=d[2];
    d[2]=d[4];
    d[4]=d[3];
    d[3]=tmp;
}

int compare(int *d1, int *d2) {
    int i=0, n=0;

    for (i=0;i<6;i++) {
        if (d1[i]==d2[i]) n++;
    }
    return n;
}

int main(void) {
    int d1[6], d2[6];
    int i, j, n=0;

    scanf("%d %d %d %d %d %d", &d1[0], &d1[1], &d1[2], &d1[3], &d1[4], &d1[5]);
    scanf("%d %d %d %d %d %d", &d2[0], &d2[1], &d2[2], &d2[3], &d2[4], &d2[5]);
    for (i=0;i<6;i++) {
        for (j=0;j<6;j++) if (d1[i]==d2[j]) n++;
    }
    if (n<6) {
        printf("No\n");
        return 0;
    }
    while (d1[0]!=d2[0]) {
        north(d2);
        if (d1[0]==d2[0]) {
            break;
        } else {
            east(d2);
        }
    }
    while (d1[1]!=d2[1]) curl(d2);    
    for (i=0;i<7;i++) {
        n=compare(d1, d2);
        if (n==6) break;
        north(d2);
        n=compare(d1, d2);
        if (n==6) break;
        east(d2);
        n=compare(d1, d2);
        if (n==6) break;
    }

    if (n==6) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}



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


int main(){
	int A, B, C;
	cin >> A >> B >> C;
	for(int i = 0; i < B; ++i){
		if((A*i)%B==C) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}












Measured memory_bytes: 3632
export class Main {
  static main(input: string): string {
    const mod = Math.pow(10, 9) + 7;
    const tmp: string[] = input.split("\n");
    const [n, k]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    let min = ((k - 2) * (k - 1) / 2) % mod;
    let max = ((n + (n - (k - 2))) * (k - 1) / 2) % mod;
    let result = 0;
    for (let i = k, len = n + 1; i <= len; i++) {
      min = (min + (i - 1)) % mod;
      max = (max + (n - (i - 1))) % mod;
      let t = max - min + 1;
      let diff = t < 0 ? mod + t : t;
      result = (result + diff) % mod;
    }
    return `${result}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 33180
#include <algorithm>
#include <iostream>

using namespace std;

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

    int N;
    cin >> N;
    if (N % 2 == 0) {
        cout << N << endl;
    } else {
        cout << N * 2 << endl;
    }
}


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



int main() {
  int N;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
    
  int mae=0;
  int usi=0;
  for(int i=0;i<N;i++){
    usi+=vec.at(i);
  }
  int dis=100000;
  for(int i=0;i<N;i++){
    mae+=vec.at(i);
    usi-=vec.at(i);
    int sa=abs(mae-usi);
    dis=min(dis,sa);
  }
  cout<<dis<<endl;
      
  
    
 
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<int32_t mod>
struct ModInt{
	int32_t a;
	inline int32_t normalize(int64_t x){
		x%=mod;
		if(x<0)x+=mod;
		return x;
	}
	ModInt(const int64_t a=0):a(normalize(a)){}

	ModInt& operator+=(const ModInt &x){
		a+=x.a;
		if(a>=mod)a-=mod;
		return *this;
	}
	ModInt& operator-=(const ModInt &x){
		a-=x.a;
		if(a<0)a+=mod;
		return *this;
	}
	ModInt& operator*=(const ModInt &x){
		a=(int64_t)a*x.a%mod;
		return *this;
	}
	ModInt& operator/=(const ModInt &x){
		*this*=x.inv();
		return *this;
	}

	ModInt operator+(const ModInt x){return ModInt(*this)+=x;}
	ModInt operator-(const ModInt x){return ModInt(*this)-=x;}
	ModInt operator*(const ModInt x){return ModInt(*this)*=x;}
	ModInt operator/(const ModInt x){return ModInt(*this)/=x;}
	bool operator==(const ModInt x){return a==x.a;}
	bool operator!=(const ModInt x){return a!=x.a;}

	ModInt operator-(){return ModInt(0)-ModInt(*this);}
	ModInt pow(int64_t ex)const{
		int64_t x=a;
		int64_t res=1;
		while(ex){
			if(ex&1)res=res*x%mod;
			x=x*x%mod;
			ex>>=1;
		}
		return ModInt(res);
	}
	ModInt inv()const{return pow(mod-2);}
};

template<int32_t mod>
istream& operator>>(istream& in,ModInt<mod>& a){
	return (in>>a.a);
}
template<int32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
	return (out<<a.a);
}


template<class M>
vector<M>gcd_convolution(vector<M>A,vector<M>B){
	int m=max(A.size(),B.size());
	A.resize(m);
	B.resize(m);
	
	vector<int>isprime(m,1);
	for(int i=2;i<m;i++){
		if(!isprime[i])continue;
		for(int k=m/i;k>=1;k--){
			isprime[k*i]=false;
			A[k]+=A[k*i];
			B[k]+=B[k*i];
		}
	}
	for(int i=1;i<m;i++){
		A[i]+=A[0];
		B[i]+=B[0];
	}

	for(int i=0;i<m;i++)A[i]*=B[i];

	isprime=vector<int>(m,1);
	for(int i=2;i<m;i++){
		if(!isprime[i])continue;
		for(int k=1;k*i<m;k++){
			isprime[k*i]=false;
			A[k]-=A[k*i];
		}
	}
	for(int i=1;i<m;i++)A[i]-=A[0];
	return A;
}

using mint=ModInt<998244353>;

int N;
int A[222222];

signed main(){
	cin>>N;
	rep(i,N)cin>>A[i];

	vector<mint>X(1000001);
	rep(i,N)X[A[i]]+=A[i];

	X=gcd_convolution(X,X);
	mint ans=0;
	for(int i=1;i<=1000000;i++){
		ans+=X[i]/i;
	}

	rep(i,N)ans-=A[i];
	ans/=2;
	cout<<ans<<endl;	
	return 0;
}

Measured memory_bytes: 29184
# require 'pry'
str = gets.chomp.split('')

r0 = 0
r1 = 0
# binding.pry
str.each do |s|
  case s
  when "0"
    if r1 > 0
      r1 -= 1
    else
      r0 += 1
    end
  when "1"
    if r0 > 0
      r0 -= 1
    else
      r1 += 1
    end
  end
end
# puts r0, r1
puts str.size - r0 - r1

Measured memory_bytes: 6908