akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
    int h, w;
    cin >> h >> w;

    vector<string> s(h);
    REP(i, h) cin >> s[i];

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

    REP(i, h){
        REP(j, w){
            if(s[i][j] == '#') continue;

            int num = 0;

            for(int d = 0; d < 8; ++d){
                const int ni = i + dy[d];
                const int nj = j + dx[d];

                if(nj < 0 || h <= ni) continue;
                if(ni < 0 || w <= nj) continue;

                if( s[ni][nj]  == '#') ++num;
            }

            s[i][j] = char(num + '0');
        }
    }

    REP(i, h) cout << s[i] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
 
    int i, j;        // loop counter
 
    for(i=1;i<=9;i++){
        for(j=1;j<=9;j++){
             printf("%dx%d=%d\n", i, j, i*j);
        }
    }
 
    return 0;
}

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

int main() {
  
  int N;
  int A;
  cin >> N >> A;
  
  if ((N%500)<=A) {
    cout << "Yes" << endl;
  }
  
  if ((N%500)>A) {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,M; cin>>A>>B>>M;
  vector<int> a(A),b(B),x(M),y(M),c(M);
  for(int i=0;i<A;i++)cin>>a[i];
  for(int i=0;i<B;i++)cin>>b[i];
  int tmp,mini=1e6;
  for(int i=0;i<M;i++){
    cin>>x[i]>>y[i]>>c[i];
    tmp=a[x[i]-1]+b[y[i]-1]-c[i];
    //cout <<x[i]<<" "<<a[x[i]]<<" "<<y[i]<<" "<<b[y[i]]<<" "<<c[i]<<endl;
    if(mini>tmp)mini=tmp;
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  if(mini>a[0]+b[0]) mini=a[0]+b[0];
  cout <<mini<<endl;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <stdio.h>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
#define intl long long
#define mp make_pair
vector< vector<int> > grafo(101);
vector<bool> visitada;
vector<int> unidaA;
bool hayMatchingParaLaPersona(int persona){
    for(int i=0;i<grafo[persona].size();i++){
        int tarea = grafo[persona][i];
        if (!visitada[tarea]){
            visitada[tarea] = true;
            if (unidaA[tarea] == -1 || hayMatchingParaLaPersona(unidaA[tarea]) ){
                unidaA[tarea] = persona;
                return true;
            }
        }
    }
    return false;
}
int maximoMatching(){
    unidaA.assign(101, -1); 
    int result = 0;
    for (int persona = 0; persona < 101; persona++){
        visitada.assign(101, false);
        if (hayMatchingParaLaPersona(persona)){
            result++;
        }
    }
    return result;
}
struct point{
	int x;
	int y;
	int index;
};
int main(){
	int n;
	point m;
	cin>>n;
	vector <point> v;
	vector <point> v1;
	for(int i=0;i<n;i++){
		cin>>m.x>>m.y;
		m.index=i+1;
		v.push_back(m);		
	}
	for(int i=0;i<n;i++){
		cin>>m.x>>m.y;
		m.index=i+1;
		v1.push_back(m);		
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(v[i].x<v1[j].x&&v[i].y<v1[j].y){
				grafo[v1[j].index].push_back(v[i].index);
			}
		}
	}
	cout<<maximoMatching()<<endl;
	return 0;
}


Measured memory_bytes: 256
N, M = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(N - 1 + M)]

from collections import defaultdict
from copy import deepcopy

vs = defaultdict(set)
ws = defaultdict(set)
rws = defaultdict(int)

for a, b in AB:
    vs[a].add(b)
    ws[b].add(a)
    rws[b] += 1

#print(vs)
#print(ws)

# topological sort

L = []
S = [i for i in range(1, N + 1) if not rws[i]]

while S:
    n = S.pop()
    L.append(n)
    for m in vs[n]:
        rws[m] -= 1
        if not rws[m]:
            S.append(m)

#print(S)
#print(L)

nrank = dict((n, r) for r, n in enumerate(L))

#print(nrank)

for n in range(1, N + 1):
    r = 0
    if ws[n]:
        r = sorted(ws[n], key=lambda x:-nrank[x])[0]
    print(r)


Measured memory_bytes: 105552
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

// edit

void solve() {
    string s,t;
    cin >> s >> t;
    if(s == t.substr(0,s.size())){
        cout << "Yes"  << endl;
    }else{
        cout << "No" << endl;
    }
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include<vector>
#include<set>
#include<algorithm>
typedef long long int ll;
using namespace std;

#define MAX 100005
 
struct edge{
	int from,to;
};
 
int pa[MAX];
int ra[MAX];
 
void init(){
	for(int i=0;i<MAX;i++){
		pa[i]=i;
		ra[i]=1;
  	}
}
 
int find(int x){
  	if(pa[x]==x)return x;
	else return pa[x]=find(pa[x]);
}
 
void unite(int x,int y){
  	x=find(x),y=find(y);
  	if(x==y)return;
  	if(ra[x]<ra[y])swap(x,y);
  	pa[y]=x;
  	ra[x]+=ra[y];
}
 
bool same(int x,int y){
  	return (find(x)==find(y));
}
 
 
int main(){
	int n,m,a,b,ans=0;
    int p[MAX];
	cin >> n >> m;
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
	init();

    for(int i=0;i<m;i++){
        cin>>a>>b;
        unite(a,b);
    }
	
	for(int i=0;i<n;i++){
		if(same(p[i],i+1))ans++;
	}
  
  cout<<ans<<endl;
}

Measured memory_bytes: 1408
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

W, H, x, y = getNM()
if 2 * x == W and 2 * y == H:
    print(W * H / 2, 1)
else:
    print(W * H / 2, 0)

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

int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	char x[n];
	int d;
	cin >> x >> d;
	int c0=0, c1=0;
	for (int i = 0; i < n; ++i)
	{
		if (x[i]=='0') ++c0;
		else if (x[i]=='1') ++c1;
	}
	char ans[n]={};
	for (int i = 0; i < n; ++i)
	{
		ans[i] = x[i];
	}
	if (d>0)
	{
		for (int i = 0; i < n; ++i)
		{
			if (x[i]=='0')
			{
				ans[i] = '1';
				--d;
			}
			if (d==0)
			{
				break;
			}
		}
	}
	if (d>0)
	{
		for (int i = n-1; i >= 0; --i)
		{
			if (x[i] == '1')
			{
				ans[i] = '0';
				--d;
			}
			if (d==0)
			{
				break;
			}
		}
	}
	for (int i = 0; i < n; ++i)
	{
		cout << ans[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
using namespace std;
using ll = long long;
ll dp[1000000][13];
const ll MOD = 1000000007;

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

    dp[0][0] = 1;
    rep(i, 0, s.size())
    {
        if (s[i] == '?')
        {
            rep(k, 0, 10)
            rep(j, 0, 13)
            {
                dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
                dp[i + 1][(j * 10 + k) % 13] %= MOD ;
            }
        }
        else
            rep(j, 0, 13)
            {
                int k = s[i] - '0';
                dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
                dp[i + 1][(j * 10 + k) % 13] %= MOD;
            }
        // rep(j, 0, 13)
        //     cout << i << ' ' << j << ' ' << dp[i + 1][j] << endl;
    }
    cout << dp[s.size()][5] << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define INF 1e9

class Edge {
    public:
        ll Cost;
	    int To;
	    Edge(int t,ll c){
		    Cost = c;
		    To = t;
	    }
	    bool const operator<(Edge e) const {
		    return Cost < e.Cost;
	    }
};
 
 
class Dijkstra {
    public:
	    Dijkstra(int n,bool dir);
	    int I, V, E;
	    vector<ll> Cost;
	    void AddPath(int f, int t, ll c);
	    bool PathExist(int t);
	    void Run(int f);
    private:
	    bool isNonDir = true;
	    vector<vector<Edge>> Adj;
};
 
Dijkstra::Dijkstra(int n,bool dir) {
	isNonDir = dir;
	I = n + 1;
	V = n;
	Adj.resize(I);
}
 
 
void Dijkstra::AddPath(int f, int t, ll c) {
	E++;
	Adj[f].push_back(Edge(t, c));
	if (isNonDir) Adj[t].push_back(Edge(f, c));
}
 
bool Dijkstra::PathExist(int t) {
	return Cost[t] != INF;
}
 
void Dijkstra::Run(int f)
{
	priority_queue<Edge> pq;
	Cost.resize(I);
	for (int i = 0; i < I; i++){
		Cost[i] = INF;
	}
	Cost[f] = 0;
	pq.push(Edge(f, 0L));
 
	while (!pq.empty())
	{
		auto cur = pq.top();
		pq.pop();
 
		if (Cost[cur.To] < cur.Cost) continue;
		for (int i = 0; i < Adj[cur.To].size(); i++)
		{
			auto tmp = Adj[cur.To][i];
			if (Cost[tmp.To] > cur.Cost + tmp.Cost) {
				Cost[tmp.To] = cur.Cost + tmp.Cost;
				pq.push(Edge(tmp.To, Cost[tmp.To]));
			}
		}
	}
}

int main(void)
{
    int n, W, v[105], w[105], i, j, dp[105][10005] = {};

    cin >> n >> W;
    for(i = 0; i < n; i++){
        cin >> v[i] >> w[i];
    }

    for(i = 1; i <= n; i++){
        for(j = 1; j <= W; j++){
            if(j >= w[i - 1])dp[i][j] = max(dp[i - 1][j - w[i - 1]] + v[i - 1], dp[i - 1][j]);
            else dp[i][j] = dp[i - 1][j];
        }
    }

    cout << dp[n][W] << endl;
}


Measured memory_bytes: 7192
#include<iostream>
#include<queue>
using namespace std;
#include<vector>
#include<functional>
template<typename T>
struct lazysegtree{
	using F=function<T(T,T)>;
	using G=function<T(T,T,int,int)>;
	const F calcfn,lazycalcfn;
	const G updatefn;
	int n;
	T defvalue,lazydefvalue;
	vector<T>dat,lazy;
	vector<bool>lazyflag;
	lazysegtree(int n_=0,T defvalue_=0,
		const F calcfn_=[](T a,T b){return a+b;},
		const F lazycalcfn_=[](T a,T b){return a+b;},
		const G updatefn_=[](T a,T b,int l,int r){return a+b*(r-l);},
		T lazydefvalue_=0
	):defvalue(defvalue_),lazydefvalue(lazydefvalue_),
		calcfn(calcfn_),lazycalcfn(lazycalcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,defvalue);
		lazy.assign(2*n-1,lazydefvalue);
		lazyflag.assign(2*n-1,false);
	}
	void copy(const vector<T>&v)
	{
		for(int i=0;i<v.size();i++)dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--)dat[i]=calcfn(dat[2*i+1],dat[2*i+2]);
	}
	void eval(int i,int l,int r)
	{
		if(lazyflag[i])
		{
			dat[i]=updatefn(dat[i],lazy[i],l,r);
			if(r-l>1)
			{
				lazy[2*i+1]=lazycalcfn(lazy[2*i+1],lazy[i]);
				lazy[2*i+2]=lazycalcfn(lazy[2*i+2],lazy[i]);
				lazyflag[2*i+1]=lazyflag[2*i+2]=true;
			}
			lazy[i]=lazydefvalue;
			lazyflag[i]=false;
		}
	}
	void update(int a,int b,T x,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return;
		else if(a<=l&&r<=b)
		{
			lazy[k]=lazycalcfn(lazy[k],x);
			lazyflag[k]=true;
			eval(k,l,r);
		}
		else
		{
			update(a,b,x,2*k+1,l,(l+r)/2);
			update(a,b,x,2*k+2,(l+r)/2,r);
			dat[k]=calcfn(dat[2*k+1],dat[2*k+2]);
		}
	}
	T query(int a,int b,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return defvalue;
		else if(a<=l&&r<=b)return dat[k];
		else return calcfn(
			query(a,b,2*k+1,l,(l+r)/2),
			query(a,b,2*k+2,(l+r)/2,r)
		);
	}
};
string s;
int N,Q;
main()
{
	cin>>N>>Q>>s;
	priority_queue<int>X;
	lazysegtree<pair<int,int> >P(N+1,make_pair(2*N,2*N),
	[](pair<int,int>a,pair<int,int>b){return a<b?a:b;},
	[](pair<int,int>a,pair<int,int>b){return make_pair(a.first+b.first,0);},
	[](pair<int,int>a,pair<int,int>b,int l,int r){return make_pair(a.first+b.first,a.second);},
	make_pair(0,0));
	vector<pair<int,int> >init(N+1);
	init[0]=make_pair(0,1);
	for(int i=0;i<N;i++)
	{
		init[i+1].first=init[i].first;
		init[i+1].second=-i;
		if(s[i]=='(')init[i+1].first++;
		else
		{
			init[i+1].first--;
			X.push(-i);
		}
	}
	P.copy(init);
	for(;Q--;)
	{
		int id;cin>>id;
		id--;
		if(s[id]=='(')
		{
			s[id]=')';
			X.push(-id);
			while(s[-X.top()]=='(')X.pop();
			int jd=-X.top();
			cout<<jd+1<<endl;
			s[jd]='(';
			P.update(jd+1,id+1,make_pair(2,0));
		}
		else
		{
			s[id]='(';
			int jjd=1-P.query(0,id+1).second;
			int jd=1-P.query(jjd+1,id+1).second;
			cout<<jd+1<<endl;
			s[jd]=')';
			X.push(-jd);
			P.update(jd+1,id+1,make_pair(-2,0));
		}
	}
}



Measured memory_bytes: 24176
def divisors(N):
    U = int(N ** 0.5) + 1
    L = [i for i in range(1, U) if N % i == 0]
    return L + [N // i for i in reversed(L) if N != i * i]

N, K, *A = map(int, open(0).read().split())

for d in reversed(divisors(sum(A))):
    R = sorted(a % d for a in A)
    if sum(R[:-sum(R) // d]) <= K:
        print(d)
        quit()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

#define N 200008

int n;
int a[N],b[N];

void solve()
{
	int len = 0;
	for (int i = n; i>= 1; i-=2)
		b[++len] = a[i];
	for (int i = n-1,len = n; i >= 1; i-=2)
		b[len--] = a[i];
	for (int i = 1; i <= n; i++)
		printf("%d ", b[i]);
	printf("\n");
}

void init()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
}

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

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

int main()
{

	std::string str;
	std::cin >> str;

	bool hasA = false;
	bool hasB = false;

	for (auto s : str)
	{
		hasA = hasA || (s == 'A');
		hasB = hasB || (s == 'B');
	}

	std::cout << (hasA && hasB ? "Yes" : "No") << std::endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

a = [0, 2,5,5,4,5,6,3,7,6]

def sort_str(s):
    ret = list(s)
    ret.sort(reverse=True)
    return ''.join(ret)

def is_greater(a, b):
    if len(a) > len(b):
        return True
    elif len(a) < len(b):
        return False
    for i in range(len(a)):
        if a[i] > b[i]:
            return True
        else:
            return False
    return False

def _solve(n: int, m: int, A: "List[int]"):
    dp = [None] * (n + 1)
    dp[0] = ''
    for c in A:
        for i in range(n + 1):
            if i - a[c] >= 0 and dp[i - a[c]] is not None:
                tmp = sort_str(dp[i - a[c]] + str(c))
                if dp[i] is None or is_greater(tmp, dp[i]):
                    dp[i] = tmp
        #print(dp)
    print(dp[n])
    return

def solve(n: int, m: int, A: "List[int]"):
    dp = [-1] * (n + 1)
    memo = ['' for _ in range(n + 1)]
    dp[0] = 0
    A.sort(reverse=True)
    #A.sort()
    for c in A:
        for i in range(n + 1):
            if i - a[c] >= 0 and dp[i - a[c]] >= 0:
                dp[i] = max(dp[i], dp[i - a[c]] * 10 + c)
                #if dp[i] < dp[i - a[c]] + 1:
                #    dp[i] = dp[i - a[c]] + 1
                #    memo[i] = memo[i - a[c]] + str(c)
        #print(dp)
        #print(memo)
    print(dp[n])
    #ret = list(memo[n])
    #ret.sort(reverse=True)
    #ret = ''.join(ret)
    #print(ret)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(M) ]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16616
#include<stdio.h>
int main()
{
    int n,x,y,z,a;
    scanf("%d",&n);
    x=n/100;
    a=n%100;
    y=a/10;
    z=a%10;
    if(x*100+y*10+z==z*100+y*10+x)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
// agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define mod 998244353
#define endl '\n'
typedef  long long int ll ; 
using namespace std;
ll power(ll a, ll b)
{
    ll res=1LL;
    while(b>0){
        if(b&1) res=(res*a) %mod;
        a=(a*a)%mod;
        b>>=1;
    }
    
    return res%mod;
}
int main()
{
    ll n;
    cin>>n;
    int flag=0;
   int arr[n+5]={0};
   for(int i=1;i<=n;i++) {
       ll a;
       cin>>a;
       if(i==1 && a!=0) flag=1;
       arr[a]++;
   }
  if(flag){ cout<<0;  return 0; }
   int idx;
   for(int i=0;i<=n;i++){
       if(i==0 && arr[i]!=1) { flag=1; break; }
       else if (i==0 && arr[i]==1) continue;
       else if(arr[i]==0) {
           idx=i;
           for(int j=i+1;j<=n;j++) if(arr[j]!=0) { flag=1; break; }
            break;
       }
   }
   ll ans=1;
//   cout<<flag<<endl;
    // cout<<idx<<endl;
   if(flag){ cout<<0;  return 0; }
   for(int i=1;i<idx;i++){
       ans*=power(arr[i-1],arr[i]);
       ans%=mod;
   }
   cout<<ans<<endl;
  
   
   
   
    
    
    
}

Measured memory_bytes: 640
import sys
import math
l=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
j_day=a//c
j_amr=a%c
if(j_amr != 0):
    j_day=j_day+1
m_day=b//d
m_amr=b%d
if(m_amr != 0):
    m_day=m_day+1
if(j_day>=m_day):
    study_day=j_day
else:
    study_day=m_day
day=l-study_day
print(day)


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

int main(){
	int n;
	int a[100];
	int exchanges=0;
	bool flag = true;
	
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	while(flag){
		flag = false;
		for(int j=n-2;j>=0;j--){
			if(a[j]>a[j+1]){
				int tmp;
				tmp=a[j];
				a[j]=a[j+1];
				a[j+1]=tmp;
				flag = true;
				exchanges++;
			}
		
		}
	}
	for(int i=0;i<n;i++){
		if(i>0) cout<<" ";
		cout<<a[i];
	}
	cout<<endl;
	cout<<exchanges<<endl;
	return 0;	
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(void){
int n,x,a,b,c,sum=0;
while(1){
scanf("%d %d",&n,&x);
if(n==0&&x==0)break;
for(a=1;a<=n;a++){
for(b=a+1;b<=n;b++){
for(c=b+1;c<=n;c++){
if(a+b+c==x)sum++;
}
}
}
printf("%d\n",sum);
sum=0;
}
return 0;
}


Measured memory_bytes: 2000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int inf = 1001001001;
const int mod = 1000000007;
using pint=pair<ll,ll>;
 
// union by size + path having
class UnionFind {
public:
   vector <ll> par; // 各元の親を表す配列
   vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
 
   // Constructor
   UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
       for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
   }
   void init(ll sz_) {
       par.resize(sz_);
       siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
       for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
  }
 
   // Member Function
   // Find
   ll root(ll x) { // 根の検索
      while (par[x] != x) {
           x = par[x] = par[par[x]]; // x の親の親を x の親とする
       }
       return x;
  }
 
   // Union(Unite, Merge)
   bool unite(ll x, ll y) {
       x = root(x);
       y = root(y);
       if (x == y) return false;
       // merge technique（データ構造をマージするテク．小を大にくっつける)
       if (siz[x] < siz[y]) swap(x, y);
       siz[x] += siz[y];
       par[y] = x;
       return true;
  }
 
  bool same(ll x, ll y) { // 連結判定
       return root(x) == root(y);
  }
 
  ll size(ll x) { // 素集合のサイズ
      return siz[root(x)];
  }
};
 
ll modpow(ll x, ll n) {
   x = x%mod;
   if(n==0) return 1;  //再帰の終了条件
 
   else if(n%2==1) {
       return (x*modpow(x, n-1))%mod;  //nが奇数ならnを1ずらす
   }
   else return modpow((x*x)%mod, n/2)%mod;  //nが偶数ならnが半分になる
}
 
ll com(ll n, ll k) {
   ll x = 1;
   for(int i=n-k+1; i<=n; i++) {
      x = x*i%mod;
   }
 
   ll y = 1;
   for(int i=1; i<=k; i++) {
       y = y*i%mod;
   }
   y = modpow(y, mod-2);
 
   return x*y%mod;
}
 
int main(){

    ll n,k;
    cin >> n >> k;
    ll a=(n/k);
    ll b=(n/(k/2));
    ll c=b-a;

    if(k%2!=0){
        cout << a*a*a << endl;
    }
    else{
        cout << a*a*a+c*c*c << endl;
    }
 
}

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

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

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

    int n, m;
    cin >> n >> m;

    multiset< int> st;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        st.insert(x);
    }

    priority_queue< pair< int, int>> pq;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        pq.emplace(y, x);
    }

    LL res = 0;

    while (!pq.empty()) {
        int cnt = pq.top().second, val = pq.top().first;
        pq.pop();

        while (cnt-- && !st.empty()) {
            res += max(*st.begin(), val);
            st.erase(st.begin());
        }
    }

    while (!st.empty()) {
        res += *st.begin();
        st.erase(st.begin());
    }

    cout << res << endl;
}

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

typedef long long ll;
#define PB push_back

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	int a[n] = {0};
	for(int i = 0; i < n - 1; ++i) {
		int ai; cin >> ai;
		a[ai - 1]++;
	}
	for (int i = 0; i < n; i++) {
		cout << a[i] << "\n";
	}
}


Measured memory_bytes: 4444
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Program
{
    public class ABC073D
    {
        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static long NextLong() => long.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static public void Main(string[] args)
        {
            var N = Console_.NextInt();
            var M = Console_.NextInt();
            var R = Console_.NextInt();

            var rs = new int[R];
            for (int i = 0; i < R; ++i)
            {
                var r = Console_.NextInt();
                rs[i] = r - 1;
            }

            var dist = new int[N][];
            for (int i = 0; i < N; ++i)
            {
                dist[i] = new int[N];
                for (int j = 0; j < N; ++j)
                {
                    dist[i][j] = i == j ? 0 : 1000000000;
                }
            }
            for (int i = 0; i < M; ++i)
            {
                var A = Console_.NextInt();
                var B = Console_.NextInt();
                var C = Console_.NextInt();

                dist[A - 1][B - 1] = C;
                dist[B - 1][A - 1] = C;
            }

            for (int k = 0; k < N; ++k)
            {
                for (int i = 0; i < N; ++i)
                {
                    for (int j = 0; j < N; ++j)
                    {
                        dist[i][j] = Math.Min(dist[i][j], dist[i][k] + dist[k][j]);
                    }
                }
            }

            Console.WriteLine(MinCost(-1, rs, dist));
        }

        public static int MinCost(int first, int[] tgt, int[][] dist)
        {
            if (tgt.Length == 0) return 0;
            int min = 1000000000;
            for (int i = 0; i < tgt.Length; ++i)
            {
                var list = tgt.ToList();
                list.RemoveAt(i);
                var c = (first != -1 ? dist[first][tgt[i]] : 0) + MinCost(tgt[i], list.ToArray(), dist);
                if (c < min) min = c;
            }
            return min;
        }
    }
}


Measured memory_bytes: 15688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		sc.close();
		
		int count = 0;
		for(int i = A; i <= B; i++) {
			String tmp = String.valueOf(i);
			if(tmp.charAt(0) == tmp.charAt(4) && tmp.charAt(1) == tmp.charAt(3)) {
				count++;
			}
		}
		System.out.println(count);
	}

}

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

int N;
int64_t A[401], S[401];
int64_t dp[401][401];

int64_t rec(int L, int R){
    if(L == R) return 0;
    if(dp[L][R] >= 0) return dp[L][R];
    int64_t ret = 1e18;
    for(int i=L; i<R; i++){
        int64_t result = rec(L, i) + rec(i+1, R) + S[R] - S[L-1];
        ret = min(ret, result);
    }
    dp[L][R] = ret;
    return ret;
}

int main(){
    cin >> N;
    for(int i=1; i<=N; i++){
        cin >> A[i];
        S[i] = A[i] + S[i-1];
    }
    for(int i=0; i<=400; i++) for(int j=0; j<=400; j++) dp[i][j] = -1;
    cout << rec(1, N) << endl;
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;

#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rrep(i,N) for(int i=(int)(N)-1;i>=0;--i)
#define debug(x) cout<<#x<<"="<<x<<endl;
constexpr ll MOD=1000000007;
constexpr ll INF=1LL<<60;
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end
int W,H;
const int ma=1<<20;
int Id(int h,int w){return h*W+w;}
void solve(){
    while((cin>>W>>H,W|H)){
        vector<vector<int>> g(H*W);
        rep(j,2*H-1){
            if(j%2){
                rep(i,W){
                    int a;cin>>a;
                    if(!a){
                        g[Id(j/2,i)].push_back(Id(j/2+1,i));
                        g[Id(j/2+1,i)].push_back(Id(j/2,i));
                    }
                }
            }else{
                rep(i,W-1){
                    int a;cin>>a;
                    if(!a){g[Id(j/2,i)].push_back(Id(j/2,i+1));g[Id(j/2,i+1)].push_back(Id(j/2,i));}
                }
            }
        }
        queue<int> q;
        vector<int> dist(W*H,ma);
        dist[0]=1;
        q.push(0);
        while(q.size()){
            int p=q.front();q.pop();
            for(int e:g[p])
                if(dist[e]==ma){
                    dist[e]=dist[p]+1;q.push(e);
                }
        }
        if(dist[H*W-1]==ma)cout<<0<<endl;
        else cout<<dist[H*W-1]<<endl;
    }
}

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


Measured memory_bytes: 3172
while True:
    try:
        a, op, b = map(str, input().split())
        a = int(a)
        b = int(b)
        if op == '+':
            print(a+b)
        elif op == '-':
            print(a-b)
        elif op == '*':
            print(a*b)
        elif op == '/':
            print(a//b)
        elif op == '?':
            break;
    except:
        break;      


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

/*** MOD CALCULATION ***/

// const int MOD = 1e9+7;
const int MOD = 998244353;
const int MAX = 2'000'005;

ll addM(ll a, ll b){
	return ((a % MOD) + (b % MOD)) % MOD;
}

ll mulM(ll a, ll b){
	return ((a % MOD) * (b % MOD)) % MOD;
}

ll powM(ll a, ll b){
	if(b == 0) return 1;
  	else if(b == 1) return a % MOD;
  	else if(b%2==0) return mulM(powM(a, b/2), powM(a, b/2));
  	else return mulM(a, mulM(powM(a, (b-1)/2), powM(a, (b-1)/2)));
}

// b^{-1} = b^{p-2} (mod p)
// a/b = a*b^{p-2} (mod p)
ll divM(ll a, ll b){ 
  	return mulM(a, powM(b, MOD-2));
}

// n!, (n!)^{-1} のテーブル作成
ll fac[MAX], finv[MAX], inv[MAX];
void COMBinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    rep3(i,2,MAX-1){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COMB(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

/*** MOD CALCULATION ここまで ***/

vvi to;

int dfs(int v){
    int res = 1;
    for(auto u : to[v]){
        res = mulM(res, dfs(u));
    }
    return addM(res, 1);
}

void Main(){
    int n; cin >> n;
    vector<P> robot(n);
    rep(i, n) cin >> robot[i].fi >> robot[i].se;
    sort(all(robot));
    
    // to は有向グラフだが実は木になる
    to.resize(n);
    // s には {x, id} を記憶
    set<P> s;
    
    rep3rev(i, n-1, 0){
        int x = robot[i].fi, d = robot[i].se;
        while(!s.empty() && s.begin()->fi < x+d){
            to[i].pb(s.begin()->se);
            s.erase(s.begin());
        }
        s.insert({x, i});
    }
    
    int ans = 1;
    for(auto [x, v] : s){
        ans = mulM(ans, dfs(v));
    }

    cout << ans << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 24956
var lines = []; var result = 0;
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0]);
    var A = lines[1].split(" ").map(value => Number(value));

    for (var i = 0; i < 30; i++) {
        for (var j = 0; j < N; j++) {
            if (A[j] % 2 !== 0) { console.log(result); return (0); }
            A[j] /= 2;
        }
        result++;
    }
});

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

int main(){
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<int> ans(N+1,0);
  int count = 0;
  
  for(int i=1; i <= N-1; i++){
    for(int j=i+1; j<=N; j++){
      vector<int> kouho = {abs(j-i), abs(X-i)+1+abs(Y-j), abs(Y-i)+1+abs(X-j)};
      sort(kouho.begin(), kouho.end());
      int min = kouho.at(0);
      ans.at(min)++;
    }
  }
  for(int i=1; i<N; i++) cout<<ans.at(i)<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#include<string>
using namespace std;
#define ll long long
typedef pair<ll , ll > pii;
ll mod=998244353;
ll p=1e9+7;

int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    int h,w; cin>>h>>w;
    int a[100][100];
    for(int i=0; i<h; i++){
        string s; cin>>s;
        for(int j=0; j<w; j++){
            if(s[j] == '#') a[i][j]=1;
            else a[i][j]=0;
        }
    }
    int dp[100][100];
    dp[0][0]=a[0][0];
    for(int i=1; i<w; i++){
        if(a[0][i] == 0) dp[0][i]= dp[0][i-1];
        else{
            dp[0][i]=dp[0][i-1]+(a[0][i-1] == 0);
        }
    }
    for(int i=1; i<h; i++){
        if(a[i][0] == 0) dp[i][0]= dp[i-1][0];
        else{
            dp[i][0]=dp[i-1][0]+(a[i-1][0] == 0);
        }
    }
    for(int i=1; i<h; i++){
        for(int j=1; j<w; j++){
            if( a[i][j] == 0 ) dp[i][j]=min(dp[i][j-1], dp[i-1][j]);
            else dp[i][j]=min( dp[i-1][j]+ (a[i-1][j] == 0) , dp[i][j-1]+ (a[i][j-1] == 0 ));

        }
    }
    int ans=dp[h-1][w-1];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
/*
w2sc
2019/12/19
15:15:49
*/
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
using namespace std;
int n,k;
int main()
{
    cin>>n>>k;
    vector<bool> a(n);
    getchar();
    for(int i=0;i<n;i++)
    {
        char c=getchar();
        a[i]=(c=='R');
    }
    int cnt=0;
    for(int i=0;i<n;i++)
        cnt+=((i<n && a[i] && a[i+1]) || (i && !a[i] && !a[i-1]));
    printf("%d\n",min(n-1,cnt+2*k));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c;
  cin>>a>>b>>c;
  cout<<a<<" "<<b<<" "<<3*c-b-a<<endl;
  cout<<4*c-2*a-b<<" "<<c<<" "<<2*a+b-2*c<<endl;
  cout<<a+b-c<<" "<<2*c-b<<" "<<2*c-a<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int swap(int x, int y)
{
    int temp;
    temp = x;
    x = y;
    y = temp;
    
    return x, y;
}

int main(void)
{
    int x, y, r;
    scanf("%d %d", &x, &y);
    
    if ( x < y) {
    swap(x, y);
    }

    while ( y > 0) {
    r = x % y;
    x = y;
    y = r;
    }
    
    printf("%d\n", x);
    
    return 0;
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);


template<class T> int latter(const vector<T> &v, T x) {
  return upper_bound(v.begin(), v.end(), x) - v.begin();
}
template<class T> int former(const vector<T> &v, T x) {
  return lower_bound(v.begin(), v.end(), x) - v.begin() - 1;
}


int main() {
  int N; cin >> N;
  vector<int> a(N+1);
  rep(i, N) cin >> a[i];
  a[N] = INF;



  vector<int> ans;
  ans.push_back(-INF);
  ans.push_back(-a[0]);
  for(int i = 1; i < N; i++) {
    int asize = ans.size();
    if (a[i] <= -ans[asize-1]) {
      ans.push_back(-a[i]);
      continue;
    }

    int nx = latter(ans, -a[i]);
    if (nx == 0) {
      ans[1] = -a[i];
    } else {
      ans[nx] = -a[i];
    }
  }

  cout << ans.size()-1 << endl;



  return 0;
}

Measured memory_bytes: 1276
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = int;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 3010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int p, MOD, a[MAXN];
vector<int> t = {0, 1}; // x

ll binPowMod(ll a, ll b) {
    a %= MOD;
    ll res = 1;
    while (b > 0) {
        if (b & 1LL) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1LL;
    }
    return res;
}

ll add(ll a, ll b) {
    return (a + b) % MOD;
}

ll mul(ll a, ll b) {
    return a * b % MOD;
}

ll inv(ll x) {
    return binPowMod(x, MOD-2);
}

vector<int> mul(const vector<int> &p, int j) {
    // p[0] + p[1] * x + p[2] * x^2 + ... + p[n-1] * x^(n-1)
    // multiply
    // x - j
    int n = SZ(p);
    vector<int> res(n+1,0); // 0 -> n
    FOR(i,0,n-1) res[i+1] = add(res[i+1], p[i]);
    FOR(i,0,n-1) res[i] = add(res[i], mul(p[i], j));
    return res;
}

vector<int> div(vector<int> p, int j) {
    // p[0] + p[1] * x + ... + p[n-1] * x^(n-1)
    // divide
    // x - j
    int n = SZ(p);
    vector<int> res(n-1,0);
    FORE(i,n-1,1) {
        p[i-1] = add(p[i-1], mul(j, p[i]));
        res[i-1] = p[i];
    }
    return res;
}

int get(const vector<int> &p, int x) {
    // f(x) = p[0] + p[1] * x + ... + p[n-1] * x^(n-1)
    // now = x^y
    int res = 0, now = 1;
    FOR(i,0,SZ(p)-1) {
        res = add(res, mul(p[i], now));
        now = mul(now, x);
    }
    return res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> p;
    FOR(i,0,p-1) cin >> a[i];
    MOD = p;
    FOR(i,1,p-1) t = mul(t, i);
    vector<int> res(p, 0);

    FOR(i,0,p-1) {
        if (!a[i]) continue;
        vector<int> s = div(t,i);
        int cur = get(s,i);
        cur = inv(cur);
        FOR(j,0,SZ(s)-1) res[j] = add(res[j], mul(s[j], cur));
    }

    FOR(i,0,p-1) cout << res[i] << ' ';
    return 0;
}


Measured memory_bytes: 3708
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from collections import deque
from decimal import *
import queue

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N,D = inputMap()
	ans = 0
	for i in range(N):
		X,Y = inputMap()
		tmp = math.sqrt(X**2 + Y**2)
		if tmp <= D:
			ans += 1

	print(ans)


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 78480
#include <stdio.h>

int main (void)
{
    int a,b,c;

    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);

    if(a+c == b||a+b == c||b+c == a)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;

        

}

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

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

	int i = 0;
	bool flag = true;

	while(flag && i < s.size()){
		int j = i + 1;
		if(j % 2 == 0){
			if(s[i] == 'L' || s[i] == 'U' ||s[i] == 'D') {}
			else { flag = false;}
		}else{
			if(s[i] == 'R' || s[i] == 'U' ||s[i] == 'D'){}
			else{flag = false;}
		}
		i++;
	}

	if(flag == true) cout << "Yes" << endl;
	else cout << "No" << endl;

}



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

using namespace std;

int main (void) {
    string s;
    cin >> s;
    size_t count = 0;
    char prev = '\0';
    for (auto& e : s) {
        if (e != prev ) ++count;
        prev = e;
    }
    cout << --count << endl;
}


Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)


	sum := 0
	for i := 0; i <n ; i++ {
		var a int
		fmt.Scan(&a)
		sum += a
	}

	if  sum % 2 == 0 {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}


Measured memory_bytes: 6324
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a,b;
  cin>>n;
  if(n==1){
    cout<<"Hello World";
  }
  else{
    cin>>a>>b;
    cout<<a+b;
  }
  
  return(0);
}


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

using namespace std;

int main() {
  while (true) {
    double x, h;
    cin >> x >> h;
    if (x == 0)
      break;
    double a = x * x + 2 * x * sqrt(x * x / 4 + h * h);
    printf("%lf\n", a);
  }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
 

 
int main(){
    
    int ans=0,a,b,mouth;
    cin>>a>>b;
    mouth=1;
    while(mouth<b){
        mouth+=a-1;
        ans++;
    }
    cout<<ans<<endl;
}

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

int main()
{
    long long A, B, C, K;
    cin >> A >> B >> C >> K;
    long long ans = 0;
    if (A <= K)
    {
        ans += A;
        K -= A;
    }
    else
    {
        cout << K << endl;
        return 0;
    }
    if (B <= K)
    {
        K -= B;
    }
    else
    {
        cout << ans << endl;
        return 0;
    }
    if (C <= K)
    {
        ans -= C;
        K -= C;
    }
    else
    {
        ans -= K;
        cout << ans << endl;
        return 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[100011];
int B[100011];
int C[100011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d%d", A+i, B+i);

    LL ans = 1LL<<60;
    LL tmp = 0;
    REP (i, N) tmp += A[i];
    amin(ans, tmp);
    tmp = 0;
    REP (i, N) tmp += B[i];
    amin(ans, tmp);

    tmp = 0;
    vector<pair<int, int> > P; P.reserve(N+N);
    REP (i, N) {
	P.emplace_back(A[i], i);
	P.emplace_back(B[i], i);
    }
    sort(P.begin(), P.end());
    REP (i, N) {
	C[P[i].second]++;
	tmp += P[i].first;
    }

    if (*max_element(C, C+N) == 1) {
	P[N].second;
	REP (i, N) {
	    if (P[i].second == P[N].second) continue;
	    amin(ans, tmp - P[i].first + P[N].first);
	}
    }

    REP (t, 2) {
	if (*max_element(C, C+N) == 1) {
	    int k = N-1+t;
	    C[P[k].second]--;
	    tmp -= P[k].first;
	    k++;
	    C[P[k].second]++;
	    tmp += P[k].first;
	}
    }

    amin(ans, tmp);
    printf("%lld\n", ans);
    

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

int main(){
    int t,i,j,n,a[20],b,c[20],f=0,s=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=0;i<n;i++){
        cin>>b;
        s=s+b;
    }
    for(i=0;i<n-1;i++){
        cin>>c[i];
    }
    for(i=0;i<n-1;i++){
        if(a[i]==a[i+1]-1){s=s+c[a[i]-1];}    //cout<<c[a[i]]<<endl;
    }
    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in =new Scanner(System.in);
		while(in.hasNext())
		{
			double m=in.nextDouble();
			double t=m/9.8;
			double y=4.9*t*t;
			int f=0;
			while(true)
			{
				if(5*f-5>y)
					break;
				f++;
			}
			System.out.println(f);
		}
	}
}

Measured memory_bytes: 12000
N, K = list(map(int, input().split(' ')))
#print(N, K)

P = 0

for i in range(1, N + 1):
    if(i < K):
        count = 1
        while(i * 2 ** count < K):
            count += 1
        #print(count)
        P += 1 / N * (0.5 ** count)
    else:
        P += 1 / N

print(round(P, 12))

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

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  if(a[0] + a[1] == a[2]) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int kane = 0;
  if(a == 3){
    kane += 100000;
  }
  if(b == 3){
    kane += 100000;
  }
  if(a == 2){
    kane += 200000;
  }
  if(b == 2){
    kane += 200000;
  }
  if(a == 1){
    kane += 300000;
  }
  if(b == 1){
    kane += 300000;
  }
  if(a == 1 && b == 1){
    kane += 400000;
  }
  cout << kane << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main()
{
  string s;
  cin >> s;
  ll n = s.length();
  ll count0 = 0, count1 = 0;
  ll nums[n + 10];
  ll rn = 0, ln = 0;
  bool t = true;
  rep(i, n) nums[i] = 1;

  rep(i, n - 1)
  {
    if (s[i] == 'R' && s[i + 1] == 'R')
    {
      if (i % 2 == 0)
      {
        count0++;
      }
      else
        count1++;
      nums[i]--;
    }
    else if (s[i] == 'R' && s[i + 1] == 'L')
    {
      if (i % 2 == 0)
      {
        nums[i] += count0;
        nums[i + 1] += count1;
      }
      else
      {
        nums[i] += count1;
        nums[i + 1] += count0;
      }
      count0 = 0;
      count1 = 0;
    }
  }
  reverse(s.begin(),s.end());
  rep(i, n - 1)
  {
    if (s[i] == 'L' && s[i + 1] == 'L')
    {
      if (i % 2 == 0)
      {
        count0++;
      }
      else
        count1++;
      nums[n-1-i]--;
    }
    else if (s[i] == 'L' && s[i + 1] == 'R')
    {
      if (i % 2 == 0)
      {
        nums[n-1-i] += count0;
        nums[n - i-2] += count1;
      }
      else
      {
        nums[n - 1 - i] += count1;
        nums[n -i-2] += count0;
      }
      count0 = 0;
      count1 = 0;
    }
  }
  

  rep(i, n) cout << nums[i] << " ";

  return 0;
}


Measured memory_bytes: 1408