akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int A,B;cin>>A>>B;
    if(A%3 && B%3 && (A+B)%3){
        cout<<"Impossible"<<endl;
    }else{
        cout<<"Possible"<<endl;
    }
}


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

int main() {
  int kinshi=0;
  int N,M;
  cin>>N>>M;
  vector<int>keta(N,0);
  vector<int>ketakanri(N,0);
  keta[0]=1;
  for(int i=0;i<M;i++){
    int s,c;
    cin>>s>>c;
    s--;
    if(ketakanri[s]){
      if(keta[s]!=c){
        kinshi++;
      }
    }
    keta[s]=c;
    ketakanri[s]=1;
  }
  if(N!=1){
  if(keta[0]==0) kinshi++;
  }
  if(N==1 and M==0){
    cout<<0;
    return 0;
  }
  if(kinshi) cout<<-1;
  else{
    rep(i,N) cout<<keta[i];
  }
}


Measured memory_bytes: 256
N = int(input())
lst = [list(map(int,input().split())) for _ in range(N)]

for x,y,h in lst:
    if h != 0:
        break

for cx in range(101):
    for cy in range(101):
        H = abs(cx-x) + abs(cy-y) + h
        if all(hi == max(H-abs(cx-xi)-abs(cy-yi),0) for xi,yi,hi in lst):
            print(cx,cy,H)
            exit()

Measured memory_bytes: 3064
while n = gets.to_i
  break if n == 0
  res = n
  for x in (0..(n**(1.0/3.0)).ceil)
    c = x ** 3
    if (k = n - c) >= 0
      y = Math.sqrt(k).to_i
      z = k - y * y
      res = [res, x + y + z].min
    end
  end
  p res
end

Measured memory_bytes: 8996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
ll kaijo(ll x){
  ll ans=1;
  rep1(i,x)ans*=i;
  return ans;
}
  
void solve(){
    int n;
    cin>>n;
    vector<int>x(n);
    vector<int>y(n);
    rep(i,n)cin>>x[i]>>y[i];
    double sum=0;
    vector<int>v(n);
  rep(i,n)v[i]=i;
  do{
    rep(i,n-1)sum+=sqrt(pow((x[v[i]]-x[v[i+1]]),2.0)+pow((y[v[i]]-y[v[i+1]]),2.0));
  }while(next_permutation(v.begin(),v.end()));
cout<<sum/kaijo(n)<<endl;
}

int main(){
    cout<<std::fixed<<std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}


Measured memory_bytes: 256
def f(n):
    if n%2==0:
        return n/2
    else:
        return 3*n+1

s = int(input())
hist = [s, ]
m = 1
while True:
    elem = f(hist[m-1])
    if elem not in hist:
        hist.append(elem)
        m += 1
    else:
        print(m+1)
        break


Measured memory_bytes: 2940
#include <cmath>
#include <cstdio>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stdio.h>
#include <functional>
#include <chrono>
using namespace std;

#define rep(i,s,n) for(ll i=s;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
constexpr ll MAX_INF = 9223372036854775807;
constexpr ll MOD = (1e9 + 7);
//constexpr ll MOD = (998244353);

using vl = vector<ll>;
using vvl = vector<vector<ll>>;

template<class T>
vector<vector<T>> vvt(T init, ll m, ll n) {
	vector<vector<T>> ans = vector<vector<T>>(m, vector<T>(n, init));
	return move(ans);
}

template<class T>
vector<T> vt(T init,ll n) {
	vector<T> ans = vector<T>(n, init);
	return move(ans);
}

template<class T>
T maxVec(vector<T> &v) {
	T ans = -INF;
	rep(i,0, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}

// 素数判定
bool judge(ll n) {
	for (ll i = 2; i * i <= n; i++) if (n %= i)return false;
	return true;
}


template <class C>
void print(const C& c, std::ostream& os = std::cout)
{
	std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, ", "));
	os << std::endl;
}
/*
ll count(ll n,ll r) {
	ll ans = 0,check = 1;
	rep(i,0, r) {
		if ((n & check) > 0) {
			ans++;
		}
		check = check << 1;
	}
	return ans;
}
*/
bool sortreverse(ll a, ll b) {
	return a > b;
}

ll kiriage(ll a, ll b) {
	if (a % b == 0)return a / b;
	return a / b + 1;
}

void factorization(vector<pll>& ans, ll n) {
	ll i = 2, c = 0;
	for (i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			c = 0;
			while (n % i == 0) {
				c++;
				n /= i;
			}
			ans.push_back(make_pair(i, c));
		}
	}
	if (n != 1) {
		ans.push_back(make_pair(n, 1));
	}
	return;
}

ll modpow(ll n, ll a, ll m) {
	if (a == 0)return 1;
	if (a % 2 == 0) {
		ll b = modpow(n, a / 2, m);
		return (b * b) % m;
	}
	else if (a % 2 == 1) return (n * modpow(n, a - 1, m)) % m;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

ll n,m,x,y,t,q,s;

int main() {
	cin >> n;
	vl a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	vector<vector<pll>> fac(n);
	unordered_map<ll,ll> check;
	vector<unordered_map<ll, ll>> facmap(n);
	rep(i, 0, n) {
		factorization(fac[i], a[i]);
		rep(j, 0, fac[i].size()) {
			facmap[i][fac[i][j].first] = fac[i][j].second;
			if (check.find(fac[i][j].first) == check.end()) {
				check[fac[i][j].first] = fac[i][j].second;
			}
			else {
				check[fac[i][j].first] = max(check[fac[i][j].first], fac[i][j].second);
			}
		}
	}
	ll saisyoukoubai = 1;
	for (auto itr = check.begin(); itr != check.end(); ++itr) {
		saisyoukoubai *= modpow(itr->first, itr->second, MOD);
		saisyoukoubai %= MOD;
	}
	ll ans = 0;
	rep(i, 0, n) {
		ll c = modinv(a[i],MOD);
		c *= saisyoukoubai;
		c %= MOD;
		ans += c;
		ans %= MOD;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
vector<ll> arr[100005];
pair<ll,ll> dfs(ll child, ll parent)
{
	ll white=1;
	ll black=1;
	//cout<<arr[1].size()<<endl;
	for(ll i=0;i<arr[child].size();i++)
	{
		if(arr[child][i]!=parent){
			pair<ll,ll> p=dfs(arr[child][i],child);
			white=((white%mod)*((p.first+p.second)%mod))%mod;
			black=((black%mod)*(p.first%mod))%mod;
			//cout<<white<<" "<<black<<" "<<arr[child][i]<<endl;
		}
	}
	//cout<<white<<" "<<black<<endl;
	return make_pair(white,black);
} 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("test.txt","r",stdin);
	ll n;
	cin>>n;
	ll x,y;
	for(ll i=1;i<n;i++)
	{	
		cin>>x>>y;
		//cout<<x<<" "<<y<<endl;
		arr[x].push_back(y);
		arr[y].push_back(x);
	}
	pair<ll,ll> ans=dfs(1,-1);
	cout<<(ans.first+ans.second)%mod<<endl;

}

Measured memory_bytes: 12672
x, y = map(int, input().split())
def reward(x):
    if x == 1:
        return 300000
    elif x == 2:
        return 200000
    elif x == 3:
        return 100000
    else:
        return 0

if x * y == 1:
    print(300000 * 2 + 400000)
else:
    print(reward(x) + reward(y))

Measured memory_bytes: 38256
# -*- coding: utf-8 -*-
import types
#import copy

# Input
abcd = input()
n = len(abcd) - 1 # 閾の数

# Print
for i in range( 2**n ):
    op = n * ["-"]

    # Create operation list
    # example: ['+', '-', '+']
    for j in range(n):
        if ( i >> j ) & 1:
            op[n-1 -j] = "+"
            
    formula = ""
    for p_n, p_o in zip(abcd, op+[""]):
        formula += (p_n + p_o)

    if eval(formula) == 7:
        print(formula + "=7")
        break




Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = __LONG_LONG_MAX__;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll x; cin >>x;
    ll y = 100ll;
    ll index = 0ll;
    while(y<x){
        index++;
        y += (y/100ll);
    }
    cout << index << endl;
}

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

int N;
int x[200], y[200];
long long mod = 998244353;
long long ans = 0;



int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i];
    }
    ans = 1;
    for(int i = 0; i < N; i++){
        ans *= 2;
        ans %= mod;
    }

    ans += mod - 1;
    ans %= mod;
    ans += mod - N;
    ans %= mod;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            int cnt = 0;
            for(int k = j + 1; k < N; k++){
                int dx1 = x[k] - x[i];
                int dx2 = x[k] - x[j];
                int dy1 = y[k] - y[i];
                int dy2 = y[k] - y[j];
                if(dx1*dy2 == dx2*dy1){
                    cnt++;
                }
            }
            int minus = 1;
            for(int k = 0; k < cnt; k++){
                minus *= 2;
                minus %= mod;
            }
            ans += mod - minus;
            ans %= mod;
        }
    }
    cout << ans << endl;
}

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

// macros
#define overload_rep(_1, _2 ,_3 ,name, ...) name
#define re_p(i, n) for(int i = 0; i < (n); ++i)
#define r_ep(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, r_ep, re_p)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// Let's get AC!
int N;
int A[300000];
int B[300000];
int C[300000];
int now, sum;

int main(){
    cin >> N;
    rep(i, N){
        int a;
        cin >> a;
        A[a - 1]++;
    }
    rep(i, N)if(A[i])B[A[i] - 1]++, now++;
    rep(i, N){
        C[i] = now + sum / (i + 1);
        now -= B[i];
        sum += (i + 1) * B[i];
    }
    reverse(C, C + N);
    rep(i, N){
        cout << C + N - lower_bound(C, C + N, i + 1) << '\n';
    }
}

Measured memory_bytes: 3200
s = input()
v = 0
for i in range(2**(len(s)-1)):
  k = 0
  j = 1
  while i:
    if i & 1:
      v += int(s[k:j])
      k = j
    i >>= 1
    j += 1
  v += int(s[k:])
print(v)

Measured memory_bytes: 2940
// Author: Eleus Ahammad, CSE, KUET.
#include <bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
#define vi vecor<int>
#define vii vector<pii>
#define vll vector<ll>
#define pb push_back
#define F first
#define S second
#define pf printf
#define sf scanf
#define lsort(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define csort(a, cmp) sort(a.begin(), a.end(), cmp)
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ifile freopen("input.txt", "r", stdin)
#define ofile freopen("output.txt", "w", stdout)
using namespace std;

ll gcd(ll a, ll b)
{
    if (b == 0) return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

ll modpow(ll a, ll b, ll m)
{
    if (b == 0) return 1%m;
    ll u = modpow(a, b / 2, m);
    u = ((u%m) * (u%m)) % m;
    if (b%2) u = ((a%m) * (u%m))%m;
    return u;
}

ll egcd(ll a, ll b, int &x, int &y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    int x1, y1, d;
    d = egcd(b, a%b, x1, y1);
    x = y1;
    y = x1 - (a / b) * y1;
    return d;
}
ll modInv(ll a, ll b)
{
    int x, y;
    egcd(a, b, x, y);
    return (x%b + b)%b;
}

const double PI = acos(-1.0);
const int mod = (int) 1e9 + 7;
//Code begins here.

ll ncr(ll n, ll r)
{
    //if (n - r < r) r = n - r;
    ll ans = 1;
    ll fr = 1;
    for (int i = 1, j = n; i <= r; i++, j--) {
        ans = ((ans%mod) *( j%mod))%mod;
        fr = ((fr%mod)  * (i%mod)) % mod;
    }
    //cout << ans << "\n";
    return ((ans%mod) * modpow(fr, mod - 2, mod)) % mod;
}

void solve()
{
    int n, a, b;
    cin >> n >> a >> b;
    ll ans = modpow(2, n, mod) - 1;
    //cout << ans << "\n";
    ans = ans - ncr(n, a) - ncr(n, b);
    cout << (ans%mod + mod)%mod << "\n";
}

int main()
{
    fastio;
    //ifile;
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}



Measured memory_bytes: 256
from copy import deepcopy
from operator import itemgetter

def buy(p, cr):
    cnt, rem = cr
    r1000 = p % 1000
    r500 = p % 500
    m500 = 500 - r500
    m1000 = 1000 - r1000
    if r1000 == 0:
        if rem < 500:
            return ((cnt, rem),)
        else:
            return ((cnt+1, rem-500),)
    elif r1000 == 500:
        return ((cnt+1, rem),)
    elif r1000 < 500:
        return ((cnt+1, rem + m500), (cnt, rem + m1000))
    else:
        if rem - r500 >= 0:
            return ((cnt+1, rem - r500),)
        else:
            return ((cnt, rem + m500),)

INF = 10**20

def solve(plist):
    dp = {
        (0, 0): 0
    }
    for p in plist:
        ndp = {}
        for cr in list(dp.keys()):
            for ncr in buy(p, cr):
                ndp[ncr] = min(dp[cr] + p, dp.get(ncr, INF))

        dp.update(ndp)
        ndp = {}
        cc = -1
        mp = INF
        for c, r in sorted(dp.keys(), reverse=True):
            pp = dp[(c, r)]
            if cc != c:
                mp = INF
                cc = c
            if mp > pp:
                ndp[(c, r)] = pp
                mp = pp
        dp = ndp

    cplist = ((t[0][0], t[1]) for t in dp.items())
    return sorted(sorted(cplist, key=itemgetter(1)),
                  key=itemgetter(0), reverse=True)[0]

def main():
    while True:
        n = int(input().strip())
        if n == 0:
            break
        plist = [int(input().strip()) for _ in range(n)]
        print(" ".join(str(i) for i in solve(plist)))

if __name__ == '__main__':
    main()



Measured memory_bytes: 14784
#include<cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
using namespace std;
int main(){
  string a,b,c;
  cin>>a>>b>>c;
  int al,bl,cl;
  al=a.size();
  bl=b.size();
  cl=c.size();
  if (a[al-1]==b[0] and b[bl-1]==c[0])printf("YES");
  else printf ("NO");
  return 0;
}
  


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		vector<int> x(n, 0), y(n, 0);
		for(int i=0; i < n; i++)cin >> x[i] >> y[i];
		auto dxy = vector<tuple<double, int, int>>(n);
		for(int i=0; i < n; i++)dxy[i] = make_tuple(atan2((double)y[i], (double)x[i]), x[i], y[i]);
		sort(dxy.begin(), dxy.end());
		int sx=0, sy=0;
		for(int i=0; i < n; i++)sx += x[i];
		for(int i=0; i < n; i++)sy += y[i];
		double ret = 0.0;
		for(int i=0; i < n; i++){
			for(int j=i+1; j <= n; j++){
				int tsx = 0, tsy = 0;
				for(int k=i; k < j; k++){
					tsx += get<1>(dxy[k]);
					tsy += get<2>(dxy[k]);
				}
				updmax(ret, sqrt(((double)tsx) * tsx + (double)tsy * tsy));
				updmax(ret, sqrt(((double)(sx - tsx)) * (sx - tsx) + ((double)(sy - tsy)) * (sy - tsy)));
			}
		}
		cout << setprecision(12) << ret << "\n";
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<set>
#include<vector>
#include<random>
#include<utility>
using namespace std;
struct Point{
    int x, y, l;
    Point(int x, int y, int l) : x(x), y(y), l(l) {}
    Point(){}
};
struct Node{
    Node* left  = NULL;
    Node* right = NULL;
    int x;
    int y;
    int location;
    Node(int x, int y, int location) : x(x), y(y), location(location){}
    Node(){}
};
class Tree{
private:
    Node* root = NULL;
    void add_Node(Node* n, Node*& pos, int depth){
        if (pos == NULL) {
            pos = n;
            return;
        }
        if (depth % 2 == 0) {
            if (n->y < pos->y) {
                add_Node(n, pos->left , depth + 1);
            } else {
                add_Node(n, pos->right, depth + 1);
            }
        } else {
            if (n->x < pos->x) {
                add_Node(n, pos->left , depth + 1);
            } else {
                add_Node(n, pos->right, depth + 1);
            }
        }
    }
    void find_Node(int sx, int tx, int sy,
                   int ty, set<int>& ans, Node* pos, int depth){
        if (pos == NULL) return;
        if (sx <= pos->x && pos->x <= tx && sy <= pos->y && pos->y <= ty) {
            ans.insert(pos->location);
        }
        if (depth % 2 == 0){
            if (sy <= pos->y) {
                find_Node(sx, tx, sy, ty, ans, pos->left, depth + 1);
            }
            if (pos->y <= ty) {
                find_Node(sx, tx, sy, ty, ans, pos->right, depth + 1);
            }
        } else {
            if (sx <= pos->x) {
                find_Node(sx, tx, sy, ty, ans, pos->left, depth + 1);
            }
            if (pos->x <= tx) {
                find_Node(sx, tx, sy, ty, ans, pos->right, depth + 1);
            }
        }
    }
public:
    void add_data(int x_in, int y_in, int loc_in){
        Node* n = new Node(x_in, y_in, loc_in);
        add_Node(n, root, 0);
    }
    void find_data(int sx, int tx, int sy, int ty, set<int>& ans){
        find_Node(sx, tx, sy, ty, ans, root, 0);
    }
};

int main(){
    int n;
    scanf("%d", &n);
    vector<Point> data(n);
    for (int i = 0; i < n; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        data[i] = Point(x, y, i);
    }
    random_device rnd;
    mt19937 mt(rnd());
    uniform_int_distribution<> rand_n(0, n - 1);
    for (int i = 0; i < n; i++) {
        swap(data[rand_n(mt)], data[rand_n(mt)]);
    }
    Tree T;
    for (int i = 0; i < n; i++) {
        T.add_data(data[i].x, data[i].y, data[i].l);
    }
    int q;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        set<int> ans;
        int sx, tx, sy, ty;
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        T.find_data(sx, tx, sy, ty, ans);
        for (auto it = ans.begin(); it != ans.end(); it++) {
            printf("%d\n", *it);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 31084
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        final int N = Integer.parseInt(sc.next());
        Set<String> set = new HashSet<>();
        
        for (int i = 0; i < N; i++) {
            set.add(sc.next());
        }

        
        out.println(set.size());
        
        out.flush();
    }
}

Measured memory_bytes: 77120
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n == 0 )break;
			else calc(n);
			
		}
	}
	double xs[];
	double ys[];
	double zs[];
	double rs[];
	double distance[];
	int count;
	public void calc(int n){
		xs = new double[n];
		ys = new double[n];
		zs = new double[n];
		rs = new double[n];
		for(int i = 0; i < n; i++){
			xs[i] = sc.nextDouble();
			ys[i] = sc.nextDouble();
			zs[i] = sc.nextDouble();
			rs[i] = sc.nextDouble();			
		}
		
		distance = new double[n];
		Arrays.fill(distance, Double.MAX_VALUE);
		
		double ans = 0;
		
		distance[0] = -1;
		count = 1;	
		update(0, n);
		
		while(count < n){
			int small = -1;
			for(int k = 0; k < n; k++){
				if(distance[k] != -1 && (small == -1 || distance[k] < distance[small])){
					small = k;
				}
			}
			ans += distance[small];
			distance[small] = -1;
			count++;
			update(small, n);
		}
		System.out.printf("%.3f\n", ans);
	}
	
	public void update(int a, int n){
		for(int i = 0; i < n; i++){
			if(distance[i] != -1){
				double d = dist(a, i);
				if(d == 0){
					distance[i] = -1;
					count++;
					update(i, n);
				}
				else if(d < distance[i]) distance[i] = d;
			}
		}
	}

	public double dist(int a, int b){
		double d = Math.sqrt(
				  (xs[a]-xs[b]) * (xs[a]-xs[b]) +
				  (ys[a]-ys[b]) * (ys[a]-ys[b]) +
				  (zs[a]-zs[b]) * (zs[a]-zs[b])
				);
		d = d - rs[a] - rs[b];
		if(d < 0) d = 0;
		return d;
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 51124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1087, C = 2e4 + 87;
ll dp[C];
tuple<int, int, int> a[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int w, s, v;
        cin >> w >> s >> v;
        s += w;
        a[i] = make_tuple(s, w, v);
    }
    sort(a, a + n);
    for (int i = 0; i < n; ++i) {
        int s, w, v;
        tie(s, w, v) = a[i];
        for (int j = s; j >= w; --j)
            dp[j] = max(dp[j], dp[j - w] + v);
        for (int j = s + 1; j < C; ++j)
            dp[j] = max(dp[j], dp[j - 1]);
    }
    cout << dp[C - 1] << endl;
}


Measured memory_bytes: 384
H,W = map(int,input().split())
s = [list(input()) for _ in range(H)]

def check(h,w):
    dx = [0,0,-1,1]
    dy = [1,-1,0,0]
    for k in range(len(dx)):
        if 0 <= h+dy[k] <= (H-1) and 0 <= w+dx[k] <= (W-1):
            if s[h+dy[k]][w+dx[k]] == "#":
                break
            elif k == 3:
                return True
    return False

ans = "Yes"
for i in range(H):
    for j in range(W):
        if s[i][j] == "#":
            if check(i,j):
                ans = "No"
                break
print(ans)

Measured memory_bytes: 3064
#include <iostream>

//https://abc050.contest.atcoder.jp/tasks/abc050_a

using namespace std;

int main(){
    int A,B;
    char op;

    cin >> A >> op >> B;

    if(op == '+'){
        cout << A + B << endl;
    } else if(op == '-'){
        cout << A - B << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while(true){
            int h = in.nextInt();
            int w = in.nextInt();
            if(h == 0 && w == 0){
                break;
            }
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                    if(i%2 != 0 ){
                        if(j%2 !=0) {
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
                    }else{
                        if(j%2 !=0){
                            System.out.print(".");
                        }else{
                            System.out.print("#");
                        }
                    }

                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
}

Measured memory_bytes: 38284
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <string>

using namespace std;

#define int long long

vector<int> a;
vector<vector<int>> g;
vector<int> ans;

struct seg_tree_max
{
	vector<int> tree;

	void build(int i, int l, int r, vector<long long>& a)
	{
		if (l + 1 == r)
		{
			tree[i] = a[l];
			return;
		}
		int m = (l + r) / 2;
		build(i * 2 + 1, l, m, a);
		build(i * 2 + 2, m, r, a);
		tree[i] = max(tree[i * 2 + 1], tree[i * 2 + 2]);
	}

	long long get_max(int i, int l, int r, int q_l, int q_r)
	{
		if (q_l <= l && r <= q_r)
		{
			return tree[i];
		}
		if (r <= q_l || q_r <= l)
		{
			return 0;
		}
		int m = (l + r) / 2;
		return max(get_max(i * 2 + 1, l, m, q_l, q_r), get_max(i * 2 + 2, m, r, q_l, q_r));
	}


	void upd(int i, int l, int r, int q_i, long long val)
	{
		if (r <= q_i || q_i < l)
		{
			return;
		}
		if (l + 1 == r)
		{
			tree[i] = val;

			return;
		}
		int m = (l + r) / 2;
		upd(i * 2 + 1, l, m, q_i, val);
		upd(i * 2 + 2, m, r, q_i, val);
		tree[i] = max(tree[i * 2 + 1], tree[i * 2 + 2]);
	}

	void buildd(vector<long long>& a)
	{
		tree.resize(a.size() * 4);
		build(0, 0, a.size(), a);
	}
};

seg_tree_max st;

void dfs(int v, vector<bool> &used)
{
    used[v] = true;
    ans[v] = max(st.get_max(0, 0, a.size(), 0, a[v]) + 1, st.get_max(0, 0, a.size(), 0, a.size()));
    int prev = st.get_max(0, 0, a.size(), a[v], a[v] + 1);
    st.upd(0, 0, a.size(), a[v], max(prev, st.get_max(0, 0, a.size(), 0, a[v]) + 1));
    for(int u : g[v])
    {
        if (!used[u])
        {
            dfs(u, used);
        }
    }
    st.upd(0, 0, a.size(), a[v], prev);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n, m;
    cin >> n;
    g.resize(n);
    a.resize(n);
    vector<int> f;
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i];
        f.push_back(a[i]);
    }
    map<int, int> d;
    sort(f.begin(), f.end());
    f.resize(unique(f.begin(), f.end()) - f.begin());
    for(int i = 0; i < f.size(); ++i)
    {
        d[f[i]] = i;
    }
    //cerr << "OK" << endl;
    for(int i = 0; i < n; ++i)
    {
        a[i] = d[a[i]];
    }
    //cerr << "OK" << endl;
    vector<int> gg(n, 0);
    ans.assign(n, 1);
    //cerr << "OK" << endl;
    st.buildd(gg);
    for(int i = 0; i < n - 1; ++i)
    {
        int u, v;
        cin >> u >> v;
        --u; --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<bool> used(n, false);
    dfs(0, used);
    for(int i : ans)
    {
        cout << i << '\n';
    }
}

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

int main() {
    vector<char> C(6); for(int i = 0; i < 6; ++i) cin >> C[i];

    if(C[0] == C[5] && C[1] == C[4] && C[2] == C[3]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define newl "\n"
#define rep(a, b, c, i) for (int i = a; i < b; i += c)
#define ff first
#define ss second

using namespace std;

class DistanceCoord{
public:
	int findPoints(vector<pair<ll, ll>> &dist, ll d){
		int n = dist.size();
		int count = 0;
		rep(0, n, 1, i){
			if (sqrt(dist[i].ff * dist[i].ff + dist[i].ss * dist[i].ss) <= d){
				count++;
			}
		}
		return count;
	}
};

int main(){
	int n, d;
	cin >> n >> d;
	DistanceCoord dco;
	vector<pair<ll, ll>> dist;
	while (n--){
		int x, y;
		cin >> x >> y;
		dist.push_back(make_pair(x, y));
	}
	cout << dco.findPoints(dist, d) << newl;
}


Measured memory_bytes: 7460
# D
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

X, Y = map(int, input().split())

if X % 3 == 1 and Y % 3 == 1:
    print(0)
    exit()
if X % 3 == 2 and Y % 3 == 2:
    print(0)
    exit()

a = 2 * Y // 3 - X // 3
b = 2 * X // 3 - Y // 3


mod = 10**9+7 #出力の制限
N = a + b + 3
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )



print(cmb(a+b, b, mod))

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    int N,X,Y;
    cin >> N >> X >> Y;

    vector<vi> G(N);
    for(int i=0;i<N-1;i++){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }

    G[X-1].push_back(Y-1);
    G[Y-1].push_back(X-1);


    vector<int> ans(N,0);
    queue<int> que;

    for(int i=0;i<N;i++){

        vector<int> dist(N,-1);
        dist[i] = 0;
        que.push(i);

        while(!que.empty()){
            int v = que.front();
            que.pop();
            ++ans[dist[v]];
            for(int edge=0;edge<G[v].size();edge++){
                if(dist[G[v][edge]]!=-1) continue;
                que.push(G[v][edge]);
                dist[G[v][edge]] = dist[v]+1;
            }
        }

    }

    for(int i=1;i<N;i++){
        cout << ans[i]/2 << endl;
    }

}



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

const int N = 1e6 + 100;

int F(int x) {
//    cout << "x: " << x << endl;
    int ans = 0;
    for(int i = 1;; i++) {
        if(i > x) return ans;
        ans++;
        x -= i;
    }
}


int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    long long n;
    cin >> n;
    int ans = 0;
    for(long long i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            int cnt = 0;
            while(n % i == 0) {
                cnt++;
                n /= i;
            }
            ans += F(cnt);
        }
    }

    if(n > 1) ans++;
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3652
/*

0084: search engine


*/

#include <stdio.h>
#include <string.h>

#define TEXT 2049

int main(void){
	
	char text[TEXT] = "\0";
	char temp[7] = "\0";
	char delimiters[4] = ", .";
	int i = 0;
	int count = 0;
	char *p = text;
	
	fgets(text, sizeof(text), stdin);
	
	
	while(p[i] != '\0'){
		
		if(p[i] == delimiters[0] || p[i] == delimiters[1] || p[i] == delimiters[2]){
			
			
			if(i>2 && i<7){
				
				strncpy(temp, p, i);
				temp[i] = '\0';
				
				if(count > 0){
					
					printf(" ");
					
				}
				
				printf("%s", temp);
				
				count++;
				
			}
			
			p += i+1;
			
			i = 0;
			
		}
		else{
			
			i++;
			
		}
		
	}
	
	puts("");
	
	return 0;
	
}

Measured memory_bytes: 540
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
#define mod 1000000007

ll a,b,c,d;
ll p[212345];

int main(){
  scanf("%lld%lld%lld%lld",&a,&b,&c,&d);

  ll ac,ad,bc,bd;
  ac=a*c;
  ad=a*d;
  bc=b*c;
  bd=b*d;
  if(ac>ad) ad=ac;
  if(bc>bd) bd=bc;
  if(bd>ad) printf("%lld\n",bd);
  else printf("%lld\n",ad);
  
  return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int a[3][3];
  int b[3][3] = {0};

  int N;
  rep(i, 3) {
    rep(j, 3) {
      cin >> a[i][j];
    }
  }
  cin >> N;
  rep(i, N) {
    int temp;
    cin >> temp;
    rep(j, 3) {
      rep(k, 3) {
        if(temp == a[j][k]) {
          b[j][k] = 1;
        }
      }
    }
  }
  bool f = false;
  rep(i, 3) {
    if(b[i][0] == 1 && b[i][1] == 1 && b[i][2] == 1) f = true;
  }
  rep(i, 3) {
    if(b[0][i] == 1 && b[1][i] == 1 && b[2][i] == 1) f = true;
  }
  if(b[0][0] == 1 && b[1][1] == 1 && b[2][2] == 1) f = true;
  if(b[0][2] == 1 && b[1][1] == 1 && b[2][0] == 1) f = true;
  // rep(i, 3) {
  //   rep(j, 3) {
  //     cout << b[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;

int main() {
    int a, b;
    cin >> a >> b;

    cout << 6 - a - b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N, M;
    cin >> N >> M;
    int A[N], B[M];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }
    int c[N]{};
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < N; j++) {
            if (A[j] <= B[i]) {
                c[j]++;
                break;
            }
        }
    }
    int idx = 0;
    int t = 0;
    for (int i = 0; i < N; i++) {
        if (c[i] > t) {
            t = c[i];
            idx = i + 1;
        }
    }
    cout << idx << "\n";
    return 0;
}


Measured memory_bytes: 3080
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N 100005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
#define endl "\n"
#define mid  (l + r + 1)/2
#define s3   1.73205080757
const int inf = (int)1e18 + 10;
string ans[100005];
vector < pii > v[100005]; 
string get(int x , int y){
	  string s1 = to_string(x);
	  string s2 = to_string(y);
	  int k = s1.length();
	  int p = s2.length();
	  string s;
	  for(int i = 1 ; i<= 6-k ; i++)
	  	  s += "0";
	  s += s1;
	  for(int i = 1 ; i<= 6-p ; i++)
	  	  s+="0";
	  s+=s2;
	  return s;

}
signed main(){
  fast;
 
  int n , m , x , y;
  cin >> n >> m;
  for(int i = 1 ; i<= m ; i++){
  	    cin >> x >> y;
  	    v[x].pb({y , i});
  	    
  	    
  }
  for(int i = 1 ; i<= n ; i++){
  	if(v[i].size() > 0) {
  		sort(v[i].begin() , v[i].end());
  		for(int j = 0 ; j< v[i].size() ; j++){
  			 ans[v[i][j].ss] = get(i , j+1);
  		}
  	}
  }
  for(int i = 1 ; i<= m ; i++)
  	cout << ans[i] << endl;



  

}	


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

int main() {
    int N, X; cin >> N >> X;
    vector<int> D(N + 1);
    D[0] = 0;
    for (int i = 0; i < N; ++i) {
        int x; cin >> x;
        D[i + 1] = D[i] + x;
    }
    int ans = 0;
    for (int i = 0; i <= N; ++i) {
        if (D[i] <= X) {
            ans++;
        }
    }
   cout << ans << endl;
   return 0;
 }


Measured memory_bytes: 256
import java.util.*;

/**
 * A
 */
public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int flag = 0, count = 0, left, right;

        int n = sc.nextInt();
        int[] S = new int[n];

        for(int i=0; i<n; i++) {
            S[i] = sc.nextInt();
        }

        int q = sc.nextInt();
        int[] T = new int[q];

        for (int i = 0; i<q; i++) {
            T[i] = sc.nextInt();
        }

        sc.close();

        for(int i=0; i<q; i++) {

            int key = T[i];
            flag = 0;
            left = 0;
            right = S.length;

            while(left<right) {

                int mid = (left+right)/2;

                if(key == S[mid]) {
                    flag++;
                    break;
                }

                if(key > S[mid]) {
                    left = mid+1;
                } else if(key < S[mid]) {
                    right = mid;
                }

            }

            if(flag >= 1) {
                count++;
            }

        }

        System.out.println(count);

    }
}


Measured memory_bytes: 69252
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define iter2(c) for(auto it2=c.begin(); it2!=c.end(); it2++)
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define pmod(x,m) (((x)%(m)+m)%m)
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define debug
#endif
#define MAXN 100000

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

bool ok_bit[32];
int a[MAXN+5], b[MAXN+5];

bool check(int x)
{
    for0(i,30) {
        if (!ok_bit[i] and (x&(1<<i)))
            return false;
    }
    return true;
}

ll solve(int n)
{
    printa(ok_bit,30)
    ll res = 0;
    for (int i=0; i<n; i++) {
        if (check(a[i])) {
            pr(b[i])
            res += b[i];
        }
    }
    nl
    return res;
}

int32_t main()
{
    #ifdef DEBUG
    freopen("B.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    int n,k;
    cin >> n >> k;
    for0(i,n) {
        read(a[i]); read(b[i]);
    }
    
    vector<int> ones;
    for (int i=0; i<=30; i++) {
        if (k&(1<<i))
            ones.pb(i);
    }
    printv(ones);
    if (sz(ones) == 0) {
        ll ans = 0;
        for0(i,n) {
            if (a[i] == 0)
                ans += b[i];
        }
        cout<<ans<<endl;
        return 0;
    }
    
    for (int i=0; i<=30; i++)
        ok_bit[i] = i<ones.back();
    ll ans = 0;
    ll res = solve(n);
    ans = max(ans,res);
    
    for (int i=sz(ones)-1; i>0; i--) {
        ok_bit[ones[i]] = true;
        for (int j=ones[i]-1; j>=ones[i-1]; j--)
            ok_bit[j] = false;
        res = solve(n);
        ans = max(ans,res);
    }
    ok_bit[ones[0]] = true;
    for (int j=ones[0]-1; j>=0; j--)
        ok_bit[j] = false;
    res = solve(n);
    ans = max(ans,res);
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
($N,$K)=glob<>;
@V=glob<>;
for$i(-1..$N-1){
	for$j($i+1..$N){
		@_=sort{$a-$b}@V[0..$i,$j..$N-1];
		if($-=$K-@_+1){
			$x=0;$x+=/-/&&--$-?0:$_ for@_;
			$\+=$-=$x-$\
		}
	}
}
print


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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;

  for (int i = (int)s.size() - t.size(); i >= 0; i--) {
    bool ok = true;
    for (int j = 0; j < t.size(); j++) {
      ok &= s[i + j] == '?' || s[i + j] == t[j];
    }

    if (ok) {
      for (int j = 0; j < s.size(); j++) {
        if (i <= j && j < i + t.size()) {
          cout << t[j - i];
        } else if (s[j] == '?') {
          cout << 'a';
        } else {
          cout << s[j];
        }
      }
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const long double PI=3.14159265358979323846;


vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    ll tmp = 2;
    ll ans = a[0]-1;
    rep(i,1,n){
        if(tmp>=a[i]){
            chmax(tmp,a[i]+1);
            continue;
        }
        ans += (a[i]-1ll)/tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3964
# -*- coding: utf-8 -*-
# B

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

N = int(input())

for i in range(1, 10):
    if N % i == 0 and N // i < 10:
        print('Yes')
        sys.exit()
print('No')


Measured memory_bytes: 38512
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll a,ll b){
	return (b==0)?(a):(GCD(b,a%b));
}
ll LCM(ll a,ll b){
	return a/GCD(a,b)*b;
}
//
int main(){
	string S;
	cin>>S;
	if(S[0]!='A'){
		cout<<"WA"<<endl;
	}else{
		int L=S.size();
		int c=0;
		for(int i=2;i<L-1;i++){
			if(S[i]=='C'){
				c++;
			}
		}
		if(c!=1){
			cout<<"WA"<<endl;
		}else{
			for(int i=1;i<L;i++){
				if(S[i]>='a'&&S[i]<='z'){
					continue;
				}else{
                    if(S[i]=='C'){
                      continue;
                    }
					cout<<"WA"<<endl;
					return 0;
				}
			}
			cout<<"AC"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0,ans=0;

int main(){
   double d,t,s;
   cin >> d >> t >> s;
   if(d/s>t)
   cout << "No" << endl;
   else cout << "Yes" << endl; 
}

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

int main(){
  string S;
  ll ans=0;
   cin >> S;
  if (S.at(0)=='1') {
    for (int i=0; i < S.size(); i++) {
      if(i%2 == 0) { 
      if (S.at(i) != '1') ans++;
      }
      else {
      if (S.at(i) != '0') ans++;
          }
    }
          }
  if (S.at(0)=='0') {
    for (int i=0; i < S.size(); i++) {
      if(i%2 == 0) { 
      if (S.at(i) != '0') ans++;
      }
      else {
      if (S.at(i) != '1') ans++;
          }
    }
          }

    cout <<ans<< endl;
}


Measured memory_bytes: 512
n = input()
keta = len(n)

nine_count = 9
ans = 0
for i in range(1, keta):
    if i%2 == 1:
        ans += nine_count
    nine_count *=10

if keta%2 == 1:
    num = "1"
    for i in range(keta - 1):
        num += "0"
    ans += (int(n) - int(num) + 1)

print(ans)

Measured memory_bytes: 3060