akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T> ostream& operator<<(ostream &os, vector<T> &v){os << "{";ITR(i,v){if(i!=v.begin())os << ","; os << *i;}os << "}"; return os;}
template <typename T, typename U> ostream& operator<<(ostream& os, pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

const LLI mod = 1e9+7;

LLI dp[30][1<<21];

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

  int N; cin >> N;
  vector<vector<int>> a(N, vector<int>(N)); cin >> a;

  dp[0][0] = 1;
  
  REP(i,N){
    REP(j,1<<N){
      if(__builtin_popcount(j) != i+1) continue;
      dp[i+1][j] = dp[i][j];

      REP(k,N){
	if(a[i][k] == 1 && (1<<k)){
	  (dp[i+1][j] += dp[i][j ^ (1<<k)]) %= mod;
	}
      }
    }
  }

  cout << dp[N][(1<<N)-1] << endl;

  return 0;
}


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

int k;
long long ans;

int main()
{
	cin>>k;
	for(int i=1;i<=k;i++)
		for(int j=1;j<=k;j++)
			for(int l=1;l<=k;l++)
				ans+=__gcd(i,__gcd(j,l));
	cout<<ans;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 150;

int N;
int a[MAX_N], dist_num[MAX_N] = {};

bool solve() {
    int max_dist = a[1];
    int min_dist = a[1];
    for (int i = 1; i <= N; i++) {
        dist_num[a[i]]++;
        max_dist = std::max(max_dist, a[i]);
        min_dist = std::min(min_dist, a[i]);
    }

    if (N == 2) {
        return dist_num[1] == 2;
    }

    //if (dist_num[max_dist] == 1) {
    //    return false;
    //}

    for (int i = min_dist + 1; i <= max_dist; i++) {
        if (dist_num[i] < 2) {
            return false;
        }
    }

    if (max_dist % 2 == 0) {
        if ((min_dist == max_dist / 2) && dist_num[min_dist] == 1) {
            return true;
        } else {
            return false;
        }
    } else {
        //std::cout << "check:" << min_dist << " " << max_dist << " " << dist_num[min_dist] << std::endl;
        if ((min_dist == max_dist / 2 + 1) && dist_num[min_dist] == 2) {
            return true;
        } else {
            return false;
        }
    }
}

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> a[i];
    }

    if (solve()) {
        std::cout << "Possible" << std::endl;
    } else {
        std::cout << "Impossible" << std::endl;
    }

    return 0;
}



Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, i321) => {
        read_value!($next, i32) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// # Examples
//
// # integers
// input! { n: i32, m: i32, ... }
//
// # array
// input! { n: i32, v: [i32; n], }
//
// # matrix
// input! { n: i32, m: i32, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: i32,
//     w: i32,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: i32, b: i32, c: i32,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {
    input! { mat: [chars; 3] }
    println!("{}{}{}", mat[0][0],mat[1][1],mat[2][2]);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  int x, y, a, b, c, nr, ng;
  ll o;
  scanf("%d %d %d %d %d", &x, &y, &a, &b, &c);
  vector<ll> p(a), q(b), r(c), ap(x + 1), aq(y + 1), ar(min(c, x + y) + 1);
  for(int i = 0; i < a; i++) scanf("%lld", &p[i]);
  for(int i = 0; i < b; i++) scanf("%lld", &q[i]);
  for(int i = 0; i < c; i++) scanf("%lld", &r[i]);
  sort(p.begin(), p.end(), greater<ll>());
  sort(q.begin(), q.end(), greater<ll>());
  sort(r.begin(), r.end(), greater<ll>());
  ap[1] = p[0];
  aq[1] = q[0];
  ar[1] = r[0];
  for(int i = 2; i <= x; i++) ap[i] = ap[i - 1] + p[i - 1];
  for(int i = 2; i <= y; i++) aq[i] = aq[i - 1] + q[i - 1];
  for(int i = 2; i <= min(c, x + y); i++) ar[i] = ar[i - 1] + r[i - 1];
  nr = x, ng = y;
  o = ap[x] + aq[y];
  for(int i = 1; i <= min(c, x + y); i++) {
    if(ap[nr - 1] + aq[ng] < ap[nr] + aq[ng - 1] && ng || nr == 0) {
      o = max(o, ap[nr] + aq[ng - 1] + ar[i]);
      ng--;
    } else {
      o = max(o, ap[nr - 1] + aq[ng] + ar[i]);
      nr--;
    }
  }
  printf("%lld\n", o);
}

Measured memory_bytes: 4864
import std.stdio;
import std.conv;
import std.string;

const int DATA = 200;

int main() {
  int data = to!(int)(chomp(readln));
  string[] result = new string[data];

  for(int i=0; i<data; i++) {
    int a, b, c, tmp; // a:max
    string[] input = (chomp(readln)).split(" ");
    a = to!(int)(input[0]);
    b = to!(int)(input[1]);
    c = to!(int)(input[2]);
    if(a<b) {
      tmp = a;
      a = b;
      b = tmp;
    }
    if(a<c) {
      tmp = a;
      a = c;
      c = tmp;
    }
    if(a*a == b*b+c*c) result[i]="YES";
    else result[i]="NO";
  }

  for(int i=0; i<data; i++) writeln(result[i]);
  
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;


typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

vector<int> G[100005];
std::vector<P> tree[100010];

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};

ll i,j,k,l,ii,jj;
ll a,b;

int main(){
    cin>>a>>b;
    if(a*b<=0){
        cout<<"Zero"<<endl;
    }else if(a>0 || (b<0 && (a+b)%2!=0)){
        cout<<"Positive"<<endl;
    }else{
        cout<<"Negative"<<endl;
    }
    return 0;
}


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

int main() {
  vector<int> a(5);
  int k;
  for(int i=0; i<5; i++) 
    cin >> a.at(i);
  cin >> k;
  
  int m = a.at(0);
  int M = a.at(0);
  
  for(int i=0; i<5; i++) {
    m = min(m, a.at(i));
    M = max(M, a.at(i));
  }
  
  if(M - m > k)
    cout << ":(" << endl;
  else
    cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#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 setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int x, k, d; cin >> x >> k >> d;

	int rem = (x) % d;
	int xdash = abs(x) / d;

	// cout << rem << ' ' << xdash << '\n';
	if(x >= 0)
	{
		if(k <= xdash)
		{
			cout << abs(x - (k * d)) << '\n';
			return 0;
		}

		if(k > xdash)
		{
			k -= xdash;
			k = (k % 2) ? 1 : 0;

			cout << abs(rem - (k * d)) << '\n';
			return 0;
		}
	}
	else
	{
		if(k <= xdash)
		{
			cout << abs(x + (k * d)) << '\n';
			return 0;
		}

		if(k > xdash)
		{
			k -= xdash;
			k = (k % 2) ? 1 : 0;

			// cout << rem << '\n';
			cout << abs(rem + (k * d)) << '\n';
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}



int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,l;cin >> n >> l;
	vector<int> a(n);
	rep(i,n) a.at(i)=l+i;
	int sum=0;
	rep(i,n) sum+=a.at(i);
	if(a.at(0)>=0) cout << sum-a.at(0) << endl;
	else if(a.at(n-1)<0) cout << sum-a.at(n-1) << endl;
	else cout << sum << endl;
}


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

public class Main{

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		ArrayList<String[]> all = new ArrayList<String[]>();
		int count = 0;

		while (true) {
			String[] kari = new String[2];
			kari[0] = sc.nextLine();

			if (kari[0].equals("0")) {
				break;
			}

			kari[1] = sc.nextLine();

			all.add(kari);
			count++;
		}

		for (int i = 0; i < count; i++) {
			String[] kari = all.get(i);
			double n = Double.parseDouble(kari[0]);
			String[] stu = kari[1].split(" ");
			double[] student = new double[(int)n];
			double sum = 0;
			for (int j = 0; j < n; j++) {
				student[j] = Double.parseDouble(stu[j]);
				sum += student[j];
			}
			double m = sum / n;

			double answer = 0;
			for (int j = 0; j < n; j++) {
				answer += (student[j] - m) * (student[j] - m);
			}
			System.out.println(Math.sqrt(answer/n));
		}

	}

}

Measured memory_bytes: 29276
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
const long long INF = 1LL << 60;
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    int p[n];
    rep(i, n) cin >> p[i];
    int pp[n];
    rep(i, n) pp[p[i] - 1] = i + 1;
    int a[n];
    a[0] = pp[0];
    rep(i, 1, n)
    {
        a[i] = a[i - 1] + pp[i];
    }
    int b[n];
    b[0] = a[n - 1];
    rep(i, 1, n)
    {
        b[i] = b[i - 1] - pp[i - 1];
    }
    rep(i, n) cout << a[i] << " ";
    cout << endl;

    rep(i, n) cout << b[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
int n;cin>>n;
  int sum=0,maxL=0;
  for(int i=0;i<n;i++)
  {
    int l;cin>>l;
    sum+=l;
    maxL=max(maxL,l);
  }
  if(sum-maxL>maxL)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
    


Measured memory_bytes: 256
n=int(input())
es=[[] for _ in range(n)]

for _ in range(n-1):
    a,b,c=map(int,input().split())
    es[a-1].append((b-1,c))
    es[b-1].append((a-1,c))

from heapq import heappush, heappop
def dijkstra(edges, size, source):
    distance = [float('inf')] * size
    distance[source] = 0
    visited = [False] * size
    pq = []
    heappush(pq, (0, source))
    while pq:
        dist_v, v = heappop(pq)
        visited[v] = True
        for u, weight in edges[v]:
            if not visited[u]:
                new_dist = dist_v + weight
                if distance[u] > new_dist:
                    distance[u] = new_dist
                    heappush(pq, (new_dist, u))
    return distance


q,k=map(int,input().split())
k-=1
dist=dijkstra(es,n,k)
for _ in range(q):
    x,y=map(int,input().split())
    x-=1
    y-=1
    print(dist[x]+dist[y])

Measured memory_bytes: 104444
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x; cin >> x;
  cout << 1-x << endk;
  return 0;
}


Measured memory_bytes: 3652
K,N=map(int,input().split())
A=list(map(int,input().split()))
n=0
j=[-1, -1]

for i in range(N):
  if i + 1 < N:
    if A[i + 1] - A[i] > n:
      n = A[i + 1] - A[i]
      j = [i, i+1]
  else:
    if K - A[i] + A[0] > n:
      n = K - A[i] + A[0]
      j = [i, 0]
print(K - n)

Measured memory_bytes: 25452
#include <iostream>
#include <string>

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

int main ()
{
  string w;
  int count;

  cin >> w;

  for (char x : w) {
    for (int i = 0; i < w.length(); i++) {
      if (x == w[i]) {
        count++;
      }
    }
    if (count % 2 != 0) break;
  }
  if (count % 2 != 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        long[] a = new long[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextLong()/2;
        }
        long lcm = lcm(a);
        int count_l = 0;
        long l = lcm;
        while (l % 2 == 0) {
            l /= 2;
            count_l += 1;
        }
        for (int i = 0; i < N; i++) {
            int count_t = 0;
            while (a[i] % 2 == 0) {
                a[i] /= 2;
                count_t += 1;
            }
            if (count_l != count_t) {
                System.out.println(0);
                return;
            }
        }
        long ans = (M / lcm + 1) / 2;
        System.out.println(ans);
    }
    private long gcd(long x, long y) {
        if (y == 0) {
            return x;
        }
        return gcd(y, x % y);
    }

    private long lcm(long x, long y) {
        return x * y / gcd(x, y);
    }

    private long lcm(long[] a) {
        long x = a[0];
        for (int i = 0; i < a.length; i++) {
            x = lcm(a[i], x);
        }
        return x;
    }
}


Measured memory_bytes: 60020
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  int ans = 0;
  vec v(N), c(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> c[i];
  }

  for (int i = 0; i < N; i++) {
    ans += max(0LL, v[i] - c[i]);
  }

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


Measured memory_bytes: 256
from heapq import heappush, heappop, heapify


def main():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    hq = [(-1) * i for i in A]
    heapify(hq)
    cnt = 0
    while cnt < m:
        a = (-1) * heappop(hq)
        a //= 2
        heappush(hq, (-1) * a)
        cnt += 1
    print((-1) * sum(hq))


if __name__ == '__main__':
    main()

Measured memory_bytes: 14180
import math


def main():
    N, A, B, C = map(int, input().split())
    s = [input() for _ in range(N)] + ['']

    # dp_abc = [None for _ in range(N+1)]
    # dp_history = [[] for _ in range(N+1)]
    #
    # dp_abc[0] = (A, B, C)

    history = []

    cnt = {
        'A': A,
        'B': B,
        'C': C,
    }

    for i in range(N):
        x, y = s[i][0], s[i][1]
        if cnt[x] > cnt[y]:
            cnt[x] -= 1
            cnt[y] += 1
            history.append(y)
        elif cnt[x] < cnt[y]:
            cnt[x] += 1
            cnt[y] -= 1
            history.append(x)
        else:
            if x in s[i + 1]:
                cnt[x] += 1
                cnt[y] -= 1
                history.append(x)
            else:
                cnt[x] -= 1
                cnt[y] += 1
                history.append(y)

        if cnt[x] < 0 or cnt[y] < 0:
            print('No')
            return

    print('Yes')
    for c in history:
        print(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 17040
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

const map<LLONG, LLONG> Divide(LLONG N)
{
    map<LLONG, LLONG> prime2NumMap;
    for (LLONG p = 2; p * p <= N; ++p)
    {
        if (N % p != 0) continue;
        while (N % p == 0)
        {
            N /= p;
            ++prime2NumMap[p];
        }
    }
    if (N != 1) prime2NumMap[N] = 1;
    return prime2NumMap;
}

int main()
{
    LLONG N; cin >> N;
    if (N == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    const auto prime2NumMap = Divide(N);
    LLONG ans = 0;
    for (const auto &kvp : prime2NumMap)
    {
        LLONG num = kvp.second;
        LLONG e = 1;
        while (num >= e)
        {
            ++ans;
            num -= e;
            ++e;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main() {
  int a;
  int b;
  cin >> a >> b;
  if (a > b) {
    cout << "a > b" << endl;
      }
  if (b > a) {
    cout << "a < b" << endl;
      }
  if (b == a) {
    cout << "a == b" << endl;
      }
  return 0;
}



Measured memory_bytes: 3084
use std::io::Read;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();
    let c: usize = iterator.next().unwrap().parse().unwrap();

    let ans = min(b / a, c);
    return ans.to_string();
}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

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

    int N; cin >> N;
    vi A(N); for (int i = 0; i < N; i++) cin >> A[i];

    vi prime;
    for (int i = 2; i <= 1000; i++) {
        bool ok = 1;
        for (int p : prime) {
            if (i % p == 0) {
                ok = 0;
                break;
            }
            if (p*p > i) break;
        }

        if (ok) prime.push_back(i);
    }

    vb chk(1001);
    set<int> ss;
    bool pa = 1;
    for (int i = 0; i < N; i++) {
        int tmp = A[i];
        for (int p : prime) {
            if (tmp % p == 0 && chk[p]) pa = 0;
            while (tmp % p == 0) {
                chk[p] = 1;
                tmp /= p;
            }
        }

        if (tmp != 1) {
            if (ss.find(tmp) != ss.end()) pa = 0;
            ss.insert(tmp);
        }
    }

    int g = A[0];
    for (int i = 1; i < N; i++) g = gcd(g, A[i]);
    bool sa = (g == 1);

    if (pa) cout << "pairwise coprime";
    else if (sa) cout << "setwise coprime";
    else cout << "not coprime";
}

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

int main() {
    double L; cin >> L;
    double ans = L * L * L / 27;
    printf("%.12f\n", ans);
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i,0,n)
#define BFOR(bit,a,b) for(int bit = (a); bit < (1<<(b)); ++bit)
#define BREP(bit,n) BFOR(bit,0,n)
using namespace std;
using ll = long long;

int main() {
  ll n,m,x;
  cin >> n >> m >> x;
  vector<ll> c(n);
  vector<vector<ll>> a(n,vector<ll> (m));
  
  REP(i,n){
    cin >> c[i];
    REP(j,m){
      cin >> a[i][j];
    }
  }
  
  ll ans = 100000000000;
  BREP(bit,n){
    ll sum = 0;
    vector<ll> ex(m);
    REP(i,n){
      if((bit>>i) & 1) continue;
      sum += c[i];
      REP(j,m){
        ex[j] += a[i][j];
      }
    }
    
    bool can = true;
    REP(i,m){
      if(ex[i] < x) can = false;
    }
    
    if(can) ans = min(ans,sum);
  }
  
  if(ans == 100000000000) cout << -1 << endl;
  else cout << ans << endl;
      
      
    
}

Measured memory_bytes: 3628
#include <set>
#include <vector>
#include <cstdio>
#include <iostream>
typedef std::pair<int,int> pii;

int n,X[20005],C[20005];
bool v[20005];
std::set<pii> S;
std::vector<int> T;

void DFS1(int p,int d)
{
    bool Flag=false;
    for(v[p]=1;;)
    {
        auto it=S.lower_bound(pii(X[p]-d+1,-1));
        if(Flag)
        {
            if(it==S.end())break;
            else ++it;
        }
        if(it==S.end()||it->first>=X[p]+d)break;
        int t=it->second;
        if(t==p)Flag=true;
        else if(S.erase(it),!v[t^1])DFS1(t^1,d);
    }
    T.push_back(p);
}

void DFS2(int p,int d,int s)
{
    bool Flag=false;
    for(v[p]=1,C[p]=s;;)
    {
        auto it=S.lower_bound(pii(X[p^1]-d+1,-1));
        if(Flag)
        {
            if(it==S.end())break;
            else ++it;
        }
        if(it==S.end()||it->first>=X[p^1]+d)break;
        int t=it->second;
        if(t==(p^1))Flag=true;
        else if(S.erase(it),!v[t])DFS2(t,d,s);
    }
}

bool Check(int d)
{
    S.clear();
    for(int i=0;i<(n<<1);++i)S.insert(pii(X[i],i)),v[i]=0;
    for(int i=0;i<(n<<1);++i)if(!v[i])DFS1(i,d);
    S.clear();
    for(int i=0;i<(n<<1);++i)S.insert(pii(X[i],i)),v[i]=0;
    for(int s=0;!T.empty();T.pop_back())if(!v[T.back()])DFS2(T.back(),d,++s);
    for(int i=0;i<n;++i)if(C[i<<1]==C[i<<1|1])return false;
    return true;
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<(n<<1);++i)scanf("%d",&X[i]);
    int l=0,r=1e9,Mid;
    while(l<r)Check(Mid=(l+r)>>1)?l=Mid+1:r=Mid;
    return printf("%d\n",l-1),0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int T; cin >> T;
    rep(test,T){
        int n; cin >> n;
        vector<pair<int,P>> v;
        rep(i,n){
            int k,l,r;
            cin >> k >> l >> r;
            v.pb({k,{l,r}});
        }
        sort(ALL(v));
        priority_queue<P,vector<P>,greater<P>> pq;
        vector<pair<int,P>> vec;
        ll ans=0;
        rep(i,n){
            if(v[i].se.fi>v[i].se.se){
                if(v[i].fi>pq.size()){
                    ans+=v[i].se.fi;
                    pq.push({v[i].se.fi-v[i].se.se,i});
                }else{
                    if(pq.top().fi<v[i].se.fi-v[i].se.se){
                        ans+=v[i].se.fi;
                        ans-=v[pq.top().se].se.fi; ans+=v[pq.top().se].se.se;
                        pq.pop();
                        pq.push({v[i].se.fi-v[i].se.se,i});
                    }else{
                        ans+=v[i].se.se;
                    }
                }
            }else vec.pb(v[i]);
        }
        sort(ALL(vec),greater<pair<int,P>>());
        priority_queue<P,vector<P>,greater<P>> pqr;
        rep(i,vec.size()){
            if(n-vec[i].fi>pqr.size()){
                ans+=vec[i].se.se;
                pqr.push({vec[i].se.se-vec[i].se.fi,i});
            }else{
                if(pqr.size()!=0&&pqr.top().fi<vec[i].se.se-vec[i].se.fi){
                    ans+=vec[i].se.se;
                    ans-=pqr.top().fi;
                    pqr.pop();
                    pqr.push({vec[i].se.se-vec[i].se.fi,i});
                }else{
                    ans+=vec[i].se.fi;
                }
            }
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 9744
#include <stdio.h>
#import <Foundation/Foundation.h>
 
int isPrime(int n) {
  
  if(n < 2) {
    return 0;
  }
  
  int i;
  for(i=2; i * i <= n; i++) {
    if(n % i == 0)
      return 0;
  }
  return 1;
}
 
int main(int argc, char **argv) {
  int n;
  scanf("%d", &n);
  
  while (1) {
    if (isPrime(n)) {
      break;
    }
    n ++;
  }
  printf("%d", n);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<string.h>

int main()
{
	int A, B, C, D, X, Y;
	scanf("%d %d %d %d", &A, &B, &C, &D);
	
	if(A%D == 0) X = A / D;	//高橋くんが死ぬターン数
	else X = A / D +1;	//高橋くんが死ぬターン数
	
	if(C%B == 0) Y = C / B;	//青木くんが死ぬターン数
	else Y = C / B +1;	//青木くんが死ぬターン数
	
	if (X >= Y) printf("Yes");
	else printf("No");


	return 0;
	
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  string s,t,u;
  int a,b;
  cin >>s>>t>>a>>b>>u;
  
  if(s==u) a--;
  if(t==u) b--;
  
  cout << a << " " << b << endl;
  
}


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

#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
  
const int INF=100000000;
 
int main(){
    while(1){
        int n,m;
        static int ld[202][202]; rep(i,202)rep(j,202){ if(i==j)ld[i][j]=0; else ld[i][j]=INF; }
        static int sd[202][202]; rep(i,202)rep(j,202){ if(i==j)sd[i][j]=0; else sd[i][j]=INF; }
          
        scanf("%d%d",&n,&m); if(n==0&&m==0)return 0;
        rep(i,m){
            int x,y,t; char sl;
            scanf("%d%d%d %c",&x,&y,&t,&sl);
            if(sl=='L'){
                ld[x][y]=t;
                ld[y][x]=t;
            }
            else {
                sd[x][y]=t;
                sd[y][x]=t;
            }
        }
          
        rep1(k,n)rep1(i,n)rep1(j,n)ld[i][j]=min(ld[i][j],ld[i][k]+ld[k][j]);
        rep1(k,n)rep1(i,n)rep1(j,n)sd[i][j]=min(sd[i][j],sd[i][k]+sd[k][j]);
          
        /*rep1(i,n){
            rep1(j,n){
                cout<<sd[i][j]<<" ";
            }
            cout<<endl;
        }*/
          
        int r,z[1002];
        static int dp[1002][202]; rep(i,1002)rep(j,202)dp[i][j]=INF;
          
        scanf("%d",&r);
    	rep(i,r)scanf("%d",&z[i]);
        dp[0][z[0]]=0;
          
        rep1(i,r-1){
            rep1(j,n){
            	dp[i][j]=min(dp[i][j],dp[i-1][j]+ld[z[i-1]][z[i]]);
                if(ld[j][z[i]]!=INF){
                    rep1(k,n){
                        dp[i][j]=min(dp[i][j],dp[i-1][k]+ld[z[i-1]][k]+sd[k][j]+ld[j][z[i]]);
                    }
                }
            }
        }
    	
    	int ret=1000000000;
    	rep1(i,n){
    		ret=min(ret,dp[r-1][i]);
    	}
          
        printf("%d\n",ret);
    }
}

Measured memory_bytes: 2284
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    lint n;cin>>n;
    for(lint i=1;i<=3500;i++){
        for(lint j=i;j<=3500;j++){
            lint tmp=n*i*j,tmp2=4*i*j-n*j-n*i;
            if(tmp2!=0){
                if(tmp%tmp2==0){
                    if(tmp/tmp2>0){
                        cout<<i<<" "<<j<<" "<<tmp/tmp2<<endl;
                        return 0;
                    }
                }
            }
        }
    }
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n; cin >> n; string s; cin >> s;

	vector<string>ans(4);

	if (s[0] == 'o') {
		ans[0] = "SSS";
		ans[1] = "WSW";
		ans[2] = "SWW";
		ans[3] = "WWS";
	}
	else {
		ans[0] = "SSW";
		ans[1] = "WSS";
		ans[2] = "SWS";
		ans[3] = "WWW";
	}
	s = (s[s.size() - 1] + s + s[0]);

	rep(i, 0, 4) {
		rep(j, 2, s.size() - 1) {
			if (s[j] == 'o') {
				if (ans[i][j] == 'S') {
					if (ans[i][j - 1] == 'S')ans[i].push_back('S');
					else ans[i].push_back('W');
				}
				else {
					if (ans[i][j - 1] == 'S')ans[i].push_back('W');
					else ans[i].push_back('S');
				}
			}
			else {
				if (ans[i][j] == 'S') {
					if (ans[i][j - 1] == 'S')ans[i].push_back('W');
					else ans[i].push_back('S');
				}
				else {
					if (ans[i][j - 1] == 'S')ans[i].push_back('S');
					else ans[i].push_back('W');
				}
			}
		}
	}

	//rep(i, 0, 4)dump(ans[i]);

	rep(i, 0, 4) {
		if (ans[i][1] == ans[i][s.size() - 1] && ans[i][0] == ans[i][s.size() - 1 - 1]) {
			cout << ans[i].substr(1, n) << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 1020
from collections import deque

H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]

q = []
for y in range(H) :
    for x in range(W) :
        if A[y][x] == '#' :
            q.append((y, x))

ret = 0
while True :
    r = []
    while q :
        cy, cx = q.pop()
        for dy, dx in ((-1, 0), (1, 0), (0, -1), (0, 1)) :
            ny, nx = cy + dy, cx + dx
            if 0 <= ny < H and 0 <= nx < W and A[ny][nx] == '.' :
                A[ny][nx] = '#'
                r.append((ny, nx))
    ret += 1
    if len(r) == 0 :
        break
    
    q = r
    
print(ret - 1)

Measured memory_bytes: 127916
#include <stdio.h>
#include <math.h>

typedef struct{
	double x;
	double y;
} point;

int main(){
	point p1, p2;
	
	scanf("%lf%lf%lf%lf", &p1.x, &p1.y, &p2.x, &p2.y);
	printf("%f\n", sqrt(pow(p1.x-p2.x, 2.0)+pow(p1.y-p2.y, 2.0)));
	
	return 0;
}

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

string dd(int x){
    int d1 = x%10;
    while(x/10 != 0){
        x /= 10;
    }
    int d2 = x;
    string s(2,'0');
    s[0] = '0'+d2;
    s[1] = '0' + d1;
    if(d1 != 0) return s;
    else return "00";
}

int main(){
    int N; cin >> N;
    map<string,int> mp;
    for(int i = 1; i <= N;++i){
        if(dd(i) != "00") mp[dd(i)]++;
    }
    ll ans = 0;
    for(auto x : mp){
        for(auto y : mp){
            if(x.first[0] == y.first[1] && x.first[1] == y.first[0]){
                ans += x.second*y.second;
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  int m;
  cin >> m;
  vector<int> b(m);
  for(int i = 0; i < m; ++i) cin >> b[i];
  cout << lexicographical_compare(a.begin(), a.end(), b.begin(), b.end()) << endl;
  return 0;
}



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

#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>

int main() {

    int N, Q;
    cin >> N >> Q;

    vvi to(200010);
    vi vq(200010, 0);

    int a, b;
    for (int i = 1; i < N; i++) {
        cin >> a >> b;
        to[a].push_back(b);
    }

    int p, x;
    for (int i = 0; i < Q; i++) {
        cin >> p >> x;
        vq[p] += x;
    }

    vi ans(200010, 0);
    int visit = 0;

    queue<int> q;
    int t;
    q.push(1);
    while (!q.empty()) {
        t = q.front();
        q.pop();
        ans[t] += vq[t];

        for (int i : to[t]) {
            q.push(i);
            ans[i] = ans[t];
        }
    }

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

    return 0;
}


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

int main() {
    vector<string> keys = { "dream", "dreamer", "erase", "eraser" };
    string s;
    cin >> s;

    reverse(s.begin(), s.end());
    for (int i = 0; i < keys.size(); i++) {
        reverse(keys.at(i).begin(), keys.at(i).end());
    }
    bool can = true;
    for (int i = 0; i < s.size();) {
        bool can2 = false;
        for (int j = 0; j < keys.size(); j++) {
            if (s.substr(i, keys.at(j).size()) == keys.at(j)) {
                i += keys.at(j).size();
                can2 = true;
                break;
            }
        }
        if (!can2) {
            can = false;
            break;
        }
    }
    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

int main(void) {
    int X;
    cin >> X;

    for(int i=1; i<=360; i++) {
        if((360*i) % X == 0) {
            cout << (360*i) / X;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
int n,d,counter=0;
scanf("%d %d",&n,&d);
while(n--){
    long long num1,num2;
    double dis;
    cin>>num1>>num2;
    dis=sqrt(num1*num1+num2*num2);
    if(dis<=d){
        counter++;
    }
}
cout<<counter<<endl;




    return 0;
}


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

int n;
int a[25];

inline void read(int &x)
{
	int ans=0,f=1;
	char a=getchar();
	while(!isdigit(a))
	{
		if(a=='-')
			f=-f;
		a=getchar();
	}
	while(isdigit(a))
	{
		ans=ans*10+(a-'0');
		a=getchar();
	}
	x=ans*f;
}

int dfs(int l,int r,int xl,int xr)
{
	if(r-l<=1)
		return 0;
	int ans=1e18;
	for(int i=l+1;i<=r-1;++i)
		ans=min(ans,dfs(l,i,xl,xl+xr)+dfs(i,r,xl+xr,xr)+a[i]*(xl+xr));
	return ans;
}

signed main(void)
{
	std::ios::sync_with_stdio(false);
	read(n);
	for(int i=1;i<=n;++i)
		read(a[i]);
	cout<<a[1]+a[n]+dfs(1,n,1,1)<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<stw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;

int main(void){
    int N,R,In;
    cin >> N >> R;
    if(N<10){
        In = R + 100*(10-N);
    }else{
        In = R;
    }
    cout << In << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	string S; cin >> S;
	cout << S.substr(0, S.size() - 8) << endl;
}

Measured memory_bytes: 256
import java.io.*;


public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException err){
			err.printStackTrace();
		}
	}

	public Main() throws IOException{
		int out_count = 0;
		int ining = 0;
		int data_size = 0;
		int point = 0;
		int[] scores;
		int[] base = new int[]{0, 0, 0};
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		String line;
		data_size = Integer.parseInt(in.readLine());
		scores = new int[data_size];

		while((line = in.readLine()) != null){
			if(line.equals("OUT")){
				out_count++;

				if(out_count == 3){
					scores[ining] = point;
					point = 0;
					ining++;
					out_count = 0;
					base = new int[]{0, 0, 0};
				}
			}
			else if(line.equals("HIT")){
				for(int i=0; i<3; i++){
					if(base[i] != 1){
						base[i] = 1;
						break;
					}

					if(i==2){
						point++;
					}
				}
			}
			else if(line.equals("HOMERUN")){
				int count = 0;
				for(int i=0; i<3; i++){
					if(base[i] == 1){
						count++;
					}
				}

				point += count+1;
				base = new int[]{0, 0, 0};
			}

			if(ining == data_size){
				break;
			}
		}

		for(int i=0; i<data_size; i++){
			System.out.println(scores[i]);
		}
	}
}

Measured memory_bytes: 9360
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int read(string a){
	re (a[0]-'0')*10+(a[1]-'0');
}
bool isyear(int a){
	if(!a||a>12) re 1;
	re 0;
}
bool ismonth(int a){
	if(0<a&&a<=12) re 1;
	re 0;
}
signed main(){
	ios_base::sync_with_stdio(0);
	string s;
	cin>>s;
	int a=read(s.substr(0,2)),b=read(s.substr(2));
	if(isyear(a)&&ismonth(b)&&!isyear(b)&&!ismonth(a)){
		cout<<"YYMM";
		re 0;
	}
	if(isyear(b)&&ismonth(a)&&!isyear(a)&&!ismonth(b)){
		cout<<"MMYY";
		re 0;
	}
	if(isyear(a)&&isyear(b)){
		cout<<"NA";
		re 0;
	}
	cout<<"AMBIGUOUS";
	re 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int main() {
	#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	#endif
	int n, m;
	cin >> n >> m;
	string s;
	cin >> s;
	vector<int> hasa(n), hasb(n), dead(n);
	vector<vector<int>> v(n);
	rep (i, 0, m) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		v[x].pb(y);
		v[y].pb(x);
		if (s[y] == 'A') {
			hasa[x]++;
		} else {
			hasb[x]++;
		}
		if (s[x] == 'A') {
			hasa[y]++;
		} else {
			hasb[y]++;
		}
	}
	int left = n;
	queue<int> q;
	rep (i, 0, n) {
		if (!hasa[i] or !hasb[i]) {
			q.push(i);
		}
	}
	while (!q.empty()) {
		int x = q.front();
		q.pop();
		if (dead[x]) {
			continue;
		}
		dead[x] = 1;
		left--;
		DBG(x, left, hasa[x], hasb[x]);
		for (auto y: v[x]) {
			DBG(y, dead[y]);
			if (s[x] == 'A') {
				hasa[y]--;
				if (hasa[y] <= 0) {
					q.push(y);
				}
			} else {
				hasb[y]--;
				if (hasb[y] <= 0) {
					q.push(y);
				}
			}
		}
	}
	if (left) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	
}


Measured memory_bytes: 12880
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	long long x, k, d;
	cin >> x >> k >> d;

	x = abs(x);
	long long m = x / d;
	/*if (x % d > abs(x % d - d)) {
		m++;
	}*/
	if (m <= k) {
		if ((k - m) % 2 == 0) {
			cout << x % d << endl;
		}
		else {
			cout << abs(x % d - d) << endl;
		}
	}
	else {
		cout << x - k * d << endl;
	}
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
 
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%lf",&x)
#define sl(x) scanf("%lld",&x)
#define pr(x) printf("%d\n",x)
#define prll(x) printf("%lld\n",x)
 
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
 
#define rep(i,x,y) for(int i=x;i<y;i++)
#define ii pair<int,int> 
#define pll pair<ll,ll> 
#define vi vector<int> 
#define vvi vector< vi > 
#define vl vector<long long int>
#define vvl vector< vl >
#define vii vector< ii >
#define vvii vector< vii >
#define priority_queue pq;
#define sz(a) ll((a).size()) 
#define pb push_back 
#define mp make_pair
 
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end() 
#define tr(i,c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ison(x,i) (((x) >> (i)) & 1)	//checks if ith bit is on
#define set0(x,i) (x & ~(1 << i))		//set ith bit in x to be zero
#define clr(a) memset(a,0,sizeof(a))
 
#define MOD 1000000007
#define INF 4000000000000000000
#define MAX 100000+5
using namespace std;

bitset<10> t;

bool check(int p)
{
	while(p)
	{
		if(t[p%10])
			return false;
		p/=10;
	}
	return true;
}

int main()
{
	int n,k,p;
	si(n); si(k);
	while(k--)
	{
		si(p);
		t[p]=true;
	}
	for(int i=n;;i++)
	if(check(i))
	{
		pr(i);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256