akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#ifdef LOCAL
#include "Template.cpp"
#else
#define t(...)
#endif
#define endl "\n"

vector<vector<int>> g;

void dfs(int s, vector<bool>& v) {
    if(v[s]) return ;
    v[s] = 1;
    for(auto i : g[s]) {
        dfs(i, v);
    }
}

void solve()
{
    int n, m; 
    cin >> n >> m;
    g.resize(n+1);
    for(int i = 0; i < m; i ++) {
        int u, v; cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<bool> visited(n+1, 0);
    int c = 0;
    for(int i = 1; i <= n; i ++) {
        if(!visited[i]) {
            c ++;
            dfs(i, visited);
        }
    }
    cout << c-1 << endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int a[100005];
    int b[100005]{0};
    int l = n, r = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        b[a[i]]++;
        l = min(l, a[i]);
        r = max(r, a[i]);
    }
    if(r - l > 1){
        cout << "No" << endl;
    }
    else if(l == r){
        if(l <= n / 2 || l == n - 1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else{
        if(r >= b[l] + 1 && r <= b[l] + b[r] / 2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 4220
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll A, B;
    cin >> A >> B;

    cout << max(A * 2 - 1, max(B * 2 - 1, A + B)) << endl;

    return 0;
}

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

using namespace std;

#define int long long

signed main(){
	int n,w;
	cin >> n >> w;
	int wt[n],v[n];
	for(int i=0;i<n;i++){
		cin >> wt[i] >> v[i];
	}
	int dp[n+1][w+1]={{0},{0}};
	for(int i=0;i<=n;i++){
		for(int j=0;j<=w;j++){
			if(i==0||j==0){
				dp[i][j]=0;
			}
			else if(j-wt[i-1]>=0){
				dp[i][j]=max(dp[i-1][j-wt[i-1]]+v[i-1],dp[i-1][j]);
			}
			else{
				dp[i][j]=dp[i-1][j];
			}
			//cout << "i " << i << " j " << j << " dp " << dp[i][j] << endl;
		}
	}
	int mx=0;
	for(int i=0;i<=w;i++){
		mx=max(mx,dp[n][i]);	
	}
	cout << mx << endl;
}

Measured memory_bytes: 79104
def primes(MAX):
    from math import sqrt
    prime = []
    limit = sqrt(MAX)
    data = [i + 1 for i in range(1, MAX)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


N = int(input())
Ps = list(filter(lambda n: n % 5 == 1, primes(55555)))[0:N]
print(" ".join(map(str, Ps)))

Measured memory_bytes: 42732
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int K, X;
	cin >> K >> X;
	for (int i = X - K + 1; i < X + K; i++) {
		cout << i << " ";
	}
	cout << endl;


	return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.conv, std.stdio, std.typecons;

void main()
{
  auto rd = readln.split.map!(to!int);
  auto a = rd[0], b = rd[1];
  writefln("%d %d %f", a / b, a % b, a.to!real / b);
}

Measured memory_bytes: 2604
#include <stdio.h>
#include <math.h>
double pi = 3.14159265358979323846;
double a, b, h, m, t, x;
int main() {
	scanf("%lf%lf%lf%lf", &a, &b, &h, &m);
	h += m / 60;
	t = h / 6 * pi - m / 30 * pi;
	x = a * a + b * b - 2 * a * b * cos(t);
	printf("%.20lf\n", sqrt(x));
}

Measured memory_bytes: 2556
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

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

	vector<int> v(100000);
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		v.at(n - 1) = 1;
	}

	int n = count(v.begin(), v.end(), 1);
	if (n % 2 == 0) {
		n--;
	}

	cout << n << endl;
}

Measured memory_bytes: 640
import sys
from collections import Counter
input = sys.stdin.readline

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    judge_a = Counter(a)
    judge_b = Counter(b)
    judge = judge_a + judge_b
    
    flag = True
    for v in judge.values():
        if v > n:
            flag = False
    
    if flag:
        i, j = 0, 0

        cycle = 0
        while i < n and j < n:
            ii, jj = i, j
            if a[i] < b[j]:
                i += 1
                continue
            if a[i] > b[j]:
                j += 1
                continue
            if a[i] == b[j]:
                while i < n-1 and a[i] == a[i+1]:
                    i += 1
                while j < n-1 and b[j] == b[j+1]:
                    j += 1
            cycle = max(cycle, i-jj+1)
            i += 1
            j += 1
        
        ans = [0]*n
        for i in range(n):
            ans[(i+cycle)%n] = b[i]
        
        for i in range(n):
            if a[i] == ans[i]:
                print("No")
                sys.exit()
        print("Yes")
        print(*ans)
    else:
        print("No")

if __name__ == "__main__":
    main()



Measured memory_bytes: 171824
import sys
l, r = [int(w) for w in input().split()]


if r-l >= 2019:
    print(0)
    sys.exit()

ans = 1.0e100
for i in range(l, r+1):
    for j in range(i + 1, r+1):
        ans = min(ans, i * j % 2019)
print(int(ans))


Measured memory_bytes: 2940
import numpy as np


def solve(string):

    n, m, *py = map(int, string.split())
    py = [(_p, _y) for _p, _y in zip(py[0::2], py[1::2])]
    p = [[] for _ in range(n)]
    for _p, _y in py:
        p[_p - 1].append(_y)
    for i in range(n):
        p[i] = np.argsort(np.argsort(p[i]))

    counter = [0 for _ in range(n)]
    ans = []
    for _p, _y in py:
        ans.append("{:06}{:06}".format(_p, p[_p - 1][counter[_p - 1]] + 1))
        counter[_p - 1] += 1
    return "\n".join(ans)


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve("{} {}\n".format(n, m) + "\n".join([input() for _ in range(m)])))


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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)
typedef long double ld;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
    #define debug true
    #define ln << endl
#else
    #define debug false
    #define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '

const int MOD = 1e9+7;

vector<vector<int>> P;
int N, gt;

vector<int> syaro(int i, int q) {
    vector<int> k;
    bool kr = false;
    int t = 1;
    for(int j: P[i]) if(j != q) {
        auto r = syaro(j, i);
        if(r.size() > 0) {
            kr = true;
            swap(k, r);
        }
        t += gt;
    }
    if(kr) {
        k.push_back(t);
        gt = 0;
        return k;
    } else if(i == N-1) {
        gt = 0;
        return {t};
    } else {
        gt = t;
        return {};
    }
}

signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    scanf("%d",&N);

    P = vector<vector<int>>(N);

    times(N-1, i) {
        int A, B;
        scanf("%d%d",&A,&B);
        --A; --B;
        P[A].push_back(B);
        P[B].push_back(A);
    }

    auto r = syaro(0, 0);
    assert(gt == 0);
    int s = 0, f = 0;

    times(r.size() / 2, i) { s += r[i]; }
    uptil(r.size() / 2, r.size(), i) { f += r[i]; }

    cout << (f > s ? "Fennec" : "Snuke") ln;

    return 0;
}


Measured memory_bytes: 20476
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;

int main() {

  int n;
  cin >> n;
  vec1 v(n);
  vec1 c(n);
  for(int i = 0; i < n; i++) { cin >> v.at(i); }
  for(int i = 0; i < n; i++) { cin >> c.at(i); }
  
  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(v.at(i) - c.at(i) >= 1) {
      ans = ans + (v.at(i) - c.at(i));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// id: ALDS1_3_D
// 由于日语系统等原因，网页上的反斜杠\显示成了￥
// CPU: 00:sec  Memory: KB
#include <iostream>
#include <string>
#include <stack>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::stack;
using std::string;
using std::vector;

int main()
{
	string s;
	stack<int> pos;
	int total = 0;
	vector<vector<int> > areas;

	cin >> s;
	int length = s.size();

	for ( int i = 0; i < length; ++i ) {
		if ( s[i] == '\\' )
			pos.push(i);
		else if ( s[i] == '/' && !pos.empty() ) {
			int lpos = pos.top();
			pos.pop();
			int area = i - lpos;
			total += area;

			vector<int> piece;
			piece.push_back(lpos);
			piece.push_back(area);
			
			while ( !areas.empty() && areas.back()[0] > lpos ) {
				piece[1] += areas.back()[1];
				areas.pop_back();
			}
			areas.push_back(piece);
		}
	}

	cout << total << endl;
	
	int k = areas.size();

	cout << k;
	for ( int i = 0; i < k; ++i )
		cout << " " << areas[i][1];
	cout << endl;

	return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;
const ll INF = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2); return sq*sq; } else { return N*RS(N, P - 1); } } //power(repeat-square,fast)
ll nPr(ll n, ll r) { ll ans = 1; rep(i, r) { ans = ans * (n - i); } return ans; } //permutation
ll nCr(ll n, ll r) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1); bunshi = bunshi * (n - i); } return bunshi / bunbo; } //combination
ll RS(ll N, ll P, ll Mod) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

ll IsFiveFuct(ll n){
  for (ll i = 1; i*i*i*i*i <= abs(n); i++){
     if (i*i*i*i*i == n) return i;
     if (-1*i*i*i*i*i == n) return -1*i;
  }
  return 0;
}

int main(void) {
  ll X; cin >> X;
  ll a = 1;
  while(true){
    ll af = a*a*a*a*a;
    if (af == X){
      cout << a << " " << 0 << "\n";
      return 0;
    }
    ll b = IsFiveFuct(af-X);
    if (b != 0){
      cout << a << " " << b << "\n";
      return 0;
    }
    a++;
  }

  return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}

ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


    
     int solve()
     {  
        int k,x;cin>>k>>x;
        if(k*500>=x) cout<<"Yes";
        else cout<<"No";

        r0   
     }
    signed main()
    {   
        asdf
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 256
#include <complex>
#include <cassert>
#include <iomanip>
#include <functional>
#include <cmath>
#include <iostream>
using namespace std;

int main() {
    int n, k; cin >> n >> k;
    int c[n];
    complex<double> p[n];
    for (int i = 0; i < n; i++) {
        double x, y; cin >> x >> y >> c[i];
        p[i] = {x, y};
    }
    if (k == 1) { cout << "0\n"; return 0; }
    double lb = 0, ub = 1.5e5;
    function<bool(complex<double>, double)> check = [&](complex<double> z, double v) {
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (c[i] * abs(z - p[i]) <= v * (1 + 1e-7)) cnt++;
        }
        return cnt >= k;
    };
    for (int xx = 0; xx < 100; xx++) {
        double v = (lb + ub) / 2;
        bool ok = false;
        for (int i = 0; !ok && i < n; i++) {
            if (check(p[i], v)) {
                ok = true;
                break;
            }
            for (int j = i+1; !ok && j < n; j++) {
                complex<double> vij = p[j] - p[i];
                double d = abs(vij), di = v / c[i], dj = v / c[j];
                if (d > di + dj || di > d + dj || dj > d + di) continue;
                double k = (d * d - dj * dj + di * di) / 2 / d,
                    h = sqrt(di * di - k * k);
                constexpr complex<double> I = {0, 1};
                complex<double> c1 = p[i] + k * vij / d + h * I * vij / d,
                    c2 = p[i] + k * vij / d - h * I * vij / d;

                ok = check(c1, v) || check(c2, v);
            }
        }
        (ok ? ub : lb) = v;
    }
    cout << setprecision(12) << lb << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = to - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

V<int> s;

int search(int target) {
  int head, tail;
  head = 0;
  tail = s.size();

  while(head < tail) {
    int mid = (tail + head) / 2;

    if(s[mid] == target) {
      return mid;
    }

    if(s[mid] < target) {
      head = mid + 1;
    } else {
      tail = mid;
    }
  }

  return -1;
}

int main() {
  int n, q;

  cin >> n;
  s.resize(n);
  rep(i, n) {
    cin >> s[i];
  }

  cin >> q;

  int ans = 0;
  rep(i, q) {
    int target;
    cin >> target;

    int index = search(target);

    if(index != -1) {
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
const int SIZE=100005;

bool cmp(int x,int y);

int n,hp,t=1,ans=0,w,b[SIZE],wic;

int main()
{
	cin>>n>>hp;
	for (int i=1;i<=n;i++){
		cin>>w>>b[i];
		wic=max(w,wic);
	}
	sort(b+1,b+n+1,cmp);
	
	while (b[t]>wic){
		hp-=b[t++];
		ans++;
		if (hp<=0){
			cout<<ans;
			return 0;
		}
	}
	if (hp%wic==0) cout<<ans+hp/wic;
	else		   cout<<ans+hp/wic+1;
	
	return 0;
}

bool cmp(int x,int y)
{
	return x>y;
}

Measured memory_bytes: 640
def main():
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]

    dx = [1,  0, -1, 0]
    dy = [0, -1,  0, 1]

    for h in range(H):
        for w in range(W):
            if S[h][w] == '.':
                continue

            flag = False
            for x, y in zip(dx, dy):
                if 0 <= x+w < W and 0 <= y+h < H and S[y+h][x+w] == '#':
                    flag = True
                    break

            if not flag:
                print('No')
                return

    print('Yes')
    
main()

Measured memory_bytes: 3064
//                                                  '-.-'
   //                                         ()      __.'.__
   //                                      .-:--:-.  |_______|
   //                               ()      \____/    \=====/
   //                               /\      {====}     )___(
   //                    (\=,      //\\      )__(     /_____\
   //    __    |'-'-'|  //  .\    (    )    /____\     |   |
   //   /  \   |_____| (( \_  \    )__(      |  |      |   |
   //   \__/    |===|   ))  `\_)  /____\     |  |      |   |
   //  /____\   |   |  (/     \    |  |      |  |      |   |
   //   |  |    |   |   | _.-'|    |  |      |  |      |   |
   //   |__|    )___(    )___(    /____\    /____\    /_____\
   //  (====)  (=====)  (=====)  (======)  (======)  (=======)
   //  }===={  }====={  }====={  }======{  }======{  }======={
   // (______)(_______)(_______)(________)(________)(_________)
   //
   // Credits :- Joan G. Stark
   //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
   //|                      AUTHOR - KASPAROVIAN                                     |
   //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define frr(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fr first
#define sc second
#define mk make_pair
#define endl '\n'
#define MOD 1000000007
#define in insert
#define sz(x) (ll)(x).size()
#define mem(a,b) memset(a,b,sizeof(a))
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
typedef pair<int,pi> ppi;
typedef vector<vi> graph;
template<class T> void mxi(T & a, const T & b) { a = max(a, b); }
template<class T> void mni(T & a, const T & b) { a = min(a, b); }
ld EPS=1e-9;
void solve()
{
  int n,d;
  cin>>n>>d;
  d=d*d;
  int cnt=0;
  frr(i,n)
  {
  	int x,y;
  	cin>>x>>y;
  	if(x*x+y*y<=d)
  		cnt++;
  }
  cout<<cnt<<endl;
}
signed main()
{
  fast;
  int t,tab;
  t=1;
  tab=t;
  while(t--)
  {
    //cout<<"Case #"<<(tab-t)<<": ";
    solve();
  }
}
//APPROACHING A QUESTION
//+ Think of binary search (max of min etc also if n<=2*10^5)
//+ Think of common dp states (Even if it appears as maths but constraints are small)
//+ Check constraints
//+ Keep calm and enjoy the question
//+ Be sure to remove MOD from binpow (if needed)
//+ Try bidirectional analysis for constructive questions
//+ If given some sequence try thinking of prefix sums
//+ If constraints are too large maybe its simple maths
//+ In questions with binary operations think of bits independently and also the change pattern
//+ If two or more binary operations are given mostly there is a relation between them and an arithmatic operator

Measured memory_bytes: 3648
/**
    AUTHOR:JUNSH
    TIME:19/5/19
**/
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rev(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
struct edge{
    int u,v,w;
    edge(int u=0,int v=0,int w=0){this->u=u,this->v=v,this->w=w;}
};
vector<edge>e[maxn];
int vis[maxn];
int dis[maxn];
void init(int l,int r){rep(i,l,r)e[i].clear();}
void add(int u,int v,int w){e[u].push_back(edge(u,v,w));}
void bfs(int x){
    for(int i=0;i<e[x].size();++i){
        if(!vis[e[x][i].v]){
        vis[e[x][i].v]=1;
        dis[e[x][i].v]=dis[x]+e[x][i].w;
        bfs(e[x][i].v);
        }
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    init(1,n);
    for(int i=1;i<n;++i){
        int u,v,w;
        cin>>u>>v>>w;
        add(u,v,w);
        add(v,u,w);
    }
    vis[1]=1;
    bfs(1);
    for(int i=1;i<=n;++i){
        if(dis[i]&1)
            cout<<"1"<<endl;
        else
            cout<<"0"<<endl;
    }
}


Measured memory_bytes: 8704
n = gets.to_i
x = gets.chomp
xs = x.to_i(2)
xc = x.count('1')
def mpow(n, p, mod)
  return 0 if mod.zero?
  n.pow(p, mod)
end
def popcount(u)
  return 0 if u.zero?
  a = u % u.to_s(2).count('1')
  1 + popcount(a)
end
xsp = mpow(xs, 1, xc + 1)
xsm = mpow(xs, 1, xc - 1)
n.times do |i|
  if x[i] == '0'
    y = xsp + mpow(2, n - i - 1, xc + 1)
    y = mpow(y, 1, xc + 1)
  elsif xc == 1
    puts '0'
    next
  else
    y = xsm - mpow(2, n - i - 1, xc - 1)
    y = mpow(y, 1, xc - 1)
  end
  puts popcount(y) + 1
end

Measured memory_bytes: 14704
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int x = Integer.parseInt(chr[0]);
			int t = Integer.parseInt(chr[1]);
			System.out.println(x-t<0?"0":x-t);

		}
	}
}

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

int main()
{
    int n;
    cin >> n;

    int m[100] = {0}, sum = 0;
    for(int i = 0; i < n; ++i)
    {
        cin >> m[i];
        sum += m[i];
    }

    int ans = sum;
    int cs = 0;
    for(int i = 0; i < n; ++i)
    {
        cs += m[i];
        ans = min(abs(sum-cs-cs), ans);
    }
    cout << ans << endl;




    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mx = 2e5 + 9;

queue<int>q;
vector<int>adj[mx];
int vis[mx];
int dis[mx];

void bfs(int s){
dis[s] = 0;
vis[s] = 1;
q.push(s);
while(!q.empty()){
    int tmp = q.front();
    q.pop();
    for(auto u : adj[tmp]){
        if(vis[u] == 1) continue;
        vis[u] = 1;
        dis[u] = 1 + dis[tmp];
        q.push(u);
    }
}
}

int main(){
int n , m;
cin>>n>>m;
for(int i=0 ; i<m ; i++){
    int u , v;
    cin>>u>>v;
    adj[u].push_back(v);
    adj[v].push_back(u);
}

bfs(1);

/*for(int i=1 ; i<=n ; i++)
    cout<<dis[i]<<" ";
cout<<endl;*/
if(vis[n] && dis[n]==2){
    cout<<"POSSIBLE"<<endl;
}
else
cout<<"IMPOSSIBLE"<<endl;

}


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

int main() {
  string word;
  cin >> word;
  
  vector<string> text(3000);
  int i = 0;
  
  while(1) {
    string tex;
  	cin >> tex;
    if(tex=="END_OF_TEXT") break;
    
    for(int k = 0; k < tex.size(); k++) {
      tex[k] = char(tolower(tex[k]));
      text.at(i).push_back(tex[k]);
    }
    
    i++;
  }
  
  int ans = 0;
  
  for(int j = 0; j < i; j++) {
  	if(text.at(j)==word) ans++;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3164
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

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

	vector<pair<ll, ll>> a(n);
	rep(i, n) {
		cin >> a[i].first >> a[i].second;
	}

	sort(all(a));

	ll res = 0;
	for (int i = 0; i < n; i++) {
		if (m <= 0) break;
		res += a[i].first * min(m, a[i].second);
		m -= min(m, a[i].second);
	}

	out(res);

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
#define reps(i,j,n) for(int i = j ; i < n ; ++i)
#define rep(i, n) reps(i,0,n)
#define fr first
#define sc second
#define SQR(x) ((x)*(x))
#define INF (1 << 28)
typedef pair< int , int > Pt;

int main(){
  int Q;
  int N,X,Y;
  Pt Natume;
  int x[1000],y[1000];
  vector< vector<int> > set;

  cin >> Q;
  while(Q--){
    //Input
    cin >> N >> X >> Y;
    cin >> Natume.sc >> Natume.fr;
    set.resize(N);
    rep(i,N) cin >> x[i] >> y[i];
    rep(i,N) rep(j,N){
      if(SQR(x[i] - x[j]) + SQR(y[i] - y[j]) <= 2500){
        set[i].push_back(j);
      }
    }
    //end

    queue< Pt > que;
    int Say[1000],cnt = 0,flg = 1,END = 1500,ans = 0;
    fill_n(Say,1000,-INF);
    rep(i,N){
      if(SQR(x[i] - Natume.sc) + SQR(y[i] - Natume.fr) <= 100){
        Say[i] = X;
        que.push(Pt(X,i));
      }
    }
    while(!que.empty()){
      Pt p = que.front(); que.pop();
      int now = p.sc , time = p.fr;
      cnt++;
      if(cnt > END){ flg--; break; }
      rep(i,set[now].size()){
        int e = set[now][i];
        if(time - Say[e] > Y){
          Say[e] = X + time;
          que.push(Pt(Say[e],e));
        }
      }
    }
    rep(i,N) ans = max(ans,Say[i]);

    //Output
    if(!flg) cout << "You're always welcome!" << endl;
    else cout << ans << endl;
    //end

    set.clear();
    }
}

Measured memory_bytes: 5228
import sys
if sys.version_info[0]>=3: raw_input=input

n=int(raw_input())
for i in range(0,n):
	a=[int(e) for e in raw_input().split()]
	a[0]-=1;a[1]-=1
	print(196471-a[0]*195-a[0]/3*5-a[1]*20+(a[1]/2 if a[0]%3!=2 else 0)-a[2])

Measured memory_bytes: 4220
while True:
    n,x = map(int, input().split())
    if n == x == 0:
        break
    ans = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for l in range(j+1,n+1):
                if i + j + l == x:
                    ans += 1
    print(ans)



Measured memory_bytes: 5596
#include <stdio.h>

using namespace std;

int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if((x >= r && x <= W-r) && (y >= r && y <= H-r))
		printf("Yes\n");
	else{
		printf("No\n");
	}
}


Measured memory_bytes: 2624
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, m;
    cin >> n >> m;
    VI f(n), g(n);
    int ac = 0, pn = 0;
    REP(i,m){
        int x = in() - 1;
        string s;
        cin >> s;
        if (s == "AC"){
            if (!f[x]){
                ac++;
                pn += g[x];
                f[x] = 1;
            }
        }else{
            g[x]++;
        }
    }
    cout << ac << " " << pn << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n, m, q;
	cin >> n >> m >> q;
	vector<array<int, 4>> a(q);
	for(auto i = 0; i < q; ++ i){
		for(auto j = 0; j < 4; ++ j){
			cin >> a[i][j];
		}
		-- a[i][0], --a[i][1];
	}
	int res = 0;
	vector<int> cur(n);
	function<void(int)> solve = [&](int p){
		if(p == n){
			int score = 0;
			for(auto i = 0; i < q; ++ i){
				if(cur[a[i][1]] - cur[a[i][0]] == a[i][2]){
					score += a[i][3];
				}
			}
			ctmax(res, score);
			return;
		}
		for(auto t = p ? cur[p - 1] : 1; t <= m; ++ t){
			cur[p] = t;
			solve(p + 1);
		}
	};
	solve(0);
	cout << res;
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

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

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
bool Q;
struct Line {
    mutable ll k, m, p;
    bool operator<(const Line& o) const {
        return Q ? p < o.p : k < o.k;
    }
};
struct LineContainer : multiset<Line> {
    const ll inf = LLONG_MAX;
    ll div(ll a, ll b){
        return a / b - ((a ^ b) < 0 && a % b);
    }
    bool isect(iterator x, iterator y) {
        if (y == end()) { x->p = inf; return false; }
        if (x->k == y->k) x->p = x->m > y->m ? inf : -inf;
        else x->p = div(y->m - x->m, x->k - y->k);
        return x->p >= y->p;
    }
    void add(ll k, ll m) {
        auto z = insert({k, m, 0}), y = z++, x = y;
        while (isect(y, z)) z = erase(z);
        if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
        while ((y = x) != begin() && (--x)->p >= y->p)
            isect(x, erase(y));
    }
    ll query(ll x) {
        assert(!empty());
        Q = 1; auto l = *lower_bound({0,0,x}); Q = 0;
        return l.k * x + l.m;
    }
}CHT;
int n,C,h[200005],dp[200005];
// dp[i]+C+h[i]*h[i]-2h[i]
void solve(){
    cin>>n>>C;
    rep(i,1,n+1) cin>>h[i];
    rep(i,1,n+1){
        if(i==1) dp[i]=0;
        else dp[i]=-CHT.query(h[i])+h[i]*h[i];
        int m=-2*h[i],c=dp[i]+C+h[i]*h[i];
        CHT.add(-m,-c);
    }
    cout<<dp[n]<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 15872
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>

using namespace std;

int main(){
  int n;cin>>n;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  
  std::sort(s.begin(),s.end());
  
  auto itr = std::unique(s.begin(), s.end());
  s.erase(itr, s.end());
  
  cout<<s.size();
  
  return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int N,X,D;
    cin>>N>>X>>D;
    REP(i,N){
        int d=1;
      	int a;
      	cin>>a;
        while(d<=X){
            D++;
            d+=a;
        }
    }
    cout<<D<<endl;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int n,c,k;cin >> n>>c>>k;
    vector<int> t(n),t2(n);
    REP(i, n) {
        cin >> t[i];
        //t[i] += k;
    }
    sort(ALL(t));

    int ans=0;
    //乗客を乗せていって　c人超えるか最初に載った人の限界の時間になるまで載せてく

    int num=0;
    int bus=0;
    int time = t[0] + k; //最初に載った人の限界出発時刻
    while (true)
    {
        //int time = t[num] + k;//最初に載った人の限界出発時刻
        bus += 1;
        num += 1;
        if(num==n){
            ans += (bus != 0);
            break;
        }
        if(bus==c||time<t[num]){
            bus = 0;
            time = t[num] + k;
            ans += 1;
        }
    }
    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
int a,b;
int main(){

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>a>>b;
    cout<<(a+b)%24<<newl;
}


Measured memory_bytes: 256
import Data.List
import Control.Monad.Writer

data Tree a = EmptyTree | Node a (Tree a) (Tree a) deriving (Show)

-- ????????????????????????????????????
findRoot :: Int -> [(Int, (Int, Int))] -> Int
findRoot x xs = let
                  findLR (idx, (l, r)) = l == x || r == x
                  node = find findLR xs
                in
                  case node of
                    Just (idx, _) -> findRoot idx xs
                    Nothing       -> x

-- ????????¨????§?????????????
makeTree :: Int -> [(Int, (Int, Int))] -> Tree Int
makeTree x xs = let
                  node = lookup x xs
                in
                  case node of
                    Just (l, r) -> Node x (makeTree l xs) (makeTree r xs)
                    Nothing            -> EmptyTree

-- PreOrder??§?????????????????????????????????
preorder :: Tree Int -> Writer [Int] (Tree Int)
preorder EmptyTree = return (EmptyTree)
preorder (Node idx l r) = do
  tell [idx]
  preorder l
  preorder r

-- InOrder??§?????????????????????????????????
inorder :: Tree Int -> Writer [Int] (Tree Int)
inorder EmptyTree = return (EmptyTree)
inorder (Node idx l r) = do
  inorder l
  tell [idx]
  inorder r

-- PostOrder??§?????????????????????????????????
postorder :: Tree Int -> Writer [Int] (Tree Int)
postorder EmptyTree = return (EmptyTree)
postorder (Node idx l r) = do
  postorder l
  postorder r
  tell [idx]
  return (EmptyTree)

-- ????????¨??????????????????????????????
format :: [Int] -> String
format xs = foldl (\acc x -> acc ++ " " ++ show x) "" xs

main = do
  n <- fmap (read) getLine
  lns <- sequence $ replicate n getLine
  let nodes = map ((\[x,y,z] -> (x, (y,z))) . map read . words) lns
      r = findRoot (fst (nodes !! 0)) nodes
      tree = makeTree r nodes
  putStrLn "Preorder"
  putStrLn $ format . snd . runWriter $ preorder tree
  putStrLn "Inorder"
  putStrLn $ format . snd . runWriter $ inorder tree
  putStrLn "Postorder"
  putStrLn $ format . snd . runWriter $ postorder tree

Measured memory_bytes: 4124
import java.util.*;
import java.io.*;
public class Main {
	void doIt() {
		InputStreamReader read = new InputStreamReader(System.in);
		BufferedReader din = new BufferedReader(read);

		try {
			while(true) {
				Stack<Character> stack = new Stack<Character>();
				Stack<Character> check = new Stack<Character>();
				boolean ans = true;
				String str = din.readLine();
				if(str.charAt(0) == '.') break;
				
				for(int r = 0; r < str.length(); r++) {
					char look = str.charAt(r);
					
					if(look == ' ') continue; //空白文字は無視
					if(look == '(' || look == '[') { //最初のカッコの時
						stack.add(look);
						if(look == '(') check.add(')'); //対となるはずであるものを格納しておく
						else check.add(']'); //対となるはずであるものを格納しておく
					} else if(look == ')' || look == ']') { //最後のカッコの時
						char ch = '.'; 
						if(!check.isEmpty()) ch = check.pop();
						if(look != ch || stack.isEmpty()) {
							ans = false;
							continue;//来るべきである文字と一致しているか
						}
						stack.pop();
					}
				}
				if(!stack.isEmpty() || !check.isEmpty()) ans = false;
				System.out.println((ans) ? "yes" : "no");
			}
		}catch(IOException e) {}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}
}

Measured memory_bytes: 26480
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    str S;
    cin >> S;
    int keta = S.length();
    long long N = stoll(S);
    // cout << keta << endl;
    int ans = 0;
    for(int i = 1; i < keta; i++) {
        if(i % 2 == 1) {
            ans += 9 * pow(10, i - 1);
        }
    }
    if(keta % 2 == 0) {
        cout << ans << endl;
        return 0;
    } else {
        cout << ans + N - pow(10, keta - 1) + 1 << endl;
        return 0;
    }
    return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
void dump(){cout<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cout<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

constexpr ll COM_MAX = (ll)1e6+100;
vector<ll> fac(COM_MAX),finv(COM_MAX),inv(COM_MAX);
// 前処理
void comb_init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<COM_MAX;++i){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}
// 二項係数計算
ll comb(ll n,ll k){
  if(n<k)return 0;
  if(n<0||k<0)return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
// 重複組み合わせ
ll nHk(ll n,ll k){
  return comb(n+k-1,n-1);
}


void solve1();void solve2();
int main(){
  solve1();
  return 0;
}

void solve1(){

  ll x,y;
  cin>>x>>y;

  comb_init();

  if((x+y)%3!=0){
    cout<<0<<endl;
    return;
  }
  
  ll n = (x+y)/3;
  ll k = max(x,y)-n;
  cout<<comb(n,k)<<endl;

}

Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int,int> pii;
typedef priority_queue<int,vector<int>,greater<int> > small_heap;
typedef priority_queue<int> big_heap;
int n,m;
vector<int>v[60];
ll path[60];
void dfs(int x,int fa,ll num){
    path[x]=num;
    for(auto vv:v[x]){
        if(vv==fa)continue;
        dfs(vv,x,num|(1ll<<vv));
    }
}
ll info[60];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n-1;i++){
        int x,y;scanf("%d%d",&x,&y);
        v[x].push_back(y);v[y].push_back(x);
    }
    dfs(1,0,0ll);
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        int x,y;scanf("%d%d",&x,&y);
        info[i]=(path[x]^path[y]);
    }
    ll maxstate=(1ll<<m)-1;
    ll ans=0ll;
    for(int i=0;i<=maxstate;i++)
    {
        ll num=0ll;
        int cnt=0;
        for(int j=0;j<=m-1;j++)
        {
            if(i&(1<<j))
            {
                cnt++;
                num|=info[j];
            }
        }
        int free=n-1-__builtin_popcountll(num);
        ans+=(1ll<<free) * (cnt & 1 ? -1ll : 1ll);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#define pb push_back
#define all(c) c.begin(),c.end()
#define uni(c) c.erase(unique(all(c)),c.end())
using namespace std;
typedef long long int ll;
int main(){
	string s;
	while(cin>>s){
		map<char,ll> m;
		for(ll i=0;i<s.size();i++){
			m[s[i]]++;
		}
		
		ll odd=0,even=0;
		map<char,ll>::iterator ite=m.begin();
		vector<ll> v;
		map<ll,ll> d;
		for(ite=m.begin();ite!=m.end();ite++){
			if(ite->second%2==1){
				odd++;
				if(ite->second>=3){
					v.pb((ite->second-1)/2);
					for(int j=2;j<=(ite->second-1)/2;j++){
						d[j]++;
					}
				}
			}else{
				even++;
				v.pb((ite->second)/2);
				for(ll j=2;j<=(ite->second)/2;j++){
					d[j]++;
				}
			}
		}
		if(odd>1){
			cout<<0<<endl;
			continue;
		}
		ll ans=1;
		for(ll i=1;i<=s.size()/2;i++){
			//cout<<ans<<endl;
			if(d[i]){
				d[i]--;
			}else
			ans*=i;
		}
		map<ll,ll>::iterator it=d.begin();
		for(it=d.begin();it!=d.end();it++){
			for(int l=0;l<it->second;l++){
				for(ll k=1;k<=it->first;k++){
					ans/=k;
				}
			}
		}
		
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0