akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
const int    dx[]={-1,0,0,1};
const int    dy[]={0,-1,1,0};
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

//幾何学テンプレート

#define equals(a,b) (fabs((a)-(b))<EPS)

//点
class Point{
public:
  double x,y;

  Point(double x = 0,double y = 0):x(x), y(y){};

  Point operator + (Point p) {return Point (x+p.x, y+p.y);}
  Point operator - (Point p) {return Point (x-p.x, y-p.y);}
  Point operator * (double a) {return Point(a*x, a*y);}
  Point operator / (double a) {return Point(x/a,y/a);}

  double abs(){return sqrt(norm());}
  double norm(){return x*x+y*y;}

  bool operator < (const Point &p)const{
    return x!=p.x ? x<p.x:y<p.y;
  }
  bool operator > (const Point &p)const{
    return x!=p.x ? x>p.x:y>p.y;
  }
  bool operator == (const Point &p)const{
    return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
  }
};

//ベクトル
typedef Point Vector;

//内積
double dot(Vector a,Vector b){
  return a.x*b.x+a.y*b.y;
}

//外積
double cross(Vector a,Vector b){
  return a.x*b.y-a.y*b.x;
}

//線分
struct Segment{Point p1,p2;};

//直線
typedef Segment Line;

//円
class Circle{
public:
  Point c;   //中心
  double r;  //半径
  Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

//多角形
typedef vector<Point> Polygon;


//円と直線の交点を求める。

//二つの線分の交差判定をする。
//3点の位置関係を調べる。

static const int COUNTER_CLOCKWISE=1;
static const int CLOCKWISE=-1;
static const int ONLINE_BACK=2;
static const int ONLINE_FRONT=-2;
static const int ON_SEGMENT=0;

int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>EPS)   return COUNTER_CLOCKWISE;
  if(cross(a,b)<-EPS)  return CLOCKWISE;
  if(dot(a,b)<-EPS)    return ONLINE_BACK;
  if(a.norm()<b.norm())return ONLINE_FRONT;

  return ON_SEGMENT;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
  return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0&&
          ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2){
  return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

//ある点から、直線/線分に対する射影を求める。
Point project(Segment s, Point p){
  Vector base=s.p2-s.p1;
  double r=dot(p-s.p1,base)/base.norm();
  return s.p1+base*r;
}

pair<Point,Point> getCrossPoints(Circle c,Line l){
  Vector pr=project(l,c.c);
  Vector e=(l.p2-l.p1)/(l.p2-l.p1).abs();
  double base=sqrt(c.r*c.r-(pr-c.c).norm());
  return make_pair(pr+e*base,pr-e*base);
}


signed main(){
  double cx,cy,r;cin>>cx>>cy>>r;
  Circle c={Point{cx,cy},r};
  int q;cin>>q;
  for(int i=0;i<q;i++){
    double x0,y0,x1,y1;cin>>x0>>y0>>x1>>y1;
    Point p1={x0,y0},p2={x1,y1};
    Line l={p1,p2};
    Point ans1,ans2;
    tie(ans1,ans2)=getCrossPoints(c,l);
    vector<Point>v;
    v.push_back(ans1);
    v.push_back(ans2);
    sort(v.begin(),v.end());
    cout<<fixed<<setprecision(15)<<v[0].x<<" "<<v[0].y<<" "<<v[1].x<<" "<<v[1].y<<endl;

  }

  return 0;
}



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

int main(){
    int N;  cin >> N;
    vector<string> S(N);
    for(int i=0; i<N; i++){
        cin >> S[i];
    }

    vector<vector<int>> cnt = vector<vector<int>>(N, vector<int>(26, 0));
    for(int i=0; i<N; i++){
        for(int j=0; j<S[i].length(); j++){
            cnt[i][S[i][j] - 'a']++;
        }
    }
    
    string ans = "";
    for(int i=0; i<26; i++){
        int c = 1e9;
        for(int n=0; n<N; n++){
            c = min(c, cnt[n][i]);
        }
        ans += string(c, 'a' + i);
    }
    cout << ans << endl;
}   

Measured memory_bytes: 256
#include <climits>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <set>

using namespace std;


int main()
{
	int n;
	scanf("%d", &n);
	int m;
	scanf("%d", &m);
	int a;
	scanf("%d", &a);
	int b;
	scanf("%d", &b);

	int count = (n - a)*(m - b);

	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 256
/*
 * 	Roses are red
 * 		Violets are blue
 * 			I cried
 * 				And so did you
 */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifndef rd
#define endl '\n'
#endif
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=2e18;
const int infi=1e9;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> oset;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
auto clk=clock();
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void solve() {
	int n,te;
	cin>>n;
	vi a;
	fr(i,1,n) {
		cin>>te;
		a.pb(te);
	}
	int ans=infl;
	fr(i,-100,100) {
		int cost=0;
		trav(j,a) {
			cost+=(i-j)*(i-j);
		}
		ans=min(ans,cost);
	}
	cout<<ans<<endl;
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
using less_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
using great_set = tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update>;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
const int N = 2e3+69;
#define ALL(x) begin(x),end(x)
#define sz(x) (ll)x.size()
const int OO = 0x3f3f3f3f;
const int mod = 1e9+7;


int n;
int arr[200069];
map<ll, ll> cum;


int main()
{
    FIO
    cin >> n;
    ll ans = 0;
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    for(int i = 0; i< n; i++)
        cum[i+arr[i]]++;
    for(int i = 0; i< n; i++)
        ans += cum[i-arr[i]];
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 27040
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, d;
    cin >> n >> d;

    auto p = initVec2<int>(n, d);
    rep(i, n){
        rep(j, d){
            cin >> p[i][j];
        }
    }

    int ans = 0;
    rep(i, n){
        for(int j = i + 1; j < n; j++){
            int sum = 0;
            rep(k, d){
                sum += (p[i][k] - p[j][k]) * (p[i][k] - p[j][k]);
            }

            bool ok = false;
            for(int k = 1; k * k <= sum; k++){
                if(k * k != sum){
                    continue;
                }
                ok = true;
            }
            if(ok){
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

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

    int cnt = 1;
    while(true) {
        int res = 0.5 * cnt * (cnt + 1);
        int res2 = 0.5 * (cnt + 1) * (cnt + 2);
        if(res - a == res2 - b) {
            cout << res - a << endl;
            break;
        }
        cnt++;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<deque>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX_LEN 16
#define MAX_STATE (1<<16)

using namespace std;
typedef pair<int,int> ii;

const int DIFF = 3;
int N,H[MAX_LEN],W[MAX_LEN];
int bitmask[MAX_LEN][12][12][3][2]; // bitmask[type][y][x][color][bool] bool = false -> erase , true -> insert
bool mincost[MAX_STATE];
char G[4][4];
char color[] = {'R','G','B'};

inline void makeBitMask(){
  REP(y,-3,8)REP(x,-3,8)rep(stamp,N)rep(c,3)rep(cy,H[stamp])rep(cx,W[stamp]){
    int nx = x + cx;
    int ny = y + cy;
    if( !( 0 <= nx && nx < 4 && 0 <= ny && ny < 4 ) )continue;
    if( G[ny][nx] == color[c] )bitmask[stamp][y+DIFF][x+DIFF][c][true]  |= (1<<(nx+(ny*4)));
    else                       bitmask[stamp][y+DIFF][x+DIFF][c][false] |= (1<<(nx+(ny*4)));
  }
}

inline void compute(){
  for(bool& i : mincost)i = false;
  mincost[0] = true;
  deque<ii> deq;
  deq.push_back(ii(0,0));
  while(!deq.empty()){
    ii data = deq.front(); deq.pop_front();

    if( data.first == (MAX_STATE-1) ){
      cout << data.second << endl;
      break;
    }

    rep(stamp,N)rep(col,3)REP(y,-3,8)REP(x,-3,8){
      int state = ( data.first | bitmask[stamp][y+DIFF][x+DIFF][col][true] ) & (~bitmask[stamp][y+DIFF][x+DIFF][col][false]);
      if(mincost[state])continue;
      mincost[state] = true;
      deq.push_back(ii(state,data.second+1));
    }
  }
}

int main(){
  cin >> N;
  rep(i,N)cin >> H[i] >> W[i];
  rep(y,4)rep(x,4)cin >> G[y][x];
  makeBitMask();
  compute();
  return 0;
}

Measured memory_bytes: 1524
#include <iostream>
#include <string>
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <stack>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
using namespace std;

struct Block
{
	int Num, Count;
	Block() { Num = Count = 0; }
	Block(int n, int c) { Num = n; Count = c; }
};

struct Integer
{
	stack<Block> blocks;
	stack<int> sum;
	int P;
	Integer(int n, int p) { blocks.emplace(0, n); sum.emplace(0); sum.emplace(n); P = p; }
	void Add(int c) { Push(Block(0, c)); }
	int Length() { return sum.top(); }
	void Take(int c)
	{
		Block b;
		while (Length() > c) b = Pop();
		if (Length() < c) Push(Block(b.Num, c - Length()));
	}
	bool Increment()
	{
		auto b = Pop();
		auto x = b.Num;
		auto n = b.Count;
		if (x == P - 1 && Length() == 0) return false;
		// y*m x*n => y*(m-1) (y+1)*1 0*n
		if (x == P - 1)
		{
			b = Pop();
			auto y = b.Num;
			auto m = b.Count;
			Push(Block(y, m - 1));
			Push(Block(y + 1, 1));
			Push(Block(0, n));
		}
		// x*n => x*(n-1) (x+1)*1
		else
		{
			Push(Block(x, n - 1));
			Push(Block(x + 1, 1));
		}
		return true;
	}
	Block Pop()
	{
		auto x = blocks.top(); blocks.pop();
		sum.pop();
		return x;
	}
	void Push(const Block& b)
	{
		if (b.Count == 0) return;
		auto p = b;
		if (Length() > 0 && blocks.top().Num == b.Num) p = Block(b.Num, b.Count + Pop().Count);
		blocks.emplace(p);
		sum.emplace(Length() + p.Count);
	}
};

int N;
vector<int> A;

bool check(int p)
{
	Integer S(A[0], p);
	for (size_t i = 1; i < N; i++)
	{
		auto a = A[i];
		if (a > S.Length()) S.Add(a - S.Length());
		else
		{
			S.Take(a);
			if (!S.Increment()) return false;
		}
	}
	return true;
}

int FirstBinary(int min, int max, function<bool(int)> pred)
{
	while (min < max)
	{
		auto mid = (min + max) / 2;
		if (pred(mid)) max = mid;
		else min = mid + 1;
	}
	return min;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	for (size_t i = 0; i < N; i++)
	{
		int x; cin >> x;
		A.push_back(x);
	}
	cout << FirstBinary(1, N, check) << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char* argv[]) {
  int N, Q;
  std::cin >> N >> Q;
  std::string S;
  std::cin >> S;
  std::vector<int> d(N + 1);
  int cnt = 0;
  for (int i = 2; i <= N; i++) {
    if (S[i - 2] == 'A' && S[i - 1] == 'C') {
      cnt++;
    }
    d[i] = cnt;
  }
  int l, r;
  for (int i = 0; i < Q; i++) {
    std::cin >> l >> r;
    int l_cnt = d[l];
    int r_cnt = d[r];
    int ret   = r_cnt - l_cnt;
    std::cout << ret << std::endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<set>
#include<iterator>
using namespace std;

multiset<int> s;
const int BN = 1024 * 1024;
int a[BN];
int n;


int main() {

	for (int i = 0; i < BN; i++)
		a[i] = 0;

	cin >> n;
	int maxi = 0;
	int aux;
	for (int i = 0; i < n; i++)
	{
		cin >> aux;
		a[aux]++;
		maxi = (aux > maxi) ? aux : maxi;
	}
	for (int i = 1; i <= maxi; i++)
		if (a[i] > 1)
			s.insert(a[i]);

	int ans = n;
	
	while (s.size() > 1)
	{
		set<int>::reverse_iterator it = s.crbegin();
		if (*it == 2)
		{
			int a = *it;
			int b = *(++it);
			a -= b - 1;
			ans -= (b - 1) * 2;
			s.erase(--(--s.end()), s.end());
			if (a > 1)
				s.insert(a);
		}
		else
		{
			int a = *it;
			if (a % 2 == 1)
			{
				ans -= a - 1;
				s.erase(--s.end(), s.end());
			}
			else
			{
				ans -= a - 2;
				s.erase(--s.end(), s.end());
				s.insert(2);
			}
		}
	}
	if (!s.empty())
		ans -= (*s.begin() % 2 == 1) ? (*s.begin() - 1) : (*s.begin());

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	bool ans = true;
	ll n;
	cin >> n;
	ll a[n];
	zep(i, 0, n){
		cin >> a[i];
		if(a[i]%2 == 0){
			if(a[i]%3 != 0 && a[i]%5 != 0){
				ans = false;
			}
		}
	}
	print((ans)? "APPROVED" : "DENIED")
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<iostream>
#define M 2000000000
using namespace std;
int dp[1001][1001];
int main(void)
{
	int i,j,n,m;
	vector<int> c,d;
	cin>>n>>m;
	d.resize(n);c.resize(m);
	for(i=0;i<n;i++) cin>>d[i];
	for(i=0;i<m;i++) cin>>c[i];
	for(i=0;i<=m;i++) {
		for(j=0;j<=n;j++) dp[i][j]=M;
	}
	dp[0][0]=0;	
	for(i=0;i<m;i++) {
		for(j=0;j<=n;j++) {
			if(dp[i][j]!=M) {
				dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
				if(j+1<=n) dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+c[i]*d[j]);
			}
		}
	}
	cout << dp[m][n] << endl;
}
	

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

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

	ll ans = 0;
	for(int i=1; i<=n; i++) {
		if (i % 3 != 0 && i % 5 != 0)
			ans += i;
	}

	cout << ans << endl;

}


Measured memory_bytes: 3596
import static java.lang.Integer.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static int N;
	public static int LI;

	public static int[] x;
	public static int[] y;
	public static long[] h;
	public static long ah;
	public static int ax;
	public static int ay;


	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
		st = new StringTokenizer(br.readLine());
		N = parseInt(st.nextToken());

		x = new int[N];
		y = new int[N];
		h = new long[N];


		for(int i=0;i<N;i++) {
			st = new StringTokenizer(br.readLine());
			x[i] = parseInt(st.nextToken());
			y[i] = parseInt(st.nextToken());
			h[i] = parseInt(st.nextToken());

			if(h[i] !=0) {
				LI=i;

			}
		}


		label:for(int yy=0;yy<=100;yy++) {
			for(int xx=0;xx<=100;xx++) {

				if(check(xx,yy)) {
					break label;
				}

			}
		}

		System.out.printf("%d %d %d%n",ax,ay,ah);

	}

	private static boolean check(int xz, int yz) {
		int hy = Math.abs(yz - y[LI]);
		int hx = Math.abs(xz - x[LI]);
		long hz2 = h[LI] + hy + hx;


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

			int hyn = Math.abs(yz - y[i]);
			int hxn = Math.abs(xz - x[i]);
			if(hz2 !=h[i] + hyn + hxn) {
				if(h[i] ==0) {
					if(hz2 >hyn + hxn) {
						return false;
					}
				}else {
					return false;
				}

			}
		}


		ax = xz;
		ay = yz;
		ah = hz2;

		return true;

	}

}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<long long> vll;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int a=0,b=0;
    int num;
    cin>>num;
    if(num==5)
    {
        a++;
    }

    if(num==7)
        {
            b++;
        }
    cin>>num;
    if(num==5)
       {
           a++;
       }
    if(num==7)
       {
           b++;
       }
    cin>>num;
    if(num==5)
    {
        a++;
    }
    if(num==7)
        {
            b++;
        }

    if(a==2&&b==1)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
        return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	//browse nanikaka code
	Scanner sc = new Scanner(System.in);
	private void doit() {
		while (true) {
			int n = sc.nextInt();
			if(n == 0) break;
			int sign = n < 0 ? 1 : 0;
			n = Math.abs(n);
			StringBuilder ans = new StringBuilder();
			for(int i = 0;; i++){
				if(n == 0) break;
				int num = n % 10;
				if((sign + i) % 2 == 0){
					ans.append(num);
				}
				else{
					int num2 = 10 - num;
					ans.append(num2 % 10);
					if(num2 != 10){
						n += 10;
					}
				}
				n = n / 10;
				
			}
			System.out.println(ans.reverse().toString());
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 24732
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
int main(void)
{
    sync;
    double r;
   	cin>>r;
    cout<<2.0*acos(-1)*r<<endl;
    return 0;
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

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

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint n; cin >> n;
  string s;
  map<string,lint> mp;
  for(lint i=0;i<n;i++) {
    cin >> s;
    mp[s]++;
  }

  printf("AC x %lld\n",mp["AC"]);
  printf("WA x %lld\n",mp["WA"]);
  printf("TLE x %lld\n",mp["TLE"]);
  printf("RE x %lld\n",mp["RE"]);

  return 0;
}


Measured memory_bytes: 3736
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int k,s;
    cin>>k>>s;
    int cnt=0;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            int z=s-x-y;
            if(0<=z&&z<=k)cnt++;
        }
    }  
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a,b,c,sum;
		while(true){
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();
			if(a==-1&&b==-1&&c==-1)break;
			else if(a==-1||b==-1)System.out.println("F");
			else{
				sum = a+b;
				if(sum>=80)System.out.println("A");
				else if(sum>=65)System.out.println("B");
				else if(sum>=50)System.out.println("C");
				else if(sum>=30){
					if(c>=50)System.out.println("C");
					else System.out.println("D");
				}else{
					System.out.println("F");
				}
			}
		}
	}
}



Measured memory_bytes: 26248
k,n=map(int, input().split())
al=list(map(int,input().split()))
last=al[-1]
al.append(al[0])
delta=[0]*n
if al[0]==0:
    for i in range(n):
        delta[i]=al[i+1]-al[i]
    delta[-1]=k-last
    print(k-max(delta))
else:
    for i in range(n):
        delta[i]=al[i+1]-al[i]
    delta[-1]=al[0]+(k-last)
    print(k-max(delta))

Measured memory_bytes: 78668
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <set>

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

struct Point {
  int x;
  int y;
  char type;
  Point() {;}
  Point(double x, double y, int type) : x(x), y(y), type(type) {;}
  bool operator<(const Point &rhs) const {
    if (y != rhs.y) { return y < rhs.y; }
    return x < rhs.x;
  }
};

struct Event {
  int x;
  Point p;
  char in;
  Event() {;}
  Event(int x, Point p, int in) : x(x), p(p), in(in) {;}
  bool operator<(const Event &rhs) const {
    if (x != rhs.x) { return x < rhs.x; }
    return in > rhs.in;
  }
};

inline int square(int x) { return x * x; }

inline int dist2(const Point &a, const Point &b) {
  return square(a.x - b.x) + square(a.y - b.y);
}

int an, bn, n;
int r;
Event event[500000];

int PlaneSweep() {
  int ans = 0;
  set<Point> open[2];
  REP(iter, n) {
    Event &e = event[iter];
    Point &p = e.p;
    if (e.in) {
      set<Point>::iterator lower = open[p.type ^ 1].lower_bound(Point(0, p.y - 4.0 * r - 1, 0));
      set<Point>::iterator upper = open[p.type ^ 1].upper_bound(Point(0, p.y + 4.0 * r + 1, 0));
      for (set<Point>::iterator it = lower; it != upper; it++) {
        if (dist2(*it, p) <= 16.0 * r * r) { ans++; }
      }
      open[p.type].insert(p);
    } else {
      open[p.type].erase(open[p.type].find(p));
    }
  }
  return ans;
}

int main() {
  while (scanf("%d %d %d", &an, &bn, &r), an|bn) {
    n = (an + bn) * 2;
    REP(i, an) {
      int x, y;
      scanf("%d %d", &x, &y);
      event[2 * i + 0] = Event(x - 2 * r, Point(x, y, 0), 1);
      event[2 * i + 1] = Event(x + 2 * r, Point(x, y, 0), 0);
    }
    REP(i, bn) {
      int x, y;
      scanf("%d %d", &x, &y);
      event[2 * an + 2 * i + 0] = Event(x - 2 * r, Point(x, y, 1), 1);
      event[2 * an + 2 * i + 1] = Event(x + 2 * r, Point(x, y, 1), 0);
    }
    sort(event, event + n);
    int ans = PlaneSweep();
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 8756
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	run()
}

func run() {
	setSpace()
	n := readN()

	as := make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = readN()
	}
	min := as[0]
	cnt := 1

	for _, a := range as {
		if min > a {
			cnt++
			min = a
		}
	}
	fmt.Println(cnt)
}

// ------以下、ユーティリティ------

var sc = bufio.NewScanner(os.Stdin)

func setSpace() {
	sc.Split(bufio.ScanWords)
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readN() int {
	n, err := strconv.Atoi(read())
	if err != nil {
		panic(err)
	}
	return n
}


Measured memory_bytes: 3584
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

using namespace std;

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

int gcd(int x, int y){
    int r = x % y;
    while(r != 0){
        x = y;
        y = r;
        r = x % y;
    }
    return y;
}

int main(){
    int N, X;
    cin >> N >> X;
    int ans;
    if(N==1){
        int x;
        cin >> x;
        ans = abs(X-x);
    }else{
        vector<int> x(N);
        cin >> x[N-1];
        ans = abs(X-x[N-1]);
        rep(i, N-1){
            cin >> x[i];
            ans = gcd(ans, abs(X-x[i]));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	LL n,m;
	int i,j,k;
	LL a,b,c;
	LL s=1;
	cin>>n;
	m=sqrt(n);
	for(i=2;i<=m;i++){
		a=n;
		while(a>1 && a%i==0)a/=i;
		if(a%i==1)s++;
	}
	n--;
	for(i=1;i<=m;i++){
		if(n%i)continue;
		if(n/i>m)s++;
	}
	cout<<s<<endl;
}

Measured memory_bytes: 256
pick :: Int -> String -> String
pick _ [] = []
pick 0 l = []
pick n l = (head l) : (pick n (drop n l))

loop :: Int -> Int -> String -> String -> [Int] -> Bool
loop n m s t [] = True
loop n m s t (x:cd) = if (pick (n`div`x) s) == (pick (m`div`x) t)
                then loop n m s t cd
                else False

check :: Int -> Int -> String -> String -> Int
check n m s t = let g = gcd n m
                    cd = [ x | x <- [1..(min n m)], (g `mod` x) == 0]
                  in if loop n m s t cd
                         then lcm n m else -1

main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine
  s <- getLine
  t <- getLine
  putStrLn $ show $ check n m s t

Measured memory_bytes: 9596
def popcount_parity(x):
    for i in range(8):
        x ^= x >> (1 << i)
    return -1 if x & 1 else 1

N, K, S, T = map(int, input().split())
if S & T != S:
    print(0)
    exit()

C = [[1]]
CC = [0] * 51
for i in range(1, 51):
    C.append([1] * (i + 1))
    for j in range(1, i):
        C[i][j] = C[i-1][j-1] + C[i-1][j]
for i in range(51):
    CC[i] = sum(C[i][1:K+1])

A = [int(a) for a in input().split()]
aa, oo = - 1, 0
for i in range(N)[::-1]:
    a = A[i]
    if a & S != S or a | T != T:
        del A[i]
        continue
    aa &= a
    oo |= a
aa ^= oo

i = aa
ans = 0
while 1:
    D = {}
    for a in A:
        t = i & a
        if t not in D: D[t] = 1
        else: D[t] += 1
    ans += sum([CC[t] for t in D.values()]) * popcount_parity(i)
    if not i: break
    i = (i - 1) & aa
print(ans)

Measured memory_bytes: 68880
macro_rules! input {
     (source = $s:expr, $($r:tt)*) => {
         let mut iter = $s.split_whitespace();
         input_inner!{iter, $($r)*}
     };
     ($($r:tt)*) => {
         let s = {
             use std::io::Read;
         let mut s = String::new();
         std::io::stdin().read_to_string(&mut s).unwrap();
         s
     };
     let mut iter = s.split_whitespace();
     input_inner!{iter, $($r)*}
     };
}
     
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};

//#[proconio::fastout]
fn main() {
    input!{
        n: usize,
        m: usize,
        roads: [usize; 2 * m],
    }
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let mut cities: Vec<i32> = vec![0; n];
    for r in roads { cities[r - 1] += 1; }
    for city in cities { writeln!(out, "{}", city).unwrap(); }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans = 0;
  ll a=min(N%(A+B),A);
  ans = N /(A+B) * A + a;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dl double long
#define rep(i, m, n) for(ll i = (ll)(m); i < (ll)(n); ++i)
#define rrep(i, m, n) for(ll i = (ll)(m); i > (ll)(n); --i)
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;

int main(void){
    int k, kk, a, b;
    cin >> k >> a >> b;
    kk = k;
    while(kk < a){
        kk += k;
    }
    cout << (kk <= b? "OK":"NG") << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(void) {

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

    int N, L;
    cin >> N >> L;

    string str;
    vector<string> strs;
    for (int i = 0; i < N; ++i) {
        cin >> str;
        strs.push_back(str);
    }

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

    for (int i = 0; i < N; ++i) {
        cout << strs[i];
    }
    cout << endl;


    return 0;
}


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

int main(){
  int r, c;
  cin >> c >> r;
  vector<vector<int> >v(c+1, vector<int>(r+1));

  for(int i=0;i<c;i++){
    for(int j=0;j<r;j++){
      cin >> v[i][j];
    }
    int sum = 0;
    for(int j=0;j<r;j++){
      sum += v[i][j];
    }
    v[i][r] = sum;
  }

  for(int i=0;i<r+1;i++){
    int sum = 0;
    for(int j=0;j<c;j++){
      sum += v[j][i];
    }
    v[c][i] = sum;
  }

  for(int i=0;i<c+1;i++){
    for(int j=0;j<r+1;j++){
      cout << v[i][j];
      if(j!=r)cout << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    int a[50];
    cin >> n;
    int absmax = 0;
    int absmaxi = 0;
    imfor(i, n) {
        cin >> a[i];
        if (abs(a[i]) > abs(absmax)) {
            absmax = a[i];
            absmaxi = i;
        }
    }
    cout << 2 * n - 1 << endl;
    imfor (i, n) {
        cout << absmaxi + 1 << " " << i + 1 << endl;
    }
    if (absmax > 0) {
        imfor (i, n - 1) {
            cout << i + 1 << " " << i + 2 << endl;
        }
    }
    else {
        for (int i = n; i > 1; i--) {
            cout << i << " " << i - 1 << endl;
        }
    }
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#define REP(i,x,n) for(int i=x;i<=n;i++)
#define DEP(i,n,x) for(int i=n;i>=x;i--)
#define mem(a,x) memset(a,x,sizeof(a))
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;
}
const int N=1000;
int t[N],v[N];
int l[N],r[N];
int main()
{
    int n=read();
    int time=0;
    REP(i,1,n) t[i]=read();
    REP(i,1,n) v[i]=read();
    int pre=0,now=0;
    REP(i,1,n){
        now+=t[i];
        l[i]=pre;r[i]=now;
        pre=now;
    }
    l[0]=0;r[0]=0;v[0]=0;
    l[n+1]=now;r[n+1]=now;v[n+1]=0;
    double ans=0;
    for(double j=0;j<(double)now;j+=0.5){
        double mix=1000;
        for(int i=0;i<=n+1;i++){
            if(l[i]<=j&&r[i]>=j) mix=min(mix,v[i]*1.0);
            else if(j<l[i]) mix=min(mix,v[i]+l[i]-j);
            else mix=min(mix,v[i]+j-r[i]);
        }
        ans+=mix*0.5;
    }
    printf("%.3f\n",ans);
    return 0;
}

Measured memory_bytes: 256
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define sum(v) accumulate(all(v), 0)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define MOD 1000000007
#define PI acos(-1)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>

using namespace std;

// clang-format on

main {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> t(n);
  rep(i, n) cin >> t[i].fi >> t[i].se;
  sort(all(t));
  int c;
  for (int i = 0; k; i++) {
    c = t[i].fi;
    k = max<int>(0, k - t[i].se);
  }
  cout << c << endl;
  bye;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int x;
  cin >> x;
  int ans;
  if(x>=400 && x<=599) {
   ans = 8; 
  }
  if(x>=600 && x<=799) {
   ans = 7; 
  }
  if(x>=800 && x<=999) {
   ans = 6; 
  }
  if(x>=1000 && x<=1199) {
   ans = 5; 
  }
  if(x>=1200 && x<=1399) {
   ans = 4; 
  }
  if(x>=1400 && x<=1599) {
   ans = 3; 
  }
  if(x>=1600 && x<=1799) {
   ans = 2; 
  }
  if(x>=1800 && x<=1999) {
   ans = 1; 
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int K, N;
    cin >> K >> N;
    vector<int> house_pos(N);
    for (int i = 0; i < N; ++i){
        cin >> house_pos[i];
    }

    int max_diff = 0;
    for (int i = 0; i < N - 1; ++i){
        max_diff = max(max_diff, abs(house_pos[i] - house_pos[i + 1]));
    }
    max_diff = max(max_diff, abs(house_pos[0] + (K - house_pos[N - 1])));
    cout << K - max_diff << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    string s;
    cin >> s;

    int num = 0;
    REP(i, n)
    {
        if(s[i] == 'R') num++;
        else num--;
    }
    cout << (num > 0 ? "Yes" : "No") << endl;
    
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c,x,y,mm[3];
   cin>>a>>b>>c>>x>>y;
    mm[0]=x*a+y*b;
    if(x>y)
    {
       mm[1]=c*2*x;
       mm[2]=c*2*y+(x-y)*a;
    }
    else
    {
       mm[1]=c*2*y;
       mm[2]=c*2*x+(y-x)*b;
    }
    sort(mm,mm+3);
    printf("%d",mm[0]);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
#define int long long
const int MN=100000;
int inf=1e9;
struct unionfind{
	int par[MN];
	void init(int N){rep(i,N) par[i]=i;}
	int find(int x){
		if(par[x]==x) return x;
		return par[x]=find(par[x]);
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x==y) return;
		par[y]=x;
	}
}UF;

typedef pair<int,int> P;	//val,id
typedef vector<P> VP;
map<int,VP> mp;
int N,a,b,x[MN],y[MN];
int cnt[MN];

signed main(){
	cin>>N>>a>>b;
	UF.init(N);
	a--,b--;
	rep(i,N) cin>>x[i]>>y[i];
	int D=abs(x[a]-x[b])+abs(y[a]-y[b]);
	rep(i,N){
		mp[x[i]+y[i]].pb(P(x[i]-y[i],i));
	}
	for(auto& it:mp){
		VP& vp=it.sc;
		sort(all(vp));
	}
	for(auto& it:mp){
		VP& vp=it.sc;
		int oh=it.fs;
		rep(i,2){
			int h=(i==0?oh-D:oh+D);
			if(mp.find(h)==mp.end()) continue;
			VP& vs=mp[h];
			int K=vs.size();
			vector<int> done(K+1,0);
			for(P p:vp){
				int x=p.fs;
				int id=p.sc;
				int lid=lower_bound(all(vs),P(x-D,-1))-vs.begin();
				int rid=lower_bound(all(vs),P(x+D,inf))-vs.begin()-1;
				if(lid<=rid){
					UF.unite(id,vs[lid].sc);
					cnt[id]+=rid-lid+1;
					done[lid]++;
					done[rid]--;
				}
			}
			rep(i,K) done[i+1]+=done[i];
			rep(i,K-1) if(done[i]>0) UF.unite(vs[i].sc,vs[i+1].sc);
		}
	}

	mp.clear();

	rep(i,N){
		mp[x[i]-y[i]].pb(P(x[i]+y[i],i));
	}
	for(auto& it:mp){
		VP& vp=it.sc;
		sort(all(vp));
	}
	for(auto& it:mp){
		VP& vp=it.sc;
		int oh=it.fs;
		rep(i,2){
			int h=(i==0?oh-D:oh+D);
			if(mp.find(h)==mp.end()) continue;
			VP& vs=mp[h];
			int K=vs.size();
			vector<int> done(K+1,0);
			for(P p:vp){
				int x=p.fs;
				int id=p.sc;
				int lid=lower_bound(all(vs),P(x-D,-1))-vs.begin();
				int rid=lower_bound(all(vs),P(x+D,inf))-vs.begin()-1;
				if(lid<=rid){
					UF.unite(id,vs[lid].sc);
					done[lid]++;
					done[rid]--;
				}
				lid=lower_bound(all(vs),P(x-D+1,-1))-vs.begin();
				rid=lower_bound(all(vs),P(x+D-1,inf))-vs.begin()-1;
				if(lid<=rid){
					cnt[id]+=rid-lid+1;
				}
			}
			rep(i,K) done[i+1]+=done[i];
			rep(i,K-1) if(done[i]>0) UF.unite(vs[i].sc,vs[i+1].sc);
		}
	}
	int ans=0;
	rep(i,N){
		if(UF.same(i,a)){
			ans+=cnt[i];
		}
	}
	cout<<ans/2<<endl;
}


Measured memory_bytes: 14300
#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>;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int mx = max(a, max(b, c));
    mx *= 3;
    int sum = a + b + c;
    if ((mx - sum) % 2 == 0)
    {
        cout << (mx - sum) / 2 << endl;
    }
    else
    {
        mx += 3;
        cout << (mx - sum) / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <list>
#include <stack>
#include <set>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
using namespace std;
int main() {
	long long int  n, m, r, R[10], a, b, c, dis[210][210], inf = 1e9;
	for (int i = 0; i < 210; i++) {//距離の初期化
		for (int j = 0; j < 210; j++) {
			dis[i][j] = inf;
		}
		dis[i][i] = 0;
	}
	cin >> n >> m >> r;
	for (int i = 0; i < r; i++)cin >> R[i];
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		if (c > dis[a][b])continue;
		dis[a][b] = dis[b][a] = c;
		for (int j = 1; j <= n; j++) {//ワーシャルフロイド
			for (int k = j+1; k <= n; k++) {
				dis[j][k] = min(dis[j][k], min(dis[j][a] + dis[b][k], dis[j][b] + dis[a][k]) + c);
				dis[k][j] = dis[j][k];
			}
		}
	}
	sort(R, R + r);
	ll yan, ans = 1e9;
	do {//ねくすとっ☆ぱーみゅてーしょん！！
		yan = 0;
		for (int i = 0; i < r - 1; i++)yan += dis[R[i]][R[i + 1]];
		ans = min(yan, ans);
	} while (next_permutation(R, R + r));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
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 ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(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;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// ここから開始
int main(){
  ll n;
  // n = 1e5;
  cin>>n;
  ll cnt[n];
  ll ans = 1;

  for(ll i = 0; i < n; i++) cnt[i]=0;
  for(ll i = 0; i < n; i++){
    ll x;
    cin>>x;
    if(x!=0&&i==0) ans=0;
    cnt[x]++;
  }
  // cout<<cnt[99999]<<endl;
  // cnt[0]=1;
  // cnt[1]=1e5-1;
  // cnt[2]=1;
  // cnt[3]=1000;
  // cnt[4]=1;
  // cnt[5]=1e5-1;
  ll mod = 998244353;

  bool flg = true;
  if(cnt[0]!=1) {
    ans=0;
    cout<<0<<endl;
    return 0;
  }
  
  for(ll i = 1; i < n; i++){
    if(cnt[i]==0){
      flg = false;
    }
    else{
      if(!flg){
        ans*=0;
        cout<<0<<endl;
        return 0;
      }
      else{
        // for(ll j = 0; j < cnt[i]; j++){
        //   ans*=cnt[i-1];
        //   ans%=mod;
        // }
        ans = modpow(ans,cnt[i-1],cnt[i],mod);
        // cout<<ans<<endl;
      }
    }
    ans%=mod;
    // cout<<ans<<endl;
  }
  cout<<ans%mod<<endl;
  return 0;
}



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

int main(void) {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  string K = "keyence";
  if (S == K) {
    cout << "YES" << endl;
    return 0;
  }

  int sn = S.size();
  for (int i = 0; i < sn; ++i) {
    for (int j = i; j < sn; ++j) {
      // delete i~j
      string check = S.substr(0, i) + S.substr(j + 1, sn - (j + 1));
      if (check == K) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}


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

int main()
{
    string s;
    cin >> s;
    s = "a" + s + "a";

    int l = 0;
    int r = s.size() - 1;
    int cnt_l = 0, cnt_r = 0;
    int cnt = 0;
    while (l <= r)
    {
        if (s[l] != s[r])
        {
            cout << -1 << endl;
            return 0;
        }
        cnt += abs(cnt_l - cnt_r);

        if (l == r) break;

        cnt_l = cnt_r = 0;
        ++l, --r;
        while(s[l] == 'x')
            ++l, ++cnt_l;
        while(s[r] == 'x')
            --r, ++cnt_r;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <iomanip>
#include <string>
#include <sstream>
#include  <list>
//#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
/*
int cmp(shi a,shi b)
{
    return a.x<b.x;
}
long long cmd(long long a, long long  b)
{
    return a > b;
}*/

int cmd(int a, int b)
{
    return abs(a)<abs(b);
}
int main()
{
    int t,n;
    string s[100];
    cin >>t>>n;


    for(int i=0; i<t; i++)
        cin >>s[i];
    for(int i=0; i<n+2; i++)
        cout<<"#";
    cout<<endl;
    for(int i=0; i<t; i++)
    {
        cout<<"#"<<s[i]<<"#"<<endl;

    }
    for(int i=0; i<n+2; i++)
        cout<<"#";
    cout<<endl;
    return 0;

}


Measured memory_bytes: 256