akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define MEMS(a, b) memset(a, b, sizeof(a))
 
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
 
const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 200001;
const int mod = 1e9 + 7;
 
 
#define FILENAME ""

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
     //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
    ll n;
    cin >> n;
    vector <ll> a;
    for (int i = 0; i < n; i++) {
        ll x;
        cin >> x;
        a.pb(x);
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i != j) ans += a[i]*a[j];
        }
    }
    cout << ans/2;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int n, y, m;
  	y = 0;
  	scanf("%d", &n);
  	m = n;
  	while (n >= 0) {
      n = n - 15;
      if (n >= 0) {
        y = y + 200;
      }
    }
  	printf("%d", (800 * m) - y);
  	return 0;
}



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

int main() {
  string s;
  cin>>s;
  bool ans=false;
  if(s.at(2)==s.at(3) && s.at(4)==s.at(5)){
    ans=true;
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
C - ID
https://atcoder.jp/contests/abc113/tasks/abc113_c

"""
import sys

from collections import defaultdict
from bisect import bisect_left

def solve(N, M, cities):
    res = defaultdict(list)
    for p, y in cities:
        res[p].append(y)
    for k in res.keys():
        res[k].sort()
    return ['{:06d}{:06d}'.format(p, bisect_left(res[p], y) + 1) for p, y in cities]


def main(args):
    N, M = map(int, input().split())
    cities = [[int(i) for i in input().split()] for i in range(M)]
    ans = solve(N, M, cities)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 45716
#include <iostream>
using namespace std;
int a[10];

bool dfs(int i,int l,int r){
	if(i>=10)return 1;
	if(l>a[i]&&r>a[i])return 0;
	if(l<a[i]){
		if(dfs(i+1,a[i],r))return 1;
	}
	if(r<a[i]){
		return dfs(i+1,l,a[i]);
	}
	return 0;
}

int main(){
	int T;cin>>T;
	while(T--){
		for(int i=0;i<10;i++)cin>>a[i];
		if(dfs(0,0,0))cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

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

void Main() {
  int N;
  cin >> N;
  vector<int> cities(N+1);
  vector<int> heroes(N);
  for (int i=0; i<N+1; ++i) {
    cin >> cities[i];
  }
  for (int i=0; i<N; ++i) {
    cin >> heroes[i];
  }

  lint ans = 0;
  for (int i=0; i<N; ++i) {
    int c = min(cities[i], heroes[i]);
    int d = min(heroes[i] - c, cities[i+1]);
    ans += c + d;
    cities[i+1] -= d;
  }
  cout << ans << "\n";
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  Main();
}


Measured memory_bytes: 1024
/*
      author : nishi5451
      created: 12.08.2020 16:21:26
*/

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


int main(){
    string w;
    cin >> w;
    vector<int> dp(26);
    rep(i,int(w.size())){
        dp[w[i]-'a']++;
    }
    rep(i,26) if(dp[i]%2!=0){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main()
{
  int n;
  string s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i, n)
  {
    if (s[i] == 'R')
      a[i] = 0;
    if (s[i] == 'G')
      a[i] = 1;
    if (s[i] == 'B')
      a[i] = 2;
  }
  vector<ll> cnt(3);
  rep(i, n) cnt[a[i]]++;
  ll ans = 1;
  rep(i, 3) ans *= cnt[i];
  rep(j, n) rep(i, j)
  {
    int k = j + (j - i);
    if (k < n)
    {
      if (a[i] == a[j])
        continue;
      if (a[i] == a[k])
        continue;
      if (a[k] == a[j])
        continue;
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void)
{
	int i;
	int N[24] = {0};
	double T[24] = {0};
	int number1[3] = {0};
	int number2[3] = {0};
	int number3;
	int number4;
	double time1[3] = {0};
	double time2[3] = {0};
	double time3;
	double time4;

	for (i = 0; i < 24; i++)
		scanf("%d %lf", &N[i], &T[i]);

	time1[0] = 100;
	for (i = 0; i < 8; i++)
	{
		if (time1[0] > T[i])
		{
			number1[0] = N[i];
			time1[0] = T[i];
		}
	}

	time1[1] =100;
	for (i = 8; i < 16; i++)
	{
		if (time1[1] > T[i])
		{
			number1[1] = N[i];
			time1[1] = T[i];
		}
	}

	time1[2] = 100;
	for (i = 16; i < 24; i++)
	{
		if (time1[2] > T[i])
		{
			number1[2] = N[i];
			time1[2] = T[i];
		}
	}

	time2[0] = 100;
	for (i = 0; i < 8; i++)
	{
		if (time1[0] != T[i] &&time2[0] > T[i])
		{
			number2[0] = N[i];
			time2[0] = T[i];
		}
	}

	time2[1] = 100;
	for (i = 8; i < 16; i++)
	{
		if (time1[1] != T[i] &&time2[1] > T[i])
		{
			number2[1] = N[i];
			time2[1] = T[i];
		}
	}

	time2[2] = 100;
	for (i = 16; i < 24; i++)
	{
		if (time1[2] != T[i] &&time2[2] > T[i])
		{
			number2[2] = N[i];
			time2[2] = T[i];
		}
	}

	time3 = 100;
	for (i = 0; i < 24; i++)
	{
		if (time1[0] != T[i] && time1[1] != T[i] && time1[2] != T[i] && time2[0] != T[i] && time2[1] != T[i] && time2[2] != T[i] && time3 > T[i])
		{
			number3 = N[i];
			time3 = T[i];
		}
	}

	time4 = 100;
	for (i = 0; i < 24; i++)
	{
		if (time1[0] != T[i] && time1[1] != T[i] && time1[2] != T[i] && time2[0] != T[i] && time2[1] != T[i] && time2[2] != T[i] && time3 != T[i] && time4 > T[i])
		{
			number4 = N[i];
			time4 = T[i];
		}
	}

	for (i = 0; i < 3; i++)
	{
		printf("%d %4.2f\n", number1[i], time1[i]);
		printf("%d %4.2f\n", number2[i], time2[i]);
	}
	printf("%d %4.2f\n", number3, time3);
	printf("%d %4.2f\n", number4, time4);

	return 0;
}

Measured memory_bytes: 652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws IOException {
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int a = in.nextInt();
    int b = in.nextInt();
    int c = in.nextInt();
    System.out.println(c + " " + a + " "  + b);
  }
}

Measured memory_bytes: 19668
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
using namespace std;
int main() {
	int num;
	cin >> num;
	int num_digit = 0;
	for (int i = 0; i < 10; i++) {
		if (static_cast<int>(num / pow(10, i)) != 0) {
			num_digit = i + 1;
		}
	}
	//sort(vec.begin(), vec.end());
	int ans = 0;
	for (int digit = 3; digit <= num_digit; digit++) {
		int use_digit = digit - 3;
		for (int i7 = 0; i7 <= use_digit; i7++) {
			for (int i5 = 0; i5 <= use_digit - i7; i5++) {
				int i3 = use_digit - i7 - i5;
				vector<int> vec = { 3,5,7 };
				for (int i = 0; i < i7; i++) {
					vec.push_back(7);
				}
				for (int i = 0; i < i5; i++) {
					vec.push_back(5);
				}
				for (int i = 0; i < i3; i++) {
					vec.push_back(3);
				}
				sort(vec.begin(), vec.end());
				do {
					int tmp_num=0;
					for (int i = 0; i < vec.size(); i++) {
						tmp_num += vec[i] * pow(10, i);
					}
					if (tmp_num <= num) {
						ans++;
					}
				} while (next_permutation(vec.begin(), vec.end()));
			}

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

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

const int MAXN = 1e5 + 5;
int n, k, m;
string s;

int main() {
    cin >> s;
    for (int i = 0; i < s.size(); i++)
        n += s[i] - '0';
    for (int i = 0; i < s.size(); i++)
        m = (m * 10) + s[i] - '0';
    cout << (m % n? "No": "Yes");
    return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from heapq import *

n, m, s = na()
uvab = nan(m)
cd = nan(n)
maxS = 5007
s = min(s, maxS)

g = [[] for _ in range(n)]
for i in range(m):
    u, v, a, b = uvab[i]
    u -= 1
    v -= 1
    g[u].append((v, (a, b)))
    g[v].append((u, (a, b)))

def dijkstra(g, x):
    dist = [[inf] * (maxS + 1) for _ in range(len(g))]
    dist[x][s] = 0
    q = []
    # proc = [False for _ in range(len(g))]
    heappush(q, (0, (x, s)))
    while len(q):
        p = heappop(q)
        a = p[1][0]
        cost = p[0]
        curS = p[1][1]
        # if proc[a]:
        #	  continue
        # proc[a] = True
        for b in g[a]:
            to = b[0]
            ncost = cost + b[1][1]
            nS = curS - b[1][0]
            if nS >= 0:
                if dist[to][nS] > ncost:
                    dist[to][nS] = ncost
                    heappush(q, (ncost, (to, nS)))
        
        c, d = cd[a]
        cost += d
        curS += c
        curS = min(curS, maxS)
        if dist[a][curS] > cost:
            dist[a][curS] = cost
            heappush(q, (cost, (a, curS)))
    
    return dist

dist = dijkstra(g, 0)
for i in range(1, n):
    ans = inf
    for j in range(maxS):
        ans = min(ans, dist[i][j])
    print(ans)

Measured memory_bytes: 49244
n, x = map(int, input().split())
L = [int(i) for i in input().split()]
L.insert(0, 0)

tmp = 0
count = 0
for i in range(n+1):
    if i != n:
        tmp += L[i]
        if x < tmp:
            print(count)
            break
        count += 1

    else:
        tmp += L[i]
        if x >= tmp:
            count += 1
        print(count)
        

Measured memory_bytes: 3060
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sqr(x) (x) * (x)

using namespace std;
using namespace __gnu_pbds;

mt19937_64 gen(time(0));

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//const int mod = 1e9 + 7;

//const int inf = 1e9;
const int maxn = 2e5 + 66;

int b[maxn];

signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif
    int n;
    cin >> n;
    int x = 0;
    for(int i = 0; i < n; ++i)
    {
        cin >> b[i];
        x ^= b[i];
    }
    for(int i = 0; i < n; ++i)
        cout << (x ^ b[i]) << ' ';
    return 0;
}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define ip pair<int, ii>
using namespace std;
const int N = 2e5 + 7, M = 3 + 7;
const ll mod = 1000000007, inf = mod + 10;



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

    int prev = -1, cnt = 0, ans = 0;

    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        if(prev!=tmp)ans += cnt/2, cnt = 1;
        else cnt++;
        prev = tmp;
    }
    ans += cnt/2;
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long ans = 1;
		for(long i=0; i<=N; i++) {
			if(i*i>N) {
				break;
			}
			ans = i*i;
		}
		System.out.println(ans);
	}
	
	// print
	static void print(String s) {
		System.out.println(s);
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static int max(int...ls) {
		int ans = Integer.MIN_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.max(ans, ls[i]);
		}
		return ans;
	}
	
	static int min(int...ls) {
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.min(ans, ls[i]);
		}
		return ans;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Vec = vector<ll>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n, m;
	cin >> n >> m;
	Vec1<P> p(n);
	for(ll i = 0; i < n; ++i) cin >> p[i].fs >> p[i].sc;

	sort(all(p));

	ll c = 0, ans = 0, i = 0;
	while(c < m){
		if(c+p[i].sc < m){
			ans += p[i].fs*p[i].sc;
			c += p[i].sc;
		}else{
			ans += p[i].fs*(m-c);
			c += m-c;
		}
		i++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <cstdio>
#include <algorithm>

using namespace std;

/**
 * main
 */
int main () {
  int A, B, C, D;
  scanf("%d %d %d %d", &A, &B, &C, &D);
  printf("%d\n", max(A*B, C*D));
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x=0;
  cin >> x;
  if (400 <= x && x <= 599)
    cout << 8 << endl;
  else if (600 <= x && x <= 799)
    cout << 7 << endl;
  else if (800 <= x && x <= 999)
    cout << 6 << endl;
  else if (1000 <= x && x <= 1199)
    cout << 5 << endl;
  else if (1200 <= x && x <= 1399)
    cout << 4 << endl;
  else if (1400 <= x && x <= 1599)
    cout << 3 << endl;
  else if (1600 <= x && x <= 1799)
    cout << 2 << endl;
  else if (1800 <= x && x <= 1999)
    cout << 1 << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;cin>>n;
    string s;
    cin>>s;
    int ans = 0;
    rep(i,10)rep(j,10)rep(k,10){
        vector<char> v = {char('0'+i),char('0'+j),char('0'+k),'-'};
        int c=0;
        rep(l,n){
            if(s[l]==v[c])c++;
        }
        ans += c==3;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using LL = long long;
const int N = 100005;
int a[N], b[N], c[N];
int main()
{
	int x, y, n, m, k;
	scanf("%d%d%d%d%d", &x, &y, &n, &m, &k);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for (int i = 1; i <= m; ++i) scanf("%d", &b[i]);
	for (int i = 1; i <= k; ++i) scanf("%d", &c[i]);

	LL res = 0;
	sort(a + 1, a + 1 + n, greater<int>());
	sort(b + 1, b + 1 + m, greater<int>());
	sort(c + 1, c + 1 + k, greater<int>());

	vector<int> v;
	for (int i = 1; i <= x; ++i)
	{
		res += a[i];
		v.push_back(a[i]);
	}

	for (int i = 1; i <= y; ++i)
	{
		res += b[i];
		v.push_back(b[i]);
	}
	sort(v.begin(), v.end());

	for (int i = 1; i <= k; ++i)
	{
		int j = c[i];
		if (j > * v.begin())
		{
			res += j - *v.begin();
			v.erase(v.begin());
		}
		else
			break;
	}

	printf("%lld\n", res);


	return 0;
}

Measured memory_bytes: 2552
import java.util.Scanner;

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

		int summary = 0;
		for (int i = 1; i <= N; i++) {
			String numString = String.valueOf(i);
			char[] numCharList = numString.toCharArray();
			int sum = 0;
			for (char numChar : numCharList) {
				sum += Character.getNumericValue(numChar);
			}
			if (A <= sum && sum <= B) {
				summary += i;
			}
		}
		System.out.println(summary);


	}
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int z[1001];

int main(){
  for(int i = 1; i < 1000; i++) z[i] = i + z[i-1];
  int a, b;
  cin >> a >> b;
  for(int i = 1; i < 999; i++){
    if(z[i] - a == z[i+1] - b){
      cout << z[i] - a << "\n";
      return 0;
    }
  }
  return 0;
}

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

const int MAX_N	= 100000;
int a[ MAX_N + 5 ];
int b[ MAX_N + 5 ];

int main()
{
int i;
int N;
int H;
int iMax;
int iSum;
int iCnt;
int X;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> H;

	for( i = 0; i < N; i++ )
	{
		cin >> a[ i ];
		cin >> b[ i ];
	}

	iMax = *max_element( a, a + N );
	sort( b, b + N, std::greater<int>() );

	iSum = 0;
	iCnt = 0;
	for( i = 0; i < N; i++ )
	{
		if( b[ i ] >= iMax )
		{
			iCnt++;
			iSum += b[ i ];
			if( iSum >= H ) break;
		}
	}

	if( i == N )
	{
		X = H - iSum;
		iCnt += X / iMax;
		if( X % iMax != 0 ) iCnt++;
	}

	cout << iCnt << endl;

	return 0;
}




Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
typedef long long LL;
using namespace std;

const LL mod = 1e9 + 7;
const int MAXN = 1e5 + 10;
char str[MAXN];

int main() {
	int x = 0, y = 0;
	bool flag = false;
	scanf("%s", str);
	int len = strlen(str);
	for(int i = 0; i < len - 1; ++i) {
		if(str[i] == 'W' && str[i + 1] == 'B') {
			x++;
			flag = true;
		} 
		else if(str[i] == 'B' && str[i + 1] == 'W') {
			y++;
			flag = true;
		}
	}
	int ans = 0;
	if(flag && str[len - 1] == 'W') x++;
	if(flag && str[len - 1] == 'B') y++;
	if(str[0] == str[len - 1] && str[0] == 'W') ans = y * 2;
	else if(str[0] == str[len - 1] && str[0] == 'B') ans = x * 2;
	else ans = max(x * 2 - 1, y * 2 - 1);
	printf("%d\n", max(0, ans));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  int n = B - A - 1;
  
  if( n%2 == 1 ) cout << "Alice" << endl;
  else if ( n%2 == 0 ) cout << "Borys" << endl;
  else cout << "Draw" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
	
int main(){
  long long i,j,k;
  long long A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  int p,q,pq;
  long long ans=99999999999;
  for(i=0;i<=max(X,Y);i++){
	ans=min(ans,2*i*C+max((long long)0,(X-i))*A+max((long long)0,(Y-i))*B);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
A=input().split()
B=[]
for i in A:
    if i.isdigit():
        B.append(int(i))
    else:
        if i=="+":
            B[-1]=B[-2]+B[-1]
            del B[-2]
        elif i=="-":
            B[-1]=B[-2]-B[-1]
            del B[-2]
        elif i=="*":
            B[-1]=B[-2]*B[-1]
            del B[-2]
print(B[0])

Measured memory_bytes: 7704
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N,M,X;
    cin >> N >> M >> X;
    
    vi C(N);
    vvi A(N,vi(M));
    rep(i,N){
        cin >> C[i];
        rep(j,M) cin >> A[i][j];
    }
    
    int ans = infi;
    
    for (int i = 0; i < (1<<N); i++) {
        int an = 0;
        bitset<13> b(i);
        vi a(M,0);
        rep(j,N) if(b[j] & 1) {
            an += C[j];
            rep(k,M) a[k]+=A[j][k];
        }
        bool f = true;
        rep(j,M) if(a[j] < X) f = false;
        if(f) chmin(ans,an);
    }
    
    if(ans == infi) cout << -1 << endl;
    else cout << ans << endl;
    
    

    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <algorithm> //fillを使うため
#include <vector>

using namespace std;

#define MAX_V 1000
#define INF 1000000000000000

struct edge {
	long long int from; //出発点
	long long int to;   //到達点
	long long int cost; //移動コスト
};

long long int max(long long int a, long long int b) {
	if (a < b)
		return b;

	return a;
}


int vis[2501];
int able[2501];
int able2[2501];




vector<edge> E;
long long int d[2501];
vector<vector<int>> e;

void dfs(int s, int st, int t) {


	vis[s] = 1;
	if (s == t) {
		able[st] = 1;
		return;
	}
	for (int i = 0; i < e[s].size(); i++) {

		if (vis[e[s][i]] != 1) {
			dfs(e[s][i], st, t);
		}
	}

	return;

}



void dfs2(int s, int st, int t) {


	vis[s] = 1;
	if (s == t) {
		able2[t] = 1;
		return;
	}
	for (int i = 0; i < e[s].size(); i++) {

		if (vis[e[s][i]] != 1) {
			dfs2(e[s][i], st, t);
		}
	}

	return;

}

int main()
{

	long long int N, M, P;
	int S = 0;
	cin >> N >> M >> P;
	
	e.resize(N);



	for (int i = 0; i < N; i++)
		d[i] = INF;

	d[S] = 0; //始点を0にする

	for (int i = 0; i < M; i++) {
		long long int A, B, C;
		cin >> A >> B >> C;
		A--, B--;
		E.push_back({ A, B, P - C });
		e[A].push_back(B);

	}

	for (int i = 0; i < N; i++) {
		dfs(i, i, N - 1);

		for (int j = 0; j < N; j++)
			vis[j] = 0;
	}


	for (int j = 0; j < N; j++)
		vis[j] = 0;

	for (int i = 0; i < N; i++) {
		dfs2(0, 0, i);
		for (int j = 0; j < N; j++)
			vis[j] = 0;
	}
	

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < (int)E.size(); j++) {

			struct edge e = E[j];

			if (d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				if (i == N-1) {
					if (able[e.to] == 1 && able2[e.to] == 1) {
						cout << -1 << endl;
						return 0;
					}

				}
			}
		}
	}

	cout << max(-d[N - 1], 0) << endl;
}

Measured memory_bytes: 768
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

ll n,x,ans,kai;
ll s[53];
ll p[53];
ll solve(ll x,ll n,ll ans){
    if(x==1){
        if (n==0) return ans+1; 
        else return ans;
    }else if(x==s[n]){
        return ans + p[n];
    }else if(x==((s[n]+1)/2)){
        return ans + p[n-1]+1;
    }else if(x<((s[n]+1)/2)){
        solve(x-1,n-1,ans);
    }else{
        solve(x-((s[n]+1)/2),n-1,ans+1+p[n-1]);
    }
}
signed main(){
    cin>>n>>x;
    rep(i,n+1){
        if(i==0){
            s[i]=1;
            p[i]=1;
        }else{
            s[i]=3+s[i-1]*2;
            p[i]=1+p[i-1]*2;
        }
    }
    kai = solve(x,n,0);
    cout<<kai<<endl;
}


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

using namespace std;
int main(void){
  bool debug=false;
  
  int N,X;
  cin >> N >> X;
  int* x=new int[N+1];
  x[0]=X;
  for(int i=1;i<=N;i++){
    cin >> x[i];
    
  }
  
  sort(x, x+N+1);

  //calc distance between a pair of neighbor points
  int* d=new int[N];
  for(int i=0;i<N;i++){
    d[i]=x[i+1]-x[i];
  }
  
  //find minimum distance
  int D=1000000001;
  for(int i=0;i<N;i++){
    if(debug){
      cout << "(x[" << i+1 << "], x[" << i << "], d[" << i << "])=(";
      cout << x[i+1] << ", " << x[i] << ", " << d[i] << ")" << endl;
        
    }    
    if(D>d[i]){ D=d[i]; }
    
  }
  if(debug){
    cout << "D=" << D << endl;
  }
  
  //find skip number
  for(; D>0;D--){
    bool isPossible=true;
    for(int i=0;i<N;i++){
      if(0!=(d[i]%D)){
        isPossible=false;
        break;
        
      }
    }
    if(isPossible){
      cout << D << endl;
      return 0;
      
    }      
  }
  return 1;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int sum = a + b + c;
    int m = max(a,max(b,c));
    sum -= m;
    sum += m * pow(2,k);
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE BlockArguments #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import Control.Monad
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn @Int
  xs <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let v :: U.Vector Int
      v = U.create do
        v <- UM.replicate n 0
        forM_ xs \x -> UM.modify v (+ 1) (x - 1)
        return v
  U.forM_ v \n -> print n


Measured memory_bytes: 9908
import java.util.*;
public class Main {
    public static void main(String[] args){

        long NUM=1000000007;
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N=sc.nextInt();
        int D=sc.nextInt();
        int[][] X=new int[N][D];
        for(int i=0;i<N;i++){
            for(int j=0;j<D;j++){
                X[i][j]=sc.nextInt();
            }
        }
        int result=0;
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                int r2=0;
                for(int k=0;k<D;k++){
                    r2+=(X[j][k]-X[i][k])*(X[j][k]-X[i][k]);
                }
                int r=(int)Math.sqrt(r2);
                if(r*r==r2){
                    result++;
                }
            }
        }
        System.out.println(result);


    }
}


Measured memory_bytes: 23764
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define mod_mul(x, y) x*y%MOD
#define mod_add(x, y) (x+y)%MOD
#define mod_sub(x, y) (x-y)%MOD
#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1LL << 62


long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}


int main(){

    int N,K; cin >> N >> K;
    std::vector<pair<long long, long long>> p;
    REP(i,N){
        long long x,y; cin >> x >> y;
        p.push_back(make_pair(x,y));
    }

    long long ans = INF;

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

    REP(i,N){
        REP(j,N){
            REP(k,N){
                REP(l,N){
                    long long maxx = max(p[i].first, max(p[j].first, max(p[k].first, p[l].first)));
                    long long maxy = max(p[i].second, max(p[j].second, max(p[k].second, p[l].second)));
                    long long minx = min(p[i].first, min(p[j].first, min(p[k].first, p[l].first)));
                    long long miny = min(p[i].second, min(p[j].second, min(p[k].second, p[l].second)));
                    int cnt = 0;
                    REP(m, N){
                        if(p[m].first >= minx && p[m].first <= maxx && p[m].second >= miny && p[m].second <= maxy){
                            cnt++;
                        }
                    }

                    if(cnt >= K){
                        ans = min(ans, (maxx-minx)*(maxy-miny));
                    }

                }
            }
        }
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#define N 10
#define M 26
using namespace std;

bool n_zero[N], f[N];
int coe[N], cnt, c;

void dfs(int n, int s) {
	if (n == cnt) {
		if (!s) c++;
		return;
	}
	
	for (int i = 0; i < N; i++) {
		if (f[i] || (!i && n_zero[n])) continue;
		
		f[i] = 1;
		dfs(n + 1, s + i * coe[n]); 
		f[i] = 0;
	}
	
}

int main()
{	
	int n;
	
	while (cin >> n, n) {
		string str;
		vector<int> index(M, -1);
		cnt = c = 0;
		
		for (int i = 0; i < N; i++)
			n_zero[i] = coe[i] = f[i] = 0;
		
		for (int i = 0; i < n; i++) {
			cin >> str;
			
			for (int j = 0; j < str.size(); j++) {
				int ch = str[j] - 'A';
				if (index[ch] == -1) {
					index[ch] = cnt;
					cnt++;
				}
				
				if (str.size() > 1 && !j) n_zero[index[ch]] = 1;
				
				if (i != n - 1)
					coe[index[ch]] += pow(10, str.size() - 1 - j);
				else
					coe[index[ch]] -= pow(10, str.size() - 1 - j);
			}
		}
		
		dfs(0, 0);
		
		cout << c << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1252
object Main {
  case class Line(string: String) {
    def strings: Seq[String] = string.split(' ')
    def ints: Seq[Int] = strings.map(_.toInt)
    def i(n: Int): Int = ints(n)
  }

  def readLine: Line = Line(io.StdIn.readLine())
  def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))

  def yesNo(b: Boolean): String = if (b) "Yes" else "No"

  def main(args: Array[String]) {
    val Seq(a, b) = readLine.ints
    println(List(a * b, (a + b) * 2).mkString(" "))
  }
}

Measured memory_bytes: 43548
#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>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

int main() {
  int n, x;
  cin >> n >> x;
  int ans = 0;
  rep(i,n) {
    int m;
    cin >> m;
    ans = gcd(ans,abs(m-x));
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int h,w;
    cin >> h >> w;
    int c[10][10], cnt[10] = {}, in;
    REP(i,0,10) REP(j,0,10) cin >> c[i][j];
    REP(i,0,h) REP(i,0,w) {
        cin >> in;
        if (in > -1) cnt[in]++;
    }
    //REP(i,0,10) cerr << cnt[i] << endl;
    REP(k,0,10) REP(i,0,10) REP(j,0,10) if (c[i][j] > c[i][k] + c[k][j]) c[i][j] = c[i][k] + c[k][j];
    LL ans = 0;
    REP(i,0,10) ans += cnt[i] * c[i][1];
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

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

int main() {
  long long int X, Y; cin >> X >> Y;
  long long int A = X, ans = 1;
  while (A < Y) {
    A *= 2;
    if (A > Y) ans--;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# Beginners Contest (C)

import sys

# 約数に分解
def calc_divisor(n):
	div_dic = {}
	if n == 1: return div_dic
	k = 2
	while True:
		# 約数の場合
		if n%k == 0:
			if k not in div_dic: div_dic[k] = 0
			div_dic[k] += 1
			n = n//k
			if n == 1: break
		else:
			k += 1
	return div_dic

# 入力取得
a,b = [int(e) for e in input().split(" ")]

# 約数に分解
div_dic_a = calc_divisor(a)
div_dic_b = calc_divisor(b)

# 約数の和集合を計算
div_ls = list(div_dic_a) + list(div_dic_b)
div_ls = list({k: 1 for k in div_ls})
div_dic = {k:(div_dic_a[k]
	if div_dic_a.get(k,0) > div_dic_b.get(k,0)
	else div_dic_b[k]) for k in div_ls}
# print(div_dic)

# 最小公倍数を計算
ans = 1
for k in div_dic:
	ans *= k ** div_dic[k]

print(ans)


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

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

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#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 REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int R; cin >> R;
    if(R < 1200) cout << "ABC" << endl;
    else if(R < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("-O3")
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<cmath>
#define LL long long
#define ui unsigned int
#define ull unsigned long long
using namespace std;
 
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void Out(int x){
    if(x>9) Out(x/10);
    putchar('0'+x%10);
}
int gcd(int x,int y){
    if(!y) return x;
    return gcd(y,x%y);
}
LL qpow(LL x,LL y,LL P){
    LL re=1;
    while(y){
        if(y&1) re=re*x%P;
        x=x*x%P;y>>=1;
    }
    return re;
}
const int N=1e5+10;
int n;
int a[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n+n;++i)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n+n);
	int ans=0;
	for(int i=1;i<=n+n;i+=2) ans+=a[i];
	printf("%d\n",ans);
	return 0;
}
/*

*/

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  long long N,D,i,j;
  long long count = 0;
  scanf("%d %d",&N,&D);
  long long X[N],Y[N];
  for(i=0;i<N;i++){
  	scanf("%lld %lld",&X[i],&Y[i]);
    if((X[i]*X[i])+(Y[i]*Y[i])<=D*D){
    	count++;
    }
  }
  printf("%lld",count);
  return 0;
  
}

Measured memory_bytes: 4828
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
    ll i,j,k,n,x,y,cnt=0;
    double d,dist;
    cin>>n>>d;
    vector<pair<ll,ll>>v;
    for(i=0;i<n;i++)
    {
        cin>>x>>y;
        v.pb(mp(x,y));
    }
    //sort(v.begin(),v.end());
    for(i=0;i<n;i++)
    {
       dist=v[i].fi*v[i].fi*1.0+v[i].se*1.0*v[i].se;
    //   cout<<dist<<endl;
       dist=sqrt(dist);
        if(dist<=d) cnt++;
        //else break;
    //    cout<<v[i].fi<<" "<<v[i].se<<endl;
    }

    cout<<cnt<<endl;


    return 0;
}





Measured memory_bytes: 7556
import math
import decimal
xh = 0
yh = 0
xm = 0
ym = 0

a,b,h,m = map(int, input().split())

th = (h*60+m)/720*2*math.pi
tm = (m)/60*2*math.pi

xh = (a)*math.cos(th)
yh = (a)*math.sin(th)
xm = b*math.cos(tm)
th = b*math.sin(tm)

x = abs(xh-xm)
y = abs(yh-th)
ans = math.sqrt(x**2+y**2)
print(format(ans, '.9f'))

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n;

int main()
{
    _FastIO;
    cout.precision(10);
    cin >> n;
    if(n % 2 == 0){
        cout << "0.5000000000" << endl;
        return 0;
    }
    int x = 0;
    for(int i = 1; i <= n; i++){
        if(i % 2)
            x++;
    }
    cout << fixed << x * 1.000000000 / n << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
//言語は「C++14(GCC 5.4.1)」
//AtCoder Beginner Contest 63-A

int main(void)
{
	int a, b;
	scanf("%d", &a);
	scanf("%d", &b);
	if (a + b == 15)
		printf("+");
	else if (a*b == 15)
		printf("*");
	else
		printf("x");
	return 0;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int ac, wa, tle, re;
    ac = wa = tle = re = 0;
    Int n;
    cin >> n;
    for (Int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s == "AC") {
            ac++;
        } else if (s == "WA") {
            wa++;
        } else if (s == "TLE") {
            tle++;
        } else {
            re++;
        }
    }
    print("AC x", ac);
    print("WA x", wa);
    print("TLE x", tle);
    print("RE x", re);
    return 0;
}

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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    int res = N;
    for (int i = 0; i <= N; i++) {
        int cc = 0;
        int t = i;
        while (t > 0) {
            cc += t%6; 
            t/=6;
        }
        t = N-i;
        while (t>0) {
            cc += t % 9;
            t/=9;
        }
        if (res > cc) res = cc;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long ksm(long long u,long long v){
	long long o=1;
	while(v){
		if(v&1)
			o=o*u%mo;
		u=u*u%mo;
		v>>=1;
	}
	return o;
}
int n,k,i,sum;
bool a[200005],flag;
char s[200005];
int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
   	n=read();k=read();
   	scanf("%s",s);
   	for(i=0;i<n;i++)
   		if(s[i]=='A')
   			a[i]=0;
   		else
   			a[i]=1;
   	while(k--){
		if((a[sum]^flag)==0)
			a[sum]^=1;
		else{
			sum++;
			flag^=1;
			sum=(sum>=n?sum-n:sum);
		}
	}
	for(i=sum;i<n;i++)
		if((a[i]^flag)==0)
			putchar('A');
		else
			putchar('B');
	for(i=0;i<sum;i++)
		if((a[i]^flag)==0)
			putchar('A');
		else
			putchar('B');
	cout<<endl;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
const ll oo = 0x3f3f3f3f3f3f3f3f;

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  ll n, w;
  cin >> n >> w;
  
  ll N = n * 1000 + 100;
  vector<ll> dp(N, oo);
  dp[0] = 0;
  
  for(ll i = 0, a, b; i < n; ++i)
  {
  	cin >> a >> b;
    for(int j = N - 1; j >= 0; --j)
      if(dp[j] != oo)
        dp[j + b] = min(dp[j + b], dp[j] + a);
  }
  
  for(ll i = N - 1; i >= 0; --i)
  {
  	if(dp[i] <= w)
    {
      cout << i << endl;
      return 0;
    }
  }
  
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <cassert>
#include <set>
#include <map>
#include <bitset>
#include <unordered_set>
#include <string>
#include <cstring>
#include <cmath>

#define forn(x, a)             for (int x = 0; x < a; x++)
#define fore(x, a, b, c)       for (int x = a; x <= b; x += c)
#define forr(x, a)             for (int x = a; x >= 0; x--)
#define all(container)         (container).begin(), (container).end()
#define rall(container)        (container).rbegin(), (container).rend()
#define sz(container)          (int) container.size()
#define mp                     make_pair
#define fi                     first
#define se                     second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector< vector< int > > vvi;
typedef vector<bool> vb;
typedef vector<long long> vll;

#ifdef LOCAL_DEFINE
    #include "../../library/debug.hpp"
#else
    #define debug(...) 0
#endif

void read(int &a) {scanf("%d", &a);}
void read(ll &a) {scanf("%lld", &a);}
void read(char* a, string& s) {scanf("%s", a); s = string(a);}
void read(float &a) {scanf("%f", &a);}
void read(double &a) {scanf("%lf", &a);}
void print(vi &a) {for (auto& x: a) printf("%d ", x); puts("");}
void print(int &a) {printf("%d ", a);}
void println(int &a) {printf("%d\n", a);}

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
int h, w;
char line[10];
vector<string> field;

void solve() {
    read(h), read(w);
    field.resize(h);
    forn(i, h) read(line, field[i]);
    vector<vb> visited(h, vb(w, false));
    int cnt = 0;
    forn(i, h) forn(j, w) if (field[i][j] == '.') ++cnt;
    debug(cnt);
    if (cnt == h * w) puts("Possible");
    else if (field[0][0] != '#') puts("Impossible");
    else {
        pii pos = mp(0, 0);
        bool ok = true;
        while(1) {
            visited[pos.fi][pos.se] = true;
            if (pos.fi == h - 1 && pos.se == w - 1) break;
            if (pos.fi + 1 < h && field[pos.fi + 1][pos.se] == '#' && pos.se + 1 < w && field[pos.fi][pos.se + 1] == '#') {
                ok = false;
                break;
            }
            if (pos.fi + 1 < h && field[pos.fi + 1][pos.se] == '#') ++pos.fi;
            else if (pos.se + 1 < w && field[pos.fi][pos.se + 1] == '#') ++pos.se;
            else {
                ok = false;
                break;
            }
        }
        if (!ok) puts("Impossible");
        else {
            forn(i, h) forn(j, w) if (field[i][j] == '#' && !visited[i][j]) {
                puts("Impossible");
                return;
            }
            puts("Possible");
        }
    }
}

int main(void) {
    int T = 1;
    while (T--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long lcm(long x,long y){
    return x*y/gcd(x,y);
}
long num2(long x){
    long ans=0;
    while(x%2==0){
        x/=2;
        ans++;
    }
    return ans;
}
int main(void){
    long n,m,b = 1;
    cin >> n >> m;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i] /= 2;
    } 
    int k = num2(a[0]);
    for(int i=0;i<n;i++){
        if(num2(a[i])!=k){
            cout << 0 << endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++) b = lcm(a[i],b);
    cout << (long(m/b)+1)/2 << endl;
}

Measured memory_bytes: 3932