akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;

int main(){
    long N, D;
    cin >> N >> D;
    int cnt=0;
    for(int i=0;i<N;i++){
        long X, Y;
        cin >> X >> Y;
        if(X * X + Y * Y <= D*D){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int k,x;
int main()
{
	cin>>k>>x;
	--k;
	for(int i=x-k;i<x;i++)
		cout<<i<<" ";
	cout<<x<<" ";
	for(int i=x+1;i<=x+k;i++)
		cout<<i<<" ";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N, K;
    cin >> N >> K;
    vector<pair<ll, ll>> num;
    Rep (i, N) {
        ll a, b;
        cin >> a >> b;
        num.push_back(make_pair(a, b));
    }

    sort(num.begin(), num.end());

    ll now = 0;
    ll ans;
    for (auto e : num) {
        now += e.second;
        if (K <= now) {
            cout << e.first << "\n";
            break;
        }
    }

}

Measured memory_bytes: 2420
#include <iostream>
#include<string>
#include<map>
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include <time.h>
#include<cmath>
#include<limits.h>
#include<unordered_map>
#include <set>
#include <iostream>     // std::cout, std::fixed
#include <iomanip>
#include<queue>
#define PI 3.1415926535897932384626433832795028841971693993
using namespace std;
const int N = 1e6 + 1;
double calcAngle(double h, double m)
{
    if (h == 12) h = 0;
    if (m == 60) m = 0;
    double hour_angle = 0.5 * (h * 60 + m);
    double minute_angle = 6 * m;
    double angle = abs(hour_angle - minute_angle);
    angle = min(360 - angle, angle);
    return angle;
}
int main() {
    double A,B,H,M; cin >> A >> B >> H >> M;
    double diff = calcAngle(H,M);
    long double ans = (A*A + B*B) - (2*A*B * cos(diff*PI/180));
    cout << setprecision(16)  <<fixed<<sqrt(double(ans)) << endl;
}



Measured memory_bytes: 4224
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(max(a,c)-min(a,c)<=d) cout<<"Yes"<<endl;
    else if(max(a,b)-min(a,b)<=d&&max(b,c)-min(b,c)<=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int get_index(char c) {
    if (0x41 <= c && c <= 0x5a) {
        return int(c) - 0x41;
    }
    if (0x61 <= c && c <= 0x7a) {
        return int(c) - 0x61;
    }
    return 26;
}

int main() {
    char alpha[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
                     'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
                     'u', 'v', 'w', 'x', 'y', 'z' };

    int count[27] = { 0 };

    for (;;) {
        string str;
        getline(cin, str);
        if (str == "\0") break;

        for (string::iterator it = str.begin(); it != str.end(); ++it) {
            ++count[get_index(*it)];
        }
    }

    for (int i = 0; i < 26; ++i) {
        cout << alpha[i] << " : " << count[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int A,B;
  cin>>A>>B;
  if(A%2&&B%2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define rep(i,n)        for(int i=0;i<n;i++)
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define Sort(v)         sort(v.begin(), v.end(), sortbysec)
#define setbits(x)      __builtin_popcountll(x)
#define rightmostbit(x) __builtin_ffsll(x)
#define leftzeros(x)    __builtin_clzll(x)
#define rightzeros(x)   __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout << fixed; cout << setprecision(x); cout << y;
#define pi              3.141592653589793238
#define mk(a,n)         int n;cin>>n;int a[n];for(int i=0;i<n;i++) cin>>a[i]
#define w(x)            int x; cin>>x; while(x--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{	return (a.second < b.second);
	// sorted by 2nd element in ascending order
}
void g_b()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
int32_t main()
{
	string s, t; cin >> s >> t;
	int c = 0;
	for (int i = 0; i < (int)s.size(); i++)
	{
		if (s[i] != t[i])c++;
	}
	cout << c;
	return 0;

}

Measured memory_bytes: 3864
import java.util.Scanner;

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

		int[][] c = new int[3][3];

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

		String ans = "No";

		if (c[0][0] - c[1][0] == c[0][1] - c[1][1] && c[0][0] - c[1][0] == c[0][2] - c[1][2])
			if (c[0][0] - c[2][0] == c[0][1] - c[2][1] && c[0][0] - c[2][0] == c[0][2] - c[2][2])
				if (c[1][0] - c[2][0] == c[1][1] - c[2][1] && c[1][0] - c[2][0] == c[1][2] - c[2][2])
					if (c[0][0] - c[0][1] == c[1][0] - c[1][1] && c[0][0] - c[2][1] == c[0][0] - c[2][1])
						if (c[0][0] - c[0][2] == c[1][0] - c[1][2] && c[0][0] - c[0][2] == c[2][0] - c[2][2])
							if (c[0][1] - c[0][2] == c[1][1] - c[1][2] && c[0][1] - c[0][2] == c[2][1] - c[2][2])
								ans = "Yes";

		System.out.println(ans);

	}

}


Measured memory_bytes: 22864
n = int(input())
h = list(map(int, input().split()))

sum = 0

# TODO: いろいろな人の関数名を参考にする
# h[0] ~ h[i-1]のなかで最大のhを取得
def get_max_h(i):
    max_h = 0
    if i > 0:
        max_h = max(h[:i])
    return max_h

for i in range(n):
    if h[i] >= get_max_h(i):
        sum += 1

print(sum)


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

int main()
{
  int n, d;
  int ice[10];

  while(1)
  {
    cin >> n;
    if(!n)
      break;

    for(int i = 0; i < 10; i++)
      ice[i] = 0;

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

    for(int i = 0; i < 10; i++)
    {
      for(int j = 0; j < ice[i]; j++)
        cout << '*';
      if(!ice[i])
        cout << '-';
      cout << endl;
    }
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int INF = 1e+18;

int sx,sy,gx,gy,n,lx,ly;

inline int ind(int x,int y,int t){
	return x + lx + (y + ly) * (lx * 2 + 1) + t * (lx * 2 + 1) * (ly * 2 + 1);
}

const int dx[] = {0,1,1,0,-1,-1},dy[2][6] = {{1,0,-1,-1,-1,0},{1,1,0,-1,0,1}};

template<class T>
struct Edge{
	int from,to;
	T cost;
	Edge(int to,T cost) : to(to),cost(cost){}
	Edge(int from,int to,T cost) : from(from),to(to),cost(cost){}
	operator int() const noexcept { return to; }
};

template<class T>
using WeightedGraph = vector<vector<Edge<T>>>;
using Graph = vector<vector<int>>;
template<class T>
using Matrix = vector<vector<T>>;

template<class T>
vector<T> dijkstra(const WeightedGraph<T> &G,int source = 0){
	using P = pair<T,int>;
	vector<T> dist(G.size(),INF);
	priority_queue<P,vector<P>,greater<P>> que;
	dist[source] = 0;
	que.emplace(dist[source],source);
	while(!que.empty()){
		P p = que.top();que.pop();
		int v = p.second;
		if(dist[v] < p.first) continue;
		for(const auto &e : G[v]){
			if(dist[e.to] > dist[v] + e.cost){
				dist[e.to] = dist[v] + e.cost;
				que.emplace(dist[e.to],e.to);
			}
		}
	}
	return dist;
}

template<class T>
ostream &operator<<(ostream &os,const Edge<T> &p){ return os << "(" << p.to << "," << p.cost << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

signed main(){
	using P = pair<int,int>;
	cin >> sx >> sy >> gx >> gy >> n;
	set<P> obj;
	for(int i = 0;i < n;i++){
		int x,y;
		cin >> x >> y;
		obj.emplace(x,y);
	}
	cin >> lx >> ly;
	WeightedGraph<int> G((lx * 2 + 1) * (ly * 2 + 1) * 6);
	for(int i = -lx;i <= lx;i++){
		for(int j = -ly;j <= ly;j++){
			for(int k = 0;k < 6;k++){
				for(int l = 0;l < 6;l++){
					int nx = i + dx[l],ny = j + dy[abs(i) % 2][l];
					if(-lx <= nx && nx <= lx && -ly <= ny && ny <= ly && !obj.count(P(nx,ny))){
						G[ind(i,j,k)].emplace_back(ind(nx,ny,(k + 1) % 6),abs(i * j * k) % 6 != l);
					}
				}
				G[ind(i,j,k)].emplace_back(ind(i,j,(k + 1) % 6),1);
			}
		}
	}
	auto dist = dijkstra(G,ind(sx,sy,0));
	int ans = INF;
	for(int i = 0;i < 6;i++) ans = min(ans,dist[ind(gx,gy,i)]);
	if(ans == INF) cout << -1 << endl;
	else cout << ans << endl;
}


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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int l, r; cin >> l >> r;
  if (r - l >= 2018) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> vec;
  for(int i=l; i<=r; i++) {
    vec.push_back(i%2019);
  }

  int ans = INT_MAX;
  int n = vec.size();
  for(int i=0; i<n; i++) {
    for(int j=i+1; j<n; j++) {
      chmin(ans, vec[i]*vec[j]%2019);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
def resolve():
    N = int(input())
    As = list(map(int, input().split(" ")))
    pos = []
    neg = []
    for a in As:
        if a >= 0:
            pos.append(a)
        else:
            neg.append(a)
    pos = deque(sorted(pos))
    neg = deque(sorted(neg))
    x = 0
    y = 0
    ops = []
    while True:
        if len(pos) > 0 and len(neg) > 0:
            if len(pos) > len(neg):
                x = neg.popleft()
                y = pos.pop()
            else:
                x = pos.pop()
                y = neg.popleft()
        elif len(pos) > 1 and len(neg) == 0:
                x = pos.popleft()
                y = pos.pop()
        elif len(neg) > 1 and len(pos) == 0:
                x = neg.pop()
                y = neg.popleft()
        else:
            raise Exception("Unreachable?")
        
        ops.append("{} {}".format(x, y))
        xmy = x - y

        if len(pos) == 0 and len(neg) == 0:
            print(xmy)
            break

        if xmy >= 0:
            pos.append(xmy)
        else:
            neg.appendleft(xmy)
        
    [print(i) for i in ops]

if '__main__' == __name__:
    resolve()

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int N;
intvec v;
int lim=150;

void input() {
	cin>>N;
}

void solve() {
	v.resize(N+1,0);
	for(int i=1; i<lim; i++) for(int j=1; j<lim; j++) for(int k=1; k<lim; k++) {
		int sum=i*i+j*j+k*k+i*j+j*k+k*i;
		if(sum<=N) v[sum]++;
	}
	for(int i=1; i<=N; i++) cout<<v[i]<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B;
    cin >> A >> B;
    cout << max(max((A + B), (A - B)), A * B) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	string S;
	int N;
	cin >> N>>S;
	
	rep(i, S.size()) {
		char a = ((S.at(i) - 'A')+N)%26+'A';
		cout << a ;
	}
		
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n;
	cin >> n;
	vector<P> s(n);
	rep(i, n)
		cin >> s[i].first >> s[i].second;

	ll ans = 0;
	rep(i, n){
		ans += s[i].second - s[i].first + 1;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod)
{
	ll ans=1;
	for(;y>0;y>>=1){
		if(y&1)(ans*=x)%=mod;
		(x*=x)%=mod;
	}
	return ans;
}

int x[11];
int r,d;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	cin >> r >> d >> x[0];
	rep(i, 1, 11) x[i] = r * x[i - 1] - d;
	rep(i, 1, 11) cout << x[i] << "\n";
	return 0;
}


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

int main() {
  int A, B, C, D, S1, S2;
  cin >> A >> B >> C >> D;
  S1 = A * B;
  S2 = C * D;
  if (S1 >= S2) {
    cout << S1;
  } else {
    cout << S2;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cctype>
using namespace std;

int main()
{
	char s;
	
	while(cin.get(s)){
		if(islower(s))
			s = toupper(s);
		else
			s = tolower(s);
		cout.put(s);
	}
	
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
int main(){
	int w[6]={2,3,5,10,12,15},m[6]={380,550,850,1520,1870,2244};
	int dp[51];
	rep(i,51)dp[i]=1000000000;
	dp[0]=0;
	for(int i=0;i<6;i++){
		for(int j=0;j<=50-w[i];j++){
			dp[j+w[i]]=min(dp[j+w[i]],dp[j]+m[i]);
		}
	}
	int n;
	while(cin>>n,n){
		cout<<dp[n/100]<<endl;
	}
}

Measured memory_bytes: 1160
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;


#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;


void Main(){
   int a, b;
  string op;
   cin >> a >> op >> b;
   
  if(op=="+")
  cout << a+b  << endl;
  else
  cout << a-b << endl;
 return;
 }
  
int main(){
 cin.tie(nullptr);
 ios_base::sync_with_stdio(false);
 cout << fixed << setprecision(15);
 Main();
 return 0;
 }


Measured memory_bytes: 256
N = int( input())
X = [ list( map( int, input().split())) for _ in range(N)]
for j in range(N):
    if X[j][2] != 0:
        k = j
        break
A = X[j]
for cx in range(101):
    for cy in range(101):
        H = A[2] + abs( A[0] - cx) + abs( A[1] - cy)
        Flag = True
        for i in range(N):
            if max( H - abs(X[i][0]-cx) - abs(X[i][1] - cy), 0) != X[i][2]:
                Flag = False
                break
        if Flag:
            print('{} {} {}'.format(cx, cy, H))
            break
    if Flag:
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;


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



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define maxn (1000+10)
#define mod 10000003
#define lnode node*2,start,mid
#define rnode node*2+1,mid+1,end
using namespace std;
struct node
{  int x;
   node(int a=0)
   {  x=a;
   } 
};
bool operator<(node a,node b)
{  return a.x<b.x;
}
priority_queue<node> q;
int main()
{   ios::sync_with_stdio(false);
	#define int ll

	int n,m,x,sum=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{  
	   cin>>x;
	   q.push(node(x));
	}
	for(int i=1;i<=m;i++)
	{  int k=(long long)q.top().x;
	   q.pop();
	   k/=2;
	   q.push(node(k));
	}
	for(int i=1;i<=n;i++)
	{  int k=(long long)q.top().x;
	   q.pop();
	   sum+=k; 
	   //cout<<k<<endl;
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 892
(defn abc165a [k a b]
  (if (or (> (- b a) k)
          (->> (range a (inc b))
               (map #(mod % k))
               (some zero?))) "OK"
      "NG"))

(let [k (read) [a b] [(read) (read)]]
  (println (abc165a k a b)))


Measured memory_bytes: 86520
H, N = list(map(int, input().split()))
A = []
for i in range(N):
    a = list(map(int, input().split()))
    A.append(a)

INF = float('INF')
MAX_J = (10 ** 4 + 1) * 2

# DP[i][j]: i番目までの魔法を使って、ダメージの総和をjにする魔力の最小値
DP = [INF] * MAX_J
DP[0] = 0

for i in range(N):
    for j in range(MAX_J):
        nj = min(j+A[i][0], H)
        DP[nj] = min(DP[nj], DP[j] + A[i][1])

print(DP[H])

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

int main()
{
    int n,m;
    scanf("%d%d",&m,&n);
    int x;
    for (int i=1;i<=n;i++) {
        scanf("%d",&x);
        m-=x;
    }
    printf("%d\n",max(m,-1));
    return 0;
}

Measured memory_bytes: 3868
import math
a,b,h,m=map(int,input().split())
x1=b*math.cos(math.radians(6*m))
y1=b*math.sin(math.radians(6*m))
x2=a*math.cos(math.radians((h*60+m)/2))
y2=a*math.sin(math.radians((h*60+m)/2))
print(((x1-x2)**2+(y1-y2)**2)**(1/2))

Measured memory_bytes: 9520
#include <iostream>
using namespace std;
const int MAXN=100005;
int n;
int a[MAXN],b[MAXN];
long long ans=0;

int main()

{
	ios::sync_with_stdio(false);
	cin>>n;
	for (int i=1;i<=n+1;i++)
		cin>>a[i];

	for (int i=1;i<=n;i++){
		cin>>b[i];
		if (b[i]>=a[i]){
			b[i]-=a[i];
			ans+=a[i];
			a[i]=0;
			if (b[i]>=a[i+1]){
				ans+=a[i+1];
				a[i+1]=0;
			}
			else{
				a[i+1]-=b[i];
				ans+=b[i];
			}
		}
		else{
			ans+=b[i];
			a[i]-=b[i];
		}
	}

	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (ll)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

void solve(){
	ll n,m;
	ll odd=0,even=0;
	cin>>n>>m;
	vector<ll> a(n);
	rep(i,0,n){
		cin>>a[i];
		a[i]/=2; 
		if(a[i]&1){
			odd = 1;
		}else{
			even = 1;
		}
	}
	
	ll ans=a[0];
	rep(i,1,n){
		if(ans>m){
			cout<<0<<endl;
			return ;
		}
		if(ans%a[i]){
			ans = ans*a[i]/__gcd(ans,a[i]);
		}
	}
	for(auto x:a){
		if(ans/x%2==0){
			cout<<0;
			return ;
		}
	}
	cout<<1+(m-ans)/(2*ans);
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;
ll n, m, x;
vector<vector<ll>> a;
vector<ll> cost;
ll ans = INF;

void dfs(vector<int> v) {
  if ((ll)v.size() == n) {
    vector<ll> score(m, 0);
    ll money = 0;
    // rep(i, n) cout << v[i] << " ";
    // cout << endl;
    rep(i, n) {
      if (v[i] == 1) {
        rep(j, m) score[j] += a[i][j];
        money += cost[i];
      }
    }
    // rep(i, m) cout << score[i] << " ";
    // cout << endl;
    bool flg = true;
    rep(i, m) {
      if (score[i] < x) flg = false;
    }
    if (flg) chmin(ans, money);
    return;
  }

  v.push_back(0);
  dfs(v);
  v.back()++;
  dfs(v);
}

int main() {

  cin >> n >> m >> x;
  a.assign(n, vector<ll>(m));
  cost.resize(n);

  rep(i, n) {
    cin >> cost[i];
    rep(j, m) cin >> a[i][j];
  }

  dfs(vector<int>(0));

  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    long ans;
    foreach (i; 0 .. N)
    {
        while (A[i] % 2 == 0)
            ans++, A[i] /= 2;
    }
    writeln(ans);
}


Measured memory_bytes: 2684
#include <bits/stdc++.h>
    using namespace std;
     
    using Matrix = array<array<int, 26>, 26>;
     
    struct Trie
    {
        array<Trie*, 26> children;
        Matrix* counts;
        int prefixes, size;
        bool is_terminal;
     
        Trie* insert(string::const_iterator c)
        {
            size++;
            if (*c == 0)
            {
                is_terminal = true;
                return this;
            }
            else
            {
                auto& child = children[*c-'a'];
                if (child == nullptr) child = new Trie{};
                return child->insert(next(c));
            }
        }
     
        void preprocess(Matrix& current)
        {
            if (is_terminal) counts = new Matrix(current);
     
            for (auto i = 0; i < 26; i++) if (children[i] != nullptr)
            {
                children[i]->prefixes = prefixes + is_terminal;
     
                for (auto j = 0; j < 26; j++) if (j != i && children[j] != nullptr)
                    current[j][i] += children[j]->size;
     
                children[i]->preprocess(current);
     
                for (auto j = 0; j < 26; j++) if (j != i && children[j] != nullptr)
                    current[j][i] -= children[j]->size;
            }
        }
    };
     
    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
     
        auto trie = new Trie{};
     
        int N; cin >> N;
        auto nodes = vector<Trie*>(N);
        for (auto i = 0; i < N; i++)
        {
            string s; cin >> s;
            nodes[i] = trie->insert(s.cbegin());
        }
     
        auto counts = Matrix{};
        trie->preprocess(counts);
     
        int Q; cin >> Q;
        for (auto q = 0; q < Q; q++)
        {
            int k; string order; cin >> k >> order;
            k--;
     
            auto result = nodes[k]->prefixes;
            for (auto j1 = 0; j1 < 26; j1++) for (auto j2 = j1+1; j2 < 26; j2++)
                result += (*nodes[k]->counts)[order[j1]-'a'][order[j2]-'a'];
            cout << result+1 << "\n";
        }
    }

Measured memory_bytes: 295040
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


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

    ll N ;
    cin >> N ;
    ll ans = 0 ;
    ll now = -1;
    rep(i, N){
        ll inp; cin >> inp;
        if(now <= inp){
            ans ++;
            now = inp;
        }
    }

    cout << ans << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200)
    {
        cout << s << endl;
    }
    else
    {
        cout << "red" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pp;

int n, k;
const int M = 524288;

int fen[500010];
int fens(int p){
	int ret=0;
	while(p) ret+=fen[p], p&=(p-1);
	return ret;
}
void fenu(int p, int v){
	while(p<=n) fen[p]+=v, p+=(p&-p);
}
int fenr(int l, int r){
	l=max(l, 0); r=min(r, n);
	return fens(r)-(l?fens(l-1):0);
}

pp tree[M<<1];
int lazy[M<<1];
void uke(int p, int v){
	tree[p].first += v;
	lazy[p] += v;
}
void pd(int p, int l, int r){
	if(l==r || !lazy[p]) return;
	uke(p*2, lazy[p]);
	uke(p*2+1, lazy[p]);
	lazy[p]=0;
}
void upd(int pt, int v, int l=1, int r=n, int p=1){
	pd(p, l, r);
	if(l==r){
		tree[p]={v, l};
		return;
	}
	int mid=(l+r)/2;
	if(pt<=mid) upd(pt, v, l, mid, p*2);
	else upd(pt, v, mid+1, r, p*2+1);
	tree[p]=min(tree[p*2], tree[p*2+1]);
}

void updr(int ul, int ur, int l=1, int r=n, int p=1){
	pd(p, l, r);
	if(ul<=l && r<=ur){
		uke(p, -1);
		return;
	}
	if(ur<l || r<ul) return;
	int mid=(l+r)/2;
	updr(ul, ur, l, mid, p*2);
	updr(ul, ur, mid+1, r, p*2+1);
	tree[p]=min(tree[p*2], tree[p*2+1]);
}

int a[500010];
int ans[500010];

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1; i<=n; ++i){
		int x; scanf("%d", &x); a[x]=i;
	}
	for(auto& x:tree) x={2e9, 0};
	for(int i=1; i<=n; ++i){
		int x=a[i];
		int indeg = fenr(x-k+1, x+k-1);
		fenu(x, 1);
		upd(x, indeg);
	}
	for(int i=1; i<=n; ++i){
		int x=tree[1].second;
		ans[x]=i;
		upd(x, 2e9);
		updr(max(1, x-k+1), min(n, x+k-1));
	}
	for(int i=1; i<=n; ++i){
		printf("%d\n", ans[i]);
	}
	return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i,m,n) for(int (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

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

    vector<ll> a(N+1);
    REP(i,1,N+1) cin >> a[i];

    vector<ll> b(N+1);
    ll s;
    for(ll i=N; i>=1; --i){
        s = 0;
        for(ll j=i+i; j<=N; j+=i) s += b[j];
        b[i] = (s + a[i]) % 2;
    }

    ll cnt = 0;
    REP(i,1,N+1)
        if(b[i] == 1) ++cnt;
    cout << cnt << endl;
    REP(i,1,N+1)
        if(b[i] == 1) cout << i << " ";
    cout << endl;

    return 0;
}

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

int main() {
    string s;
    cin >> s;
    s.erase(remove(s.begin(), s.end(), '/'), s.end());
    string last_heisei = "20190430";
    cout << (s <= last_heisei ? "Heisei" : "TBD") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define ll long long 
ll max(ll a,ll b){if(a>b) return a; return b;}
int main(){
    int n;
    scanf("%d",&n);
    ll a[n+2],b[n+1];
    int i,j;
    ll ans=0;
    for(i=1;i<=n+1;i++)
        scanf("%lld",&a[i]);
    for(i=1;i<=n;i++)
        scanf("%lld",&b[i]);
    for(i=1;i<=n;i++){
        if(b[i]<(a[i]+a[i+1])){
            ans+=b[i];
            ll p=a[i]-b[i];
            a[i]=max(0,p);
            if(a[i]==0){
                a[i+1]-=-p;
            }
        }
        else{
            ans+=a[i]+a[i+1];
            a[i]=0;
            a[i+1]=0;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

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

long long gcd(long long a, long long b){
  long long x = max(a, b), y = min(a, b);
  if(y == 0){
    return x;
  }
  return gcd(y, x % y);
}

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

  vector<long long> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
    a[i] /= 2;
  }
  long long lcm = a[0];
  for(int i = 0; i < N; i++){
    lcm = lcm * a[i] / gcd(lcm, a[i]);
    //cout << lcm << endl;
    if(lcm > M){
      cout << 0 << endl;
      return 0;
    }
  }
  //cout << "lcm: " << lcm << endl;

  bool ng = any_of(a.begin(), a.end(),
                   [=](auto val){return (lcm / val) % 2 == 0;});
  if(ng){
    //cout << "ng" << endl;
    cout << 0 << endl;
    return 0;
  }

  cout << (M + lcm) / (lcm * 2) << endl;
  
}


Measured memory_bytes: 1024
N = int(input())
K = int(input())
xx = list(map(int, input().split()))

border = K // 2
ans = 0
for x in xx:
    if x <= border:
        # A が動く
        ans += x * 2
    else:
        # B が動く
        ans += (K - x) * 2
print(ans)


Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A + B >= C) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
int main()
{
	int h, w;
	cin >> h >> w;
	int sy, sx;
	cin >> sy >> sx;
	sy += 1; sx += 1;
	int fy, fx;
	cin >> fy >> fx;
	fy += 1;
	fx += 1;
	vector<vector<char>> grid(h + 4, vector<char>(w + 4, '#'));
	for (int i = 2; i <= h + 1; i++) {
		for (int j = 2; j <= w + 1; j++) {
			cin >> grid[i][j];
		}
	}
	/*for (int i = 0; i <= h + 3; i++) {
		for (int j = 0; j <= w + 3; j++) {
			if (i == sy && j == sx) cout << 'S';
			else if (i == fy && j == fx) cout << 'F';
			else cout << grid[i][j];
		}
		cout << "\n";
	}*/

	vector<vector<long long>> vis(h + 4, vector<long long>(w + 4));
	queue<pair<int, int>> q;
	vector<pair<int, int>> v;
	q.push({ sy,sx });
	v.push_back({ sy,sx });
	vis[sy][sx] = 1;
	long long ans = 0;
	while (!q.empty() && vis[fy][fx] == 0)
	{
		auto cell = q.front();
		int y = cell.first, x = cell.second;
		q.pop();
		if (vis[y + 1][x] == 0 && grid[y + 1][x]=='.')
		{
			vis[y + 1][x]++;
			v.push_back({ y + 1,x });
			q.push({ y + 1,x });
		}
		if (vis[y - 1][x] == 0 && grid[y - 1][x]=='.')
		{
			vis[y - 1][x]++;
			v.push_back({ y - 1,x });
			q.push({ y - 1,x });
		}
		if (vis[y][x+1] == 0 && grid[y][x+1]=='.')
		{
			vis[y][x+1]++;
			v.push_back({ y,x+1 });
			q.push({ y,x+1 });
		}
		if (vis[y][x-1] == 0 && grid[y][x-1]=='.')
		{
			vis[y][x-1]++;
			v.push_back({ y,x-1 });
			q.push({ y,x-1 });
		}
		if (q.empty() && vis[fy][fx] == 0)
		{
			ans++;
			vector<pair<int, int>> v2;
			for (auto e : v)
			{
				int y = e.first, x = e.second;
				for (int i = y - 2; i <= y + 2; i++)
				{
					for (int j = x - 2; j <= x + 2; j++)
					{
						if (vis[i][j] == 0 && grid[i][j] == '.')
						{
							q.push({ i,j });
							v2.push_back({ i,j });
							vis[i][j]++;
						}
					}
				}
			}
			v.clear();
			v = v2;
		}
	}
	if (vis[fy][fx] == 0)cout << -1;
	else  cout << ans;
}

Measured memory_bytes: 12708
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=1,w=1,n=10001,m=1010,o=100;
  std::cin >> x>>y;
  std::vector<int> v(100000,0);
  for(int i= 1;i<10;i++){
    for(int j= 0;j<10;j++){
      for(int k= 0;k<10;k++){
        v[i*n+j*m+k*o]++;
      }
    }
  }
  rep(i,99999){
    v[i+1]+=v[i];
  }

    std::cout << v[y]-v[x-1] << '\n';
}


Measured memory_bytes: 1024
/*
 * a.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100000;

const string tnames[] = { "root", "internal node", "leaf" };

/* typedef */

typedef vector<int> vi;

/* global variables */

int prts[MAX_N], ds[MAX_N];
vi nbrs[MAX_N];

/* subroutines */

inline int ntype(int id) {
  if (prts[id] < 0) return 0;
  if (nbrs[id].size() == 0) return 2;
  return 1;
}

void rec(int u) {
  vi &nbru = nbrs[u];
  for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
    int &v = *vit;
    ds[v] = ds[u] + 1;
    rec(v);
  }
}

/* main */

int main() {
  memset(prts, -1, sizeof(prts));

  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int ci;
      cin >> ci;
      nbrs[u].push_back(ci);
      prts[ci] = u;
    }
  }

  int root;
  for (int i = 0; i < n; i++)
    if (prts[i] < 0) {
      root = i;
      break;
    }

  ds[root] = 0;
  rec(root);
  
  for (int i = 0; i < n; i++) {
    printf("node %d: parent = %d, depth = %d, %s, [",
	   i, prts[i], ds[i], tnames[ntype(i)].c_str());
    for (int j = 0; j < nbrs[i].size(); j++) {
      if (j) printf(", ");
      printf("%d", nbrs[i][j]);
    }
    printf("]\n");
  }

  return 0;
}

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

#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

using namespace std;
/**************************************************************************/
ll arr[1001][1001];
int main()
{
    fastIO;
    ll t,n,i,j,k,val=0,st=1, ed = 1e5, md;
    cin>>n;
    while(st<=ed)
    {
        md = st + ( ed - st ) / 2;
        if(md*(md-1)/2==n)
        {
            val = md;
            break;
        }
        if(md*(md-1)/2<n)st=md+1;
        else ed=md-1;
    }
    if(val==0){cout<<"No";return(0);}cout<<"Yes"<<endl;
    cout<<val<<endl;
    ll cnt1 = 1, cnt2 = 1;

    fo(i,val)
    {
        Fo(j,i,val-1)
        {
            arr[i][j] = cnt1++;
        }
        Fo(j,i+1,val)
        {
            arr[j][i] = cnt2++;
        }
    }

    fo(i,val)
    {
        cout<<val-1<<" ";
        fo(j,val-1)cout<<arr[i][j]<<" ";
        cout<<endl;
    }

}
/*************************************************************************/

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    ll n;
    cin >> n;
    ll x = 3 * n;
    ll a[x];
    for (ll i = 0; i < x; i++) cin >> a[i];
    sort(a, a+x, greater<ll>());
    ll sum = 0, cnt = 0;
    for (ll i = 1; cnt < n; i += 2, cnt++) {
        sum += a[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	long long int n;
	cin >> n;
	long long int a[n]; 
	for(int i=0;i<n;i++){
      	cin >> a[i];
	}  
  	long long int x;
  	cin >> x;
	long long int b[x]; 
  	for(int i=0;i<x;i++){
      	cin >> b[i];
	}  
	long long int c;
  	c = 0;
  	for(int i=0;i<x;i++){
		int D,U;
      	D = 0;
      	U = n-1;
       	while((U - D) != 0){
          	if(a[(U+D)/2] < b[i]){
              D = (U+D)/2 + 1;
            }else if(a[(U+D)/2] >= b[i]){
              U = (U+D)/2;
            }
        }
		if(a[U] == b[i]){
			c = c + 1;
		}
	}
	cout << c << endl;
}


Measured memory_bytes: 4260
n = gets.chomp.to_i
a = []
b = []

n.times do
    _a, _b = gets.chomp.split(" ").map(&:to_i)
    a << _a
    b << _b
end

a.sort!
b.sort!

if n % 2 == 0 then
    puts b[n/2] + b[n/2-1] - a[n/2] - a[n/2-1] + 1
else
    puts b[n/2] - a[n/2] + 1
end

Measured memory_bytes: 20488
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

const LL MOD = 1000000007;

int w[105];

int main() {
	int n;
	scanf("%d", &n);
	REP(i, n)scanf("%d", &w[i]);
	int ret = 1e9;
	FOR(i, 1, n) {
		int s1 = 0;
		int s2 = 0;
		REP(j, i)s1 += w[j];
		FOR(j, i, n)s2 += w[j];
		ret = min(ret, abs(s1 - s2));
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 256
import sys

def main():
	n,k = map(int,input().split())
	a = list(map(int,input().split()))
	b = {}
	for i in a:
		try:
			b[i] += 1
		except:
			b[i] = 1
	b = sorted(b.items(), key=lambda x: x[1])
	nagasa = len(b)
	cost = 0
	for i in range(nagasa-k):
		cost += b[i][1]
	print(cost)

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()

Measured memory_bytes: 38964
from sys import stdin


def rec(n, k, cnt):
    if n < k:
        return cnt + 1
    else:
        q, mod = divmod(n, k)
        cnt += 1
        n = q
        return rec(n, k, cnt)


def main():
    N, K = [int(x) for x in stdin.read().rstrip().split()]
    print(rec(N, K, 0))


if __name__ == "__main__":
    main()


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

int main(){
    string s;
    cin>>s;
    
    for(int i=0;i<s.size();i++){
        if(s[i]=='7'){
            cout<<"Yes\n";
            return 0;
        }
    }
    
    cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3628
import sys
buf = sys.stdin.buffer


class UnionFind:
    def __init__(self, num_of_node):
        self.roots = [-1] * num_of_node
        self.groups = num_of_node

    def get_root(self, node):
        root = self.roots[node]
        if root == -1:
            return node

        else:
            root = self.get_root(root)
            self.roots[node] = root
            return root

    def is_same_group(self, node1, node2):
        return self.get_root(node1) == self.get_root(node2)

    def unite(self, node1, node2):
        self.groups -= 1
        root1, root2 = self.get_root(node1), self.get_root(node2)
        self.roots[root2] = root1


def main():
    n = int(buf.readline())
    XY = map(int, buf.read().split())
    Xs = []
    Ys = []
    for i, (x, y) in enumerate(zip(XY, XY)):
        Xs.append((x-1, i))
        Ys.append((y-1, i))

    Xs.sort()
    Ys.sort()

    edges = []
    for i, ((x, node), (nx, new_node)) in enumerate(zip(Xs[:-1], Xs[1:])):
        edges.append((nx-x, node, new_node))

    for i, ((y, node), (ny, new_node)) in enumerate(zip(Ys[:-1], Ys[1:])):
        edges.append((ny-y, node, new_node))

    edges.sort(reverse=True)

    ans = 0
    uf = UnionFind(n)
    while uf.groups != 1:
        d, node1, node2 = edges.pop()
        if uf.is_same_group(node1, node2):
            continue
        uf.unite(node1, node2)
        ans += d

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 56556
package main

import (
	"fmt"
)

func main() {
	var (
		a     string
		count = 0
	)
	fmt.Scan(&a)
	for i := 0; i < len(a); i++ {
		if a[i] == '1' {
			count++
		}
	}
	fmt.Println(count)
}

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

int main() {
	long long int c = 0;
	int n; cin >> n;
	vector<int> a(n + 1);
	for (auto& vec : a) cin >> vec;
	for (int i = 0; i < n; ++i) {
		int b; cin >> b;
		if (a[i] - b < 0) {
			c += a[i]; b -= a[i];
			if (a[i + 1] - b < 0) {
				c += a[i + 1]; a[i + 1] = 0;
				continue;
			}
			a[i + 1] -= b;
			c += b;
			continue;
		}
		c += b;
	}
	cout << c << endl;
}

Measured memory_bytes: 640