akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
#define F first
#define S second
#define INF -(1<<29)
using namespace std;
typedef pair<int,int> P;
const int MAX_N = 1000010;
int n;
P dat[3*MAX_N-1];

bool cmp(const P& a,const P& b)
{
  if(a.F == b.F)
    return a.S > b.S;
  return a.F < b.F;
}

void init(int n_)
{
  n = 1;
  while(n < n_)n *= 2;
  for(int i=0;i<2*n-1;i++)dat[i] = P(INF,INF);
}

void update(int k,P a)
{
  k += n-1;
  dat[k] = a;
  while(k > 0)
    {
      k = (k-1)/2;
      dat[k] = max(dat[k*2+1],dat[k*2+2],cmp);
    }
}

P query(int a,int b,int k,int l,int r)
{
  if(r <= a || b <= l)return P(INF,INF);

  if(a <= l && r <= b)return dat[k];
  else
    {
      P vl = query(a,b,k*2+1,l,(l+r)/2); 
      P vr = query(a,b,k*2+2,(l+r)/2,r);
      return max(vl,vr,cmp);
    }
}

P _query(int a,int b)
{
  return query(a,b,0,0,n);
}

int main()
{
 
  /*
  P ta,tb;
  ta = P(-6,1);
  tb = P(-6,7);
  P pes = max(ta,tb,cmp);
  cout << pes.F << " " << pes.S << endl;
  */
  int N,q;
  cin >> N >> q;
  P val[N+1];
  init(N);
  vector<P> vec;
  for(int i=0;i<=N;i++)
    val[i] = P(INF,INF);

  for(int i=0;i<q;i++)
    {
      int a,v;
      cin >> a >> v;     
      if(val[a] == P(INF,INF))
	{
	  vec.push_back(P(v,a));
	  int index = vec.size()-1;
	  val[a] = P(v,index);
	  update(index,P(v,a));
	}
      else
	{
	  val[a].F += v;
	  update(val[a].S,P(val[a].F,a));
	}
      P ans = _query(0,vec.size());
      cout << ans.S << " " << ans.F << endl;
    }

  return 0;
}

Measured memory_bytes: 33352
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String num = scan.next();
		long sum = 0;
		for(char c : num.toCharArray()) sum+=(c-'0');
		System.out.println(sum%9 == 0 ? "Yes" : "No");
		scan.close();
	}
}

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

#define pb push_back
#define mp make_pair
#define INF 1e16+1
#define se second
#define fi first

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vi> vvi;
typedef vector <vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pll> vpll;
typedef vector< vector<pll> > vvpll;

ll i,j,n,m,x,a,b,w;
vpll v;
vll dp;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>w;
	for(i=0;i<n;i++){
		cin>>a>>b;
		v.pb(mp(a,b));
		x+=b;
	}
	dp.assign(x+1,INF);
	dp[0]=0;
	for(i=0;i<n;i++){
		for(j=x;j>=0;j--){
			if(j-v[i].se>=0) dp[j]=min(dp[j],dp[j-v[i].se]+v[i].fi);
		}
	}
	/*
	for(j=0;j<=x;j++){
		cout<<dp[j]<<' ';
	}cout<<'\n';
	*/
	a=0;
	for(j=x;j>=0;j--){
		if(dp[j]<=w){
			a=j;
			break;
		}
	}
	cout<<a<<'\n';
}


Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc118/tasks/abc118_d

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")
#define ITR(c,it)  for(auto it = c.begin(); it != c.end(); it++)

//------------------------------------------------------------------------------
struct match { int w, v, c; };

bool compare_vd(const match& m1, const match& m2) {
  return m1.v > m2.v;
}

//------------------------------------------------------------------------------
const int N_MAX = 1e4;
const int M_MAX = 9;
const int A_I_MAX = 9;
const int WGT[] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
const int INF = 1e9;

int N, M;
int A[M_MAX];

map<int, int> mp;
vector<match> x;

int K;
int dp[N_MAX + 1];

void solve() {
  sort(A, A + M);
  REP(i, M) mp[WGT[A[i]]] = A[i];
  ITR(mp, it) x.push_back({ it-> first, it-> second, 0 });
  sort(x.begin(), x.end(), compare_vd);
  K = x.size();

  fill(dp, dp + N + 1, -INF);
  dp[0] = 0;
  FOR(i, 1, N) {
    REP(j, K) {
      int w = x[j].w;
      if (i >= w) dp[i] = max(dp[i], dp[i - w] + 1);
    }
  }

  // DUMP(dp, N + 1);

  int i = N;
  while (i > 0) {
    REP(j, K) {
      int w = x[j].w;
      if (i >= w && dp[i - w] == dp[i] - 1) {
        printf("%d", x[j].v);
        i = i - w;
        break;
      }
    }
  }
  puts("");

}

void input() {
  scanf("%d%d", &N, &M);
  REP(i, M) scanf("%d", A + i);
}

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


Measured memory_bytes: 256
#include <stdio.h>

int a[100][100], b[100][100];

int main()
{
    int i, j, k, l ,m, n;
    scanf("%d%d%d", &l, &m, &n);
    for(i=0; i<l; i++) {
        for(j=0; j<m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    for(i=0; i<m; i++) {
        for(j=0; j<n; j++) {
            scanf("%d", &b[i][j]);
        }
    }
    long long ans;
    for(i=0; i<l; i++) {
        for(j=0; j<n; j++) {
            ans=0;
            for(k=0; k<m; k++) {
               ans+=a[i][k]*b[k][j];
            }
            if(j)putchar(' ');
            printf("%lld", ans);
        }
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 676
n, y = map(int, input().split())
c = int(y/1000)
flag = False
for i in range(c//9+1):
    for j in range((c-n-9*i)//4+1):
        if n-i-j < 0:
            break
        if c - 9*i - 4*j == n:
            flag = True
            break      
    if flag:
        break
if flag:
    print(i, j, n-i-j)
else:
    print(-1, -1, -1)

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

int main() {
    int L,R,d;
    cin >> L >> R >> d;
    
    int ans,ans2;
    ans = R / d;
    ans2 = (L-1)/d;
    
    cout << ans - ans2 << endl;
    
    return 0;
}


Measured memory_bytes: 3620
/*
*   1. What was the key concept?
*   2. What mistake did I make? (if any)
*   3. Thing to remember from now on.
*/

#include <iostream>
using namespace std;

#define INF 0x3f3f3f3f;
#define INFL 0x3f3f3f3f3f3f3f3f;
#define NITRO ios_base::sync_with_stdio(false); cin.tie(false)
#define PRECISE cout << fixed << setprecision(9)

using ll = long long int;
using ld = long double;

const int MOD = 1e9 + 7;
const int N = 1e6 + 5;

int main(){

    ll n, cur, last = 0, ans = 0;
    cin >> n;

    for (int i=0; i<n; i++){
        cin >> cur;

        if (cur < last){
            ans += (last - cur);
        } else {
            last = cur;
        }
    }

    cout << ans << endl;

    return 0;
}

// Check the corner cases. (n = 1).
// Check overflows. (int vs ll).
// Be consistent.

Measured memory_bytes: 3588
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>

const int MAXN = 3e5 + 10, MOD = 1e9 + 7;

int len;
int ch[8][2], dp[MAXN][8];
char s[MAXN];

inline void buildAutoMaton() {
	ch[0][0] = 5, ch[0][1] = 1;
	ch[1][0] = 3, ch[1][1] = 2;
	ch[2][0] = 2, ch[2][1] = 2;
	ch[3][0] = 4, ch[3][1] = 1;
	ch[4][0] = 3, ch[4][1] = 3;
	ch[5][0] = 7, ch[5][1] = 6;
	ch[6][0] = 5, ch[6][1] = 1;
	ch[7][0] = 5, ch[7][1] = 5;
	return;
}

int main() {
	scanf(" %s", s + 1), len = strlen(s + 1);
	buildAutoMaton(), dp[len][1] = dp[len][2] = 1;
	for (int i = len - 1; ~i; --i) {
		char c = s[i + 1];
		for (int j = 0; j < 8; ++j) {
			if (c != '1') dp[i][j] = (dp[i][j] + dp[i + 1][ch[j][0]]) % MOD;
			if (c != '0') dp[i][j] = (dp[i][j] + dp[i + 1][ch[j][1]]) % MOD;
		}
	}
	printf("%d\n", dp[0][0]);
	return 0;
}

Measured memory_bytes: 9856
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	void doIt() {
		int[] c = new int[10];
		Arrays.fill(c, 0);
		for(int i = 0; i < 4; i++) {
			c[sc.nextInt()]++;
		}
		if(c[1] == 1 && c[9] == 1 && c[7] == 1 && c[4] == 1) {
			System.out.println("YES");
		}
		else System.out.println("NO");
	}
	

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


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

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

int main(){
    int n; cin >> n;
    int h[n]; rep(i,n) cin >> h[i];

    int dp[n];
    rep(i,n) dp[i]=INF;

    dp[0]=0;

    rep(i,n){
        chmin(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
        chmin(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
    }

    COUT(dp[n-1]);

}

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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll mod = 1000000007;





int main()
{
    ll n,d;
    cin >> n >> d;
    vector<ll> w(n), v(n);
    for(ll i = 0; i < n; i++)cin >> w[i] >> v[i];
    ll base = w[0];
    vector<ll> cnt(4);
    vector<vector<ll>> val(4);
    for(ll i = 0; i < n; i++){
        cnt[w[i] - w[0]]++; 
        val[w[i] - w[0]].push_back(v[i]);
    }
    for(ll i = 0; i < 4; i++)sort(val[i].begin(), val[i].end(), greater<ll>());



    //m個取る
    ll ans = 0;
    for(ll i = 0; i <= cnt[0]; i++){
        for(ll j = 0; j <= cnt[1]; j++){
            for(ll t = 0; t <= cnt[2]; t++){
                for(ll l = 0; l <= cnt[3]; l++){
                    ll m = i + j + t + l;
                    ll lim = d - base * m;
                    if(i * 0 + j * 1 + t * 2 + l * 3 > lim)continue;
                    ll sum = 0;

                    for(ll q = 0; q < i; q++)sum += val[0][q];
                    for(ll q = 0; q < j; q++)sum += val[1][q];
                    for(ll q = 0; q < t; q++)sum += val[2][q];
                    for(ll q = 0; q < l; q++)sum += val[3][q];
                    ans = max(ans, sum);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
S = input()
Q = int(input())
now = 1
head = ''
last = ''
for _ in range(Q):
    query = input().split()
    if query[0] == '1':
        now = now * -1
    if query[0] == '2':
        if now * (int(query[1])-1.5) == 0.5:
            last += query[2]
        else:
            head += query[2]

ans = head[::-1] + S + last
if now == 1:
    print(ans)
else:
    print(ans[::-1])

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

int main() {
    int n;
    int p[50];
    int count =0;
    cin >>n;
    for(int i=0;i<n;i++){
        cin >>p[i];
    }
    for(int i=0;i<n;i++){
        if(p[i]!=i+1){
           count++;
        }
    }

    if(count==0 || count==2 ){
        cout << "YES" <<endl;
    } else {
        cout << "NO" <<endl;
    }
    return 0;
}

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

int main(){

    int N,M;
    cin >>N>>M;
    vector<vector<int>> A(N,vector<int>(M,0));
    vector<int> K(M);
    for(int i=0;i<N;i++){
      int ind;
      cin >>ind;
      for(int j=0;j<ind;j++){
        int temp;
        cin >>temp;
        A.at(i).at(temp-1)=1;
      }
    }
    int ans=0;
    for(int i=0;i<M;i++){
      int count=0;
      for(int j=0;j<N;j++){
        count+=A.at(j).at(i);
      }
      if(count==N)ans++;
    }
    cout<<ans<<endl;

  }


Measured memory_bytes: 256
//B - Power Socket
//2019/09/09

#include <stdio.h>

int main(void) {
    int p_socket,unused,num=1,ans=0;
    scanf("%d %d",&p_socket,&unused);
    p_socket--;
    while (num<unused) {
        num+=p_socket;
        ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define vll vector<long long>
#define ll long long
#define pii pair<int,int>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("inputf.txt","r",stdin);
    freopen("outputf.txt","w",stdout);
#endif
    
    	int n,x,t;
    	cin>>n>>x>>t;
    	int ans=(n/x);
    	if(n%x) ans++;
    	ans=ans*t;
    	cout<<ans<<"\n";
    
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

class UnionFind {
    vector<int> par;
    int n;
public:
    UnionFind(int n) : par(n, -1) {}
    int find(int x) {
        if (par[x] < 0) return x;
        return par[x] = find(par[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
};

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

    ll n, m;
    cin >> n >> m;

    UnionFind uf(2*n);

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b+n);
        uf.unite(a+n, b);
    }
    
    if (uf.find(0) == uf.find(n)) {
        cout << (n*(n-1)/2)-m;
        return 0;
    }

    ll c = 1;
    for (int i = 1; i < n; i++) {
        if (uf.find(0) == uf.find(i)) c++;
    }
    cout << c*(n-c)-m;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long s = 0;
		for (int i = 0; i < n; i++) {
			s += i;
		}
		System.out.println(s);
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
using namespace std;
char tetromino_figure(vector<string> v){
	for(int i = 0; i < 8; i++){
		for(int j = 0; j < 8; j++){
			if(v[i][j] == '1'){
				if(v[i][j + 1] == '1' && v[i + 1][j] == '1' && v[i + 1][j + 1] == '1') return 'A';
				if(v[i + 1][j] == '1' && v[i + 2][j] == '1' && v[i + 3][j] == '1') return 'B';
				if(v[i][j + 1] == '1' && v[i][j + 2] == '1' && v[i][j + 3] == '1') return 'C';
				if(v[i + 1][j - 1] == '1' && v[i + 1][j] == '1' && v[i + 2][j - 1] == '1') return 'D';
				if(v[i][j + 1] == '1' && v[i + 1][j + 1] == '1' && v[i + 1][j + 2] == '1') return 'E';
				if(v[i + 1][j] == '1' && v[i + 1][j + 1] == '1' && v[i + 2][j + 1] == '1') return 'F';
				if(v[i][j + 1] == '1' && v[i + 1][j - 1] == '1' && v[i + 1][j] == '1') return 'G';
			}
		}
	}
	return '0';
}
int main(){
	string s;
	while(cin >> s){
		if(s == "\n") continue;
		vector<string> v;
		for(int i = 1; i <= 3; i++) s += '0';
		v.push_back(s);
		for(int i = 2; i <= 8; i++){
			cin >> s;
			for(int j = 1; j <= 3; j++) s += '0';
			v.push_back(s);
		}
		for(int i = 1; i <= 3; i++) v.push_back("00000000000");
		cout << tetromino_figure(v) << endl;
	}
	return 0;
}


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

using namespace std;

#define ll long long
#define endl '\n'
#define pb push_back
#define inf 1e9

ll potDeDois[45];

int main ()
{
    ll h, moves = 0, pot; cin >> h;

    potDeDois[0] = 1;

    for (int i = 1; i <= 43; i++)
        potDeDois[i] = potDeDois[i-1] * 2;

    int camada = -1;

    while(h > 0)
    {
        camada++;
        moves += potDeDois[camada];
        h /= 2;
        //cout << "Camda = " << camada << ", life = " << h << endl;
    }

    cout << moves << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

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

    ll N;
    cin >> N;
    vector<double> A(N);
    rep(i, N) cin >> A[i];
    vll B(N, 0);
    rep(i, N) B[i] = A[i] * 1000000000 + 0.5;
    vll d2(N, 0), d5(N, 0);
    rep(i, N){
        while(B[i]>0 && B[i]%2==0){
            B[i] /= 2;
            ++d2[i];
        }
        while(B[i]>0 && B[i]%5==0){
            B[i] /= 5;
            ++d5[i];
        }
    }
    ll total = 0;
    vvll t25(19, vll(19, 0));
    rep(i, N){
        total += t25[min(d2[i], 18ll)][min(d5[i], 18ll)];
        REP(j, max(0ll, 18-d2[i]), 19){
            REP(k, max(0ll, 18-d5[i]), 19){
                ++t25[j][k];
            }
        }
    }
    cout << total << endl;
}


Measured memory_bytes: 9592
#include <cmath>
#include <iostream>
#include <iomanip>
#include <set>
#include <string>


#ifdef MY_LOCAL
namespace sandbox {
#endif

using namespace std;
int main()
{
	const double PI = acos(-1.0);

	int a, b, h, m;
	cin >> a >> b >> h >> m;

	int mins = 60 * h + m;
	double deg = (6.0 - 0.5) * mins;
	double rad = 2.0 * PI / 360.0 * deg;
	double distance_sqr = pow((double)a, 2.0) + pow((double)b, 2.0) - 2.0 * (double)a * (double)b * cos(rad);
	double distance = sqrt(distance_sqr);

	cout << setprecision(10) << distance << endl;
	return 0;
}

#ifdef MY_LOCAL
}
#endif

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  string s; cin >> s;
  n *= 2;
  vector<bool> vl(n);

  vl[0] = true;
  for(int i=1;i<n;++i) {
    if(s[i] == s[i-1]) vl[i] = !vl[i-1];
    else vl[i] = vl[i-1];
  }

  if(s[0] == 'W' || s[n-1] == 'W') {
    cout << 0 << endl;
    return 0;
  }

  ll cnt = 1;
  ll cntl = 1, cntr = 0;
  for(int i=1;i<n;++i) {
    if(vl[i]) {
      cntl++;
    } else {
      cnt *= cntl - cntr;
      cnt %= MOD;
      cntr++;
    }
  }
  if(cntl != cntr) {
    cout << 0 << endl;
    return 0;
  }

  for(int i=1;i<=n/2;++i) {
    cnt *= i;
    cnt %= MOD;
  }
  cout << cnt << endl;

}


Measured memory_bytes: 720
icase=0
if icase==0:
    from itertools import permutations, combinations,combinations_with_replacement,product
    n=int(input())
    d=list(map(int,input().split()))
    dd=list(combinations(d,2))
    dsum=0
    for ddd in dd:
        dsum=dsum+ddd[0]*ddd[1]
    print(dsum)

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

int n,cnt;
char c;

int main(){

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

    cin>>n;
    while(n--){
        cin>>c;
        if(c=='R')cnt++;
        else cnt--;
    }
    if(cnt>0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

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

int main()
{
	int year[20] = {};
	int i, j;
	for (i = 0; i < 15; i++)
		year[i] = 0;
	
	int gram, rate, die;
	cin >> rate >> die >> gram;
	for (j = 0; j < 10; j++){
		year[j] += rate*gram - die;
		cout << year[j] << endl;
		gram = year[j];
	}
	return 0;
}

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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long  ll;
#define endl '\n'




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


const int MOD = 1000000007;

//////////////////////////////////////////



int n;

void Input() {

    cin >> n;

}



void Solve() {


    int d[n];
    for(int i = 0; i < n; i++) {

        cin >> d[i];
    }

    sort(d, d+n);

    int r = d[n/2];
    int l = d[n/2 - 1];
    //cout << r << " " << l << endl;

    cout << r - l << endl;

}

int main() {

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


  return 0;

}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
int main() {
  using namespace std;
  int H, W;
  cin >> H >> W;
  
  //アルファベット列を用意
  vector<string> frame(H);
  for(int i=0; i<H; i++){
    cin >> frame.at(i);
  }
  
  //出力準備
  //一番上の列
  for(int i=0; i<W+2; i++) {
    cout << '#';
  }
  cout << endl;
  
  //中の部分
  for(int i=0; i<H; i++){
      cout << '#' << frame.at(i) << '#' << endl;
  }
  
  //一番下の列
  for(int i=0; i<W+2; i++) {
    cout << '#';
  }
  
  return 0;
}

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

#include <ios>
#include <iomanip>

using namespace std;

int main(){

  int x, y;

  cin >> x >> y;

  if( (x*y)%2 == 0 ){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }


  return 0;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  string n; cin >> n;
  cout << (count(ALL(n), '7') > 0 ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 3652
import java.util.*;
public class Main {
    public static void main(String[] args ){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[] box = new boolean[n];
        int[] ball = new int[n];
        box[0]=true;
        for (int i=0;i<m;i++){
            int x = sc.nextInt()-1;
            int y = sc.nextInt()-1;
            box[y] = box[x] || box[y];
            ball[x]--;
            ball[y]++;
            if (ball[x]<0) box[x] = false;
        }
        int ans=0;
        for (int i=0;i<n;i++)if (box[i])ans++;
        System.out.println(ans);
    }
}

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

int main() {
  int N;
  cin >> N;
  string A;
  
  for (int i=0; i<N; i++){
    cin>>A;
    if (A=="Y"){
      cout<<"Four"<<endl;
      break;
    }
    else if (i==N-1)
      cout<<"Three"<<endl;
    else
      continue;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    for(int i = 1;i <= n; i++)
        if(n % i == 0)
          if(i <= 9 && n / i <= 9)
            {cout << "Yes";
            return 0;
            }

            cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  ll q,h,s,d,n;
  cin>>q>>h>>s>>d;
  cin>>n;
  cout<<n/2*(min(min(q*8,h*4),min(s*2,d)))+n%2*min(q*4,min(h*2,s))<<endl;
  return 0;
}


Measured memory_bytes: 256
x,y=map(int,input().split())
if x*y>0:
  print(x-y+2 if x>y else y-x)
elif x==0:
  print(abs(y)+(y<0))
elif y==0:
  print(abs(x)+(x>0))
else:
  print(abs(abs(x)-abs(y))+1)

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

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


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
#define mod 1000000007
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);

 ll a,b;
 cin>>a>>b;
 cout<<(a*b)/(__gcd(a,b))<<endl;;
return 0;
}



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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

string S[200000];

int main()
{
	int N, max_cnt = 0;
	map<string, int> mp;
	set<string> ans;
	
	cin >> N;
	rep(i, N) cin >> S[i];

	rep(i, N) {
		if (mp.count(S[i]) > 0) mp[S[i]]++;
		else mp[S[i]] = 1;
		max_cnt = max(max_cnt, mp[S[i]]);
	}

	rep(i, N) {
		if (mp[S[i]] == max_cnt) ans.insert(S[i]);
	}

	for (auto it = ans.begin(); it != ans.end(); it++) {
		cout << (*it) << endl;
	}

	return 0;
}


Measured memory_bytes: 36096
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first fi;
#define second se;
using namespace std;
typedef pair<int, int> P;

int dx[13] = {1, 0, 0,    1, 1, 0,  1,  1,  0,   1,  1,  1,  1};
int dy[13] = {0, 1, 0,    1, 0, 1, -1,  0,  1,   1,  1, -1, -1};
int dz[13] = {0, 0, 1,    0, 1, 1,  0, -1, -1,   1, -1,  1, -1};
int n, m, p;

bool contain(int x, int y, int z){
    return (0 <= z && z < n && 0 <= y && y < n && 0 <= x && x < n);
}

signed main(){
    while(1){
        cin >> n >> m >> p;
        if(n + m + p == 0) break;
        int d[7][7][7] = {};
        int h[7][7] = {};
        vector<int> x(p), y(p);
        rep(i, 0, p){
            cin >> x[i] >> y[i];
            x[i]--; y[i]--;
        }
        int f = 0;
        int ans = -1;
        int turn = 0;
        rep(i, 0, p){
            d[x[i]][y[i]][h[x[i]][y[i]]] = (i % 2 == 0 ? 1 : 2);
            h[x[i]][y[i]]++;
            rep(j, 0, n){
                rep(k, 0, n){
                    rep(l, 0, n){
                        int tmp = d[j][k][l];
                        if(tmp == 0) continue;
                        rep(t, 0, 13){
                            rep(s, 0, m){
                                int nx = j + dx[t] * s;
                                int ny = k + dy[t] * s;
                                int nz = l + dz[t] * s;
                                if(!contain(nx, ny, nz)) break;
                                if(d[nx][ny][nz] != tmp) break;
                                if(s == m - 1) f |= (1 << tmp);
                            }
                        }
                    }
                }
            }
            if(f){
                if(f == 6) ans = -1;
                if(f == 4) ans = 2;
                if(f == 2) ans = 1;
                turn = i + 1;
                break;
            }
        }
        if(ans == -1) cout << "Draw" << endl;
        else if(ans == 1) cout << "Black " << turn << endl;
        else if(ans == 2) cout << "White " << turn << endl;
    }
}

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

struct Num
{
    int p;
    int n;
    int exp;
}a[5];
long long n;

bool cmp(Num a,Num b)
{
    return a.exp<b.exp;
}

int main()
{
    for (int i=1;i<=4;i++)
        {
        scanf ("%d",&a[i].p);
        if (i==1) a[i].n=1;
        if (i==2) a[i].n=2;
        if (i==3) a[i].n=4;
        if (i==4) a[i].n=8;
        a[i].exp=a[i].p*(8/a[i].n);
        }
    sort(a+1,a+1+4,cmp);
    cin >> n;
    n=n*4;
    long long ans=0;
    int i=1;
    while (n!=0 && i<=4)
        {
        ans+=(long long)(n/a[i].n)*(long long)a[i].p;
        n%=a[i].n;
        i++;
        }
    cout << ans;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/agc029/submissions/3810739
#include<stdio.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
const int maxn = 2e5 + 5;
map<int,int>dp[maxn];
vector<int>ve[maxn];
int n;
int ans[maxn];
int dfs2(int x,int ba,int v) {
	if(dp[x].count(v)) return dp[x][v];
	int sm = 1;
	for(int y:ve[x]) {
		if(y==ba) continue;
		if(y<v) sm += dfs2(y,x,v);
	}
	return dp[x][v] = sm;
}
void dfs1(int x,int ba,int pr,int cc) {
	cc += dfs2(x,ba,max(ba,pr));
	if(pr>x) cc -= dfs2(x,ba,pr);
	ans[x] = cc;
	for(int y:ve[x]) {
		if(y==ba) continue;
		dfs1(y,x,max(pr,ba),cc);
	}
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<n;i++) {
		int x,y; scanf("%d%d",&x,&y);
		ve[x].push_back(y);
		ve[y].push_back(x);
	}
	for(int y:ve[1]) {
		dfs1(y,1,1,0);
	}
	for(int i=2;i<=n;i++) printf("%d ",ans[i]);
}


Measured memory_bytes: 53888
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 200010;  // デフォルトでnの最大値は300000
 
// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}
 
ll inv(ll a) {
    return modpow(a, mod-2);
}
 
ll fact[MAX_N];
ll invfact[MAX_N];
 
// main関数でinit()を呼び出してからComb()を使用する
void init() {
    fact[0] = 1;
    invfact[0] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        fact[i] = (i*fact[i-1])%mod;
        invfact[i] = inv(fact[i]);
    }
}
 
ll Comb(ll n, ll r) {
    if(r < 0 || n < 0 || n < r) {
        return 0;
    }
    ll res = fact[n];
    res = (res * invfact[r])%mod;
    res = (res * invfact[n-r])%mod;
    return res;
}
 
//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll n, k;
    cin >> n >> k;
 
    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));
 
    init();
 
    ll ans = 0;
    exrep(i, 0, n-k) {
        ll p = (3*mod + a[n-1-i] - a[i])%mod;
        ll q = Comb(n-1-i, k-1);
        ans += (p*q)%mod;
        ans %= mod;
    }
 
    out(ans);
    re0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N, 0);
    ll c, d;
    for (int i = 0; i < N-1; i++) {
        cin >> c >> d;
        c--;
        d--;
        A[c]++;
        A[d]++;
    }
    ll ans;
    if(N == 1){
        printf("%lld\n", K);
        return 0;
    }
    ans = K * (K-1) % MOD;
    for (int i = 0; i < N; i++) {
        for (int j = 2; j <= A[i]; j++) {
            ans = ans * (K-j) % MOD;
        }
    }
    printf("%lld\n", ans);

}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
struct comb {
    vector<mint> fact, ifact;
    comb(int n) :fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

int main() {
	init();

    int N, K; cin >> N >> K;
    comb com(N);
    mint cnt = 0;
    rep(i, 1, K + 1) {
        mint ans = com(N - K + 1, i) * com(K - 1, i - 1);
        cout << ans.x << "\n";
    }

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n, k, x, sum = 0;
	int i;
	cin >> n >> k;
	for(i = 0; i < n; ++i) {
		cin >> x;
		if(x <= k - x)sum += x * 2;
		else if(x > k - x)sum += (k - x) * 2;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 24.01.2020 23:41:44       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[i] / 2;
    a[i] %= 2;
    if (a[i] > 0 && i < n - 1 && a[i + 1] > 0) {
      a[i] -= 1;
      a[i + 1] -= 1;
      ans += 1;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
#define pro "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○○するために生まれてきた男"
#define MAX 1010
#define int long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)

vector<pair<int,int>> temp[MAX][MAX];
signed main(){
	while(true){
		int AN, BN, R, xa, ya, xb, yb, count = 0;
		vector<pair<int,int>> temp2;
		for(int i = 0; i < MAX; i++)for(int j = 0; j < MAX; j++)temp[i][j].clear();
		cin>>AN>>BN>>R;
		
		if(!AN&&!BN) break;
		
		for(int i = 0; i < AN; i++){
			cin>>xa>>ya;
			temp2.push_back(make_pair(xa,ya));
		}
		for(int i = 0; i < BN; i++){
			cin>>xb>>yb;
			temp[xb/10][yb/10].push_back(make_pair(xb,yb));
			//cout<<" --"<<xb/10<<" "<<yb/10<<endl;
		}
		for(pair<int,int> y : temp2){
			int bi = max(y.first/10-R*4/10-1,0), ei = min(y.first/10+R*4/10+1,MAX-10);
			int bj = max(y.second/10-R*4/10-1,0), ej = min(y.second/10+R*4/10+1,MAX-10);
			for(int i = bi; i <= ei; i++){
				for(int j = bj; j <= ej; j++){//cout<<i<<" "<<j<<endl;
					for(pair<int,int> x : temp[i][j]){//cout<<"+++ "<<x.first<<" "<<x.second<<endl;
					//cout<<(x.first-y.first)*(x.first-y.first)+(x.second-y.second)*(x.second-y.second) <<" <= "<<16*R*R<<endl;
						if((x.first-y.first)*(x.first-y.first)+(x.second-y.second)*(x.second-y.second) <= 16*R*R) count++;
					}
				}
			}
		}
		cout<<count<<endl;
	}
	
	return 0;
}


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

using namespace std;

int main()
{
    set < int > st;
    int a,b,c;  cin >> a >> b >> c;
    st.insert(a);
    st.insert(b);
    st.insert(c);
    cout << (st.size() == 2 ? "Yes" : "No");
    return 0;
}



Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
good=[True]*n
for i in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    if h[a]<h[b]:
        good[a]=False
    elif h[b]<h[a]:
        good[b]=False
    elif h[b]==h[a]:
        good[a]=False
        good[b]=False
print(good.count(True))


Measured memory_bytes: 20044
main=getLine>>=print.(\s->f (length s) s)
 where f n s = if(mod n 2)==0 then(g(n-2)(init(init s)))else(g(n-1)(init s))
       g n s = if((take(quot n 2)s)++(take(quot n 2)s))==s then n else (g(n-2)(init(init s)))

Measured memory_bytes: 892
#include <iostream>
#include <vector>
using namespace std;
using lint = long long int;
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }

int main()
{
    int N;
    cin >> N;
    vector<lint> A(N + 1);
    for (int i = 1; i <= N; i++) cin >> A[i];
    vector<vector<lint>> dp(3, vector<lint>(N + 2, -1e18));
    dp[0][0] = 0;
    for (int i = 0; i <= N; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if (i) chmax(dp[j][i + 1], dp[j][i - 1] + A[i]);
        }

        for (int j = 0; j < 2; j++)
        {
            chmax(dp[j + 1][i + 1], dp[j][i]);
        }
    }
    cout << dp[1 + N % 2].back() << "\n";
}


Measured memory_bytes: 11160
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(n) for(ll i=0; i<n; i++)
#define MAX_V 100001
const ll INF = 1e+9;
const ll MOD = 998244353;

struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];
vector<int> Prev(MAX_V);

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                Prev[e.to] = v;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    cin >> V;
    int E;
    cin >> E;
    for (int i=0; i<E; ++i) {
        int a, b, c;
        cin >> a >> b;
        edge e1 = {b-1, 1};
        edge e2 = {a-1, 1};
        G[a-1].push_back(e1);
        G[b-1].push_back(e2);
    }
    dijkstra(0);
    for (int i = 0; i < V; i++)
    {
      if(d[i] == INF)
      {
        cout << "No" << endl;
        return 0;
      }
    }
    
    cout << "Yes" << endl;
    for (int i=1; i<V; ++i) {
        cout << Prev[i]+1 << endl;
    }
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);

    for (auto &x : a) cin >> x;
    for (auto &x : b) cin >> x;
    for (auto &x : c) cin >> x;

    sort(a.begin(), a.end());
    sort(c.begin(), c.end());

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll up = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        ll down = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
        down = c.size() - down;

        ans += up * down;

        //cout << up << ' ' << down << "\n";
        //break;
    }

    cout << ans;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
//#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

ll ord2(ll n) {
  ll cnt = 0;
  while(n%2==0) {cnt++; n/=2;}
  return min(cnt, (ll)9);
}

ll ord5(ll n) {
  ll cnt = 0;
  while(n%5==0) {cnt++; n/=5;}
  return min(cnt, (ll)9);
}

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

  vl pow10(19);
  pow10[0]=1;
  rep(i, 18) pow10[i+1] = pow10[i] * 10;
  
  ll n;
  cin >> n;
  vs a(n);
  rep(i, n) cin >> a[i];
  
  vl p(n), q(n);
  rep(i, n) {
    if(count(all(a[i]), '.')) {
      p[i]=1000000000;
      ll point = a[i].find('.');
      rep2(j, 0, point-1) q[i] += (a[i][j]-'0')*pow10[8+point-j];
      rep2(j, point+1, a[i].size()-1) q[i] += (a[i][j]-'0')*pow10[9+point-j];
      ll g = gcd(p[i], q[i]);
      p[i] /= g;
      q[i] /= g;
    }
    else {
      p[i]=1;
      q[i]=stoll(a[i]);
    }
  }
  
  ll r[10][10][10][10];
  rep(a, 10) rep(b, 10) rep(c, 10) rep(d, 10) r[a][b][c][d]=0;
  
  rep(i, n) r[ord2(p[i])][ord5(p[i])][ord2(q[i])][ord5(q[i])]++;
  
  ll ans=0;
  rep(a, 10) rep(b, 10) rep(c, 10) rep(d, 10) {
    rep2(i, 0, c) rep2(j, 0, d) rep2(k, a, 9) rep2(l, b, 9) {
      if(a==i and b==j and c==k and d==l) ans += r[a][b][c][d]*(r[i][j][k][l]-1);
      else ans += r[a][b][c][d]*r[i][j][k][l];
    }
  }
  ans /= 2;
  cout << ans << newl;
}

Measured memory_bytes: 12696
import std.stdio;

void main() {
	int r,g,b,n;
	scanf("%d %d %d %d", &r, &g, &b, &n);
	size_t total;
	for (int i; i <= n; i += r) {
		for (int j = i; j <= n; j += g) {
			if ((n - j) % b == 0) ++total;
		}
	}
	total.write;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,k,m,b,r,p,q,boat[51],f[51]={0},ans=0,i,j;
  scanf("%d %d",&n,&k);
  for(i=0;i<k;i++){
    scanf("%d",&m);
    for(j=0;j<m;j++){
      scanf("%d",&b);
      boat[b]=i;
    }
  }
  scanf("%d",&r);
  for(i=0;i<r;i++){
    scanf("%d %d",&p,&q);
    if(boat[p]==boat[q]){
      f[p]=1;
      f[q]=1;
    }
  }
  for(i=0;i<n;i++)
    ans+=f[i+1];
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    rep(i, N) { cin >> D[i]; }
    int M;
    cin >> M;
    vector<int> T(M);
    rep(i, M) { cin >> T[i]; }
    map<int, int> mp;
    rep(i, N) { mp[D[i]]++; }
    rep(i, M) {
        if(mp[T[i]] == 0) {
            cout << "NO" << endl;
            return 0;
        }
        mp[T[i]]--;
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, k;
	double d, sum = 0.0, ans = 0.0;
	queue<double> que;
	cin >> num >> k;
	rep(i, num) {
		cin >> d;
		d = (d + 1.0) / 2.0;
		sum += d;
		que.push(d);
		chmax(ans, sum);
		if (que.size() == k) {
			sum -= que.front();
			que.pop();
		}
	}
	printf("%.9lf\n", ans);
	return 0;
}

Measured memory_bytes: 1920