akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//Macro Functions
#define FOR(i,a) for(int i = 0; i < a; i++)
#define IN(...) cin >> __VA_ARGS__;
#define IF_EQU(a,b) if(a==b)
#define PRINT cout << 
#define END << endl

//Data Types
typedef long long ll;

//Functions
ll arraySum(ll a[], int n) 
{
    ll initial_sum  = 0; 
    return accumulate(a, a+n, initial_sum);
}

ll digit_sum(ll number)
{
	ll sum = 0;
	while(number != 0){
		sum += number%10;
		number /= 10;
	}
	return sum;
}



int main(){
	ll n, m;
	IN(n);
	m = digit_sum(n);
	if(n%m != 0) PRINT "No" END;
	else PRINT "Yes" END;
}

Measured memory_bytes: 256
height, width = gets.split.map(&:to_i)
squares = Array.new(height) {Array.new(width, 0)}
queue = []

height.times do |h|
  gets.each_char.with_index do |e, w|
    if e == '#'
      queue << h * width + w
      squares[h][w] = 1
    end
  end
end

n_step = 0

until queue.empty?

  h, w = queue.shift.divmod(width)
  n_step = squares[h][w]

  if h + 1 < height && squares[hh = h + 1][w] == 0
    squares[hh][w] = n_step + 1
    queue << hh * width + w
  end

  if 0 <= h - 1 && squares[hh = h - 1][w] == 0
    squares[hh][w] = n_step + 1
    queue << hh * width + w
  end

  if w + 1 < width && squares[h][ww = w + 1] == 0
    squares[h][ww] = n_step + 1
    queue << h * width + ww
  end

  if 0 <= w - 1 && squares[h][ww = w - 1] == 0
    squares[h][ww] = n_step + 1
    queue << h * width + ww
  end
end

puts n_step - 1



Measured memory_bytes: 21556
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,i,j,x,y;
int main()
{
	cin>>n;
	for (i=1;i<=3500;i++)
	{
		for (j=1;j<=3500;j++)
		{
			x=n*i*j;
			y=4*i*j-n*i-n*j;
			if (y<=0) continue;
			if (x%y==0)
			{
				cout<<i<<' '<<j<<' '<<x/y;
				return 0;
			}
		}
	}
	return 0;
}

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

int main(void) {
	int a[5]; // アンテナの座標
	int k; 
	int i,j; // ループ用変数

	/*アンテナ座標とkの値の入力*/
	for(i=0;i<5;i++) cin >> a[i];
	cin >> k;

	/*すべてのアンテナ間距離を計算し，kより大きいものを計数*/
	int count=0;
	for(i=0;i<5;i++) {
		for(j=i+1;j<5;j++) {
			if(a[j]-a[i]>k) count += 1;
		}
	}

	if(count==0) cout << "Yay!" << endl;
	else cout << ":(" << endl;

	return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc115/tasks/abc115_c
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N, K;
    cin >> N >> K;
    vector<int>h(N);
    for( auto&x : h)
    {
        cin >> x;
    }
    sort(ALL(h));
    int res = INT_MAX;
    for( int i = 0; i <= N-K; ++i )
    {
        res = min( res, h[i+K-1]-h[i]);
    }
    cout << res << endl;
    return 0;
}

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

signed main() {
    int n,k;
    string s;

    cin >> n >> k >> s;
    int cnt = 0;
    for(int i = 1; i < n; i++){
        if(s[i-1] == s[i]) cnt++;
    }
    cout << min(n - 1, cnt + 2 * k) << endl;
}

Measured memory_bytes: 512
n = int(input())
V_list = list(map(int, input().split()))

eo = [{}, {}]
# 0: even 1: odd
for i in range(len(V_list)):
    v = V_list[i]

    tmp = (i + 1) % 2
    eo[tmp][v] = eo[tmp].get(v, 0) + 1


eomax = [max(eo[i].values()) for i in range(2)]
maxkv = [[(k, v) for k, v in eo[i].items() if v == eomax[i]] for i in range(2)]

for ke, ve in maxkv[0]:
    flag = False
    for ko, vo in maxkv[1]:
        if(ke != ko):
            ans = n - ve - vo
            flag = True
            break
    if(flag is True):
        break
else:
    sec = [0, 0]
    for i in range(2):
        for v in eo[i].values():
            if(v >= eomax[i]):
                continue
            sec[i] = max(sec[i], v)
    ans = min(n - eomax[0] - sec[1], n - eomax[1] - sec[0])
    # print(ans)
print(ans)

Measured memory_bytes: 20720
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX = 1005;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;

int a[26];
int main()
{
    string s;
    cin >> s;
    bool flag = s.length() <= 26;
    if(flag)
    {
        for(int i = 0; i < s.length(); ++i)
        {
            if(a[s[i]-'a'])
            {
                flag = false;
                break;
            }
            a[s[i]-'a']++;
        }
    }

    if(flag) puts("yes");
    else puts("no");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

ll gcd(ll a, ll b){
  if(b == 0)
    return a;
  return gcd(b, a%b);
}

int main()
{
  int N;
  cin >> N;
  vector<ll>T(N);
  for(int i=0; i < N; i++)
    cin >> T[i];
  for(int i=1; i < N; i++){
   ll g = gcd(T[i-1], T[i]);
   T[i] = (T[i-1]/g)*(T[i]);
  }
  cout << T[N-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,m;
	
int main(){
	cin>>n>>m;
	if(n==1&&m==1){
		cout<<1<<endl;
		return 0;
	}
	if(n==1||m==1){
		cout<<n*m-2<<endl;
		return 0;
	}
	cout<<(n-2)*(m-2)<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque

n, m = map(int, input().split())
eg = [[] for _ in range(n + 1)]

for _ in range(m):
    a, b = map(int, input().split())
    eg[a].append(b)
    eg[b].append(a)

xs = [0] * (n + 1)
q = deque()
q.append(1)
seen = {1}
while len(q) > 0:
    v = q.popleft()
    for t in eg[v]:
        if t in seen:
            continue
        q.append(t)
        seen.add(t)
        xs[t] = v
print("Yes")
print(*xs[2:], sep="\n")


Measured memory_bytes: 39976
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;

int main(void) {
  string S;
  cin >> S;
  int c = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'x') {
      c++;
    }
  }
  if (c >= 8) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = input()
def F(n):
	return sum(map(int, list(str(n))))

t = 1
z = F(n)
while n > 0:
	n -= n % t
	if n == 0:
		break
	z = max(z, F(n))
	z = max(z, F(n - 1))
	t *= 10
print z

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

using namespace std;
using ll = long long;

int main(){
    int N,M,K;
    cin >> N >> M >> K;

    vector<ll> A(N);
    vector<ll> B(M);
    for(int i=0; i<N; i++)cin >> A.at(i);
    for(int i=0; i<M; i++)cin >> B.at(i);

    vector<ll> csA(N+1,0);
    vector<ll> csB(M+1,0);
    for(int i=0; i<N; i++)csA.at(i+1) = csA.at(i) + A.at(i);
    for(int i=0; i<M; i++)csB.at(i+1) = csB.at(i) + B.at(i);

    int res = 0;
    int idxB = M;
    for(int idxA=0; idxA<=N; idxA++){
        ll sumA = csA.at(idxA);
        ll t = K - sumA;
        if(t < 0)continue;

        while(sumA + csB.at(idxB) > K)idxB--;
        // auto itr = lower_bound(csB.begin(), csB.end(), t);
        // if(*itr > t)--itr;
        // int idxB = itr - csB.begin();
        res = max(res, idxA+idxB);
    }
    cout << res << endl;
}

Measured memory_bytes: 9584
S = input()
T = input()

min_count = len(T)
for s_i in range(len(S)):
    i = s_i
    matched = 0
    for j in range(len(T)):
        if len(S) <= i:  # Out of S
            matched = 0  # Cannot append characters to S
            break
        if S[i] == T[j]:
            matched += 1
        i += 1
    count = len(T) - matched
    if count < min_count:
        min_count = count
print(min_count)

Measured memory_bytes: 9104
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int d[101010];
int main()
{
	int num, kai;
	scanf("%d%d", &num, &kai);
	bool f = false;
	for (int i = 0; i < num; i++)
	{
		if (!f)scanf("%d", &d[i]);
		else scanf("%d", &d[i + 1]);
		if (!f&&d[i]>0)d[i + 1] = d[i], d[i] = 0, f = true;
	}
	num++, kai++;
	int mini = 2000000000;
	for (int i = 0; i < num; i++)
	{
		if (d[i] <= 0 && i + kai - 1 < num)mini = min(mini, -d[i] - d[i] + d[i + kai - 1]);
		if (d[i] >= 0 && i - kai + 1 >= 0)mini = min(mini, d[i] + d[i] - d[i - kai + 1]);
	}
	printf("%d\n", mini);
}

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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define ll long long

using namespace std;

int main(){
  long long N;
  cin >> N;
  long long sum=0;
  rep(i,N){
    if((i+1)%3!=0&&(i+1)%5!=0){
      sum+=i+1;
    }
  }
  cout << sum;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll INF = 1e17;

struct edge{ll to,cost;};
 
void dijkstra(vector<vector<edge> > &graph, int start, VL &d){
    int n = graph.size();
    d.assign(n, INF);
    d[start] = 0;
    priority_queue<PL, vector<PL>, greater<PL> > q;
    q.push(make_pair(0, start));
    while (!q.empty()){
        PL a = q.top();
        q.pop();
        int now = a.second;
        if(d[now] < a.first) continue;
        REP(i,graph[now].size()){
            edge e = graph[now][i];
            int next = e.to;
            if (d[next] > d[now] + e.cost){
                d[next] = d[now] + e.cost;
                q.push(make_pair(d[next], next));
            }
        }
    }
}

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    VI p(n), c(n), j(n);
    REP(i,n) p[i] = in();
    REP(i,n) c[i] = in() - 1;
    REP(i,n) j[i] = in();

    vector<vector<edge>> e(n), e2(2 * n);
    REP(i,m){
        int u = in() - 1, v = in() - 1, t = in();
        e[u].push_back(edge{v, t});
        e[v].push_back(edge{u, t});
        // e2[u].push_back(edge{v, t});
        // e2[v].push_back(edge{u, t});
        e2[n + u].push_back(edge{n + v, t});
        e2[n + v].push_back(edge{n + u, t});
    }
    // REP(i,n) e2[i].push_back(edge{n + i, -p[i]});
    VL dist, cost;
    dijkstra(e, 0, dist);
    REP(i,n) e2[0].push_back(edge{n + i, dist[i] - p[i]});
    dijkstra(e2, 0, cost);

    // REP(i,n) cout << dist[i] << " ";
    // cout << endl;
    // REP(i,2*n) cout << cost[i] << " ";
    // cout << endl;

    VL ans(k, -INF);
    REP(i,n){
        ll tmp = j[i] - dist[i] - cost[n + i];
        chmax(ans[c[i]], tmp);
    }
    REP(i,k) printf("%lld\n", ans[i]);

    return 0;
}



Measured memory_bytes: 37736
#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)
/* Precode Start Here *\
     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 */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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



 ll x,cnt=0;
 cin>>x;
 ll d=100;
 while(1)
 {
     if(d>=x)
        break;
     cnt++;
     ll a=(d*1)/100;
     d+=a;
 }
 cout<<cnt<<endl;
return 0;
}



Measured memory_bytes: 3656
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
char da[4] = { 'R', 'L', 'D', 'U' };
char dax[4] = { -1, 1, -1, 1 };
char dax2[4] = { 1, -1, 1, -1 };
ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }





vector<ll> conlist[100];
ll p[1000];


ll dfs(int state, int num,  int all, int M) {

	ll sum = 0;
	if ( num == all) {
		rep(i, M) {
			rep(j, conlist[i].size()) {
				sum += ((state & (1LL << conlist[i][j])) >> conlist[i][j]);
			}

			if (sum % 2 != p[i]) {
				return 0;
			}
			sum = 0;
		}


		return 1;
	}


	return dfs(state  + (1LL << num), num + 1, all, M) + dfs(state, num + 1, all, M);


}


int main() {
	ll n, m;

	cin >> n >> m;


	rep(i, m) {
		ll k, s;
		cin >> k;

		rep(j, k) {

			cin >> s;
			s--;
			conlist[i].push_back(s);
		}

	}


	rep(i, m) {
		cin >> p[i];
	}

	cout << dfs(0, 0, n, m) << endl;

	return 0;

}

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

int main(){
  ll h,w,i,j,m,n,o;
  string k,l;
  n=0;
  cin >> h >> w;
  ll s[h+1][w+1],t[h+1][w+1];
  for(i=0;i<=h;i++){
    if(i!=0)cin >> k;
    for(j=0;j<=w;j++){
      if(i*j==0){
        s[i][j]=10001;
        t[i][j]=0;
        o=0;
      }
      else{
        l=k.substr(0,1);
        k.erase(0,1);
        if(l==".")m=0;
        if(l=="#")m=1;
        t[i][j]=m;
        o=0;
        if((m==1)&(s[i-1][j]<=s[i][j-1])){
          o=max(o,t[i-1][j]);
        }
        if((m==1)&(s[i][j-1]<=s[i-1][j])){
          o=max(o,t[i][j-1]);
        }
        s[i][j]=min(s[i-1][j],s[i][j-1])+m-o;
      }
      if((i==1)&(j==1)){
        s[i][j]=m;
      }
    }
  }
  cout << s[h][w] <<endl;
}
     

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#define CUT (1000000000+7)
using namespace std;

int main(){
  int N,M,i;
  long long ansn = 1,ansm = 1;
  cin >> N >> M;
  if(abs(N-M)>1){
    cout << "0" << endl;
    return 0;
  }
  for(i=1;i<=N;i++)ansn=(ansn*i)%CUT;
  for(i=1;i<=M;i++)ansm=(ansm*i)%CUT;
  ansn=(ansn*ansm)%CUT;
  if(N==M)ansn=(ansn*2)%CUT;
  cout << ansn << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  rep(i, n) cin >> a[i].first, a[i].second = i + 1;
  sort(a.begin(), a.end());
  for (auto aa : a) cout << aa.second << " ";
}

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

int main(){
    int n;
    cin >> n;
    vector<P> sp;
    map<P,int> m;
    rep(i,n){
        string s;int p;
        cin >> s >> p;
        p = -p;
        sp.emplace_back(s,p);
        P mp(s,p);
        m[mp] = i+1;
    }
    sort(sp.begin(),sp.end());
    for(auto p : sp){
        cout << m.at(p) << endl;
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define N 5000000005
#define sag (root+root+1)
#define sol (root+root)
#define ort  ((bas+son)/2)
#define mod 1000000007

using namespace std;
typedef long long ll;

ll n, m, v, p;
ll arr[(ll)1e5+5];

bool check(ll ind) {
    ll sayi = arr[ind] + m;
    ll arttir = ind;
    ll sonlar = p-1;
    ll son_sayi = arr[n-p];
    if(son_sayi > sayi) return false;
    if(sonlar + arttir >= v) return true;
    ll oy_sayisi = m*v - (arttir + sonlar +1)*m;
    for(ll i = ind+1; i <= n-p; i++) {
        oy_sayisi -= (sayi - arr[i]);
        if(oy_sayisi <= 0) return true;
    }
    return false;
}
int main() {
    cin >> n >> m >> v >> p;
    //memset(arr, INT_MAX, sizeof arr);
    for(ll i = 0; i <n;i++) cin >> arr[i];
    sort(arr, arr+n);
    //for(int i=0; i<n; i++) cout << arr[i];
    ll l = 0, r = n-1;
    while(l < r-3) {
        ll mid = (l+r)/2;
        if(check(mid)) r = mid;
        else l = mid;
    }
    //cout << check(n-2) << endl;
    ll ans = n-1;
    for(ll i = l; i <= r; i++) {
        if(check(i)) {ans = i; break;}
    }
    cout << n - ans <<endl;
    

    return 0;
}

Measured memory_bytes: 1024
#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 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>
     
using namespace std;

main {
  vi t(10);
  rep(i, 10) cin>>t[i];
  sort(t.rbegin(), t.rend());
  cout<<t[0]<<endl<<t[1]<<endl<<t[2]<<endl;
  bye;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
 using namespace std;
 #define ll long long int
 int main()
  {   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
       ll b,c=0,x,i,j,n;
        cin>>n;
         ll a[n],sum=0;
          for(i=0;i<n;i++)
             {cin>>a[i];
              sum+=a[i];
             }
           for(i=0;i<n-1;i++)
             {  sum-=a[i];
               c+=((sum%1000000007)*((a[i])%1000000007))%1000000007;
             }
             cout<<c%1000000007<<endl;
        }


Measured memory_bytes: 5204
#include<iostream>
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<math.h>
typedef long long ll;
using namespace std;
int main()
{
    ll s;
    cin >> s;
    cout << (1000-(s % 1000))%1000;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>


int main()
{
  long N, A, B, divi, remaind,result;
 
  scanf("%ld %ld %ld", &N, &A, &B);
 
  divi = N / (A + B);
  remaind = N % (A + B);
  
  if(remaind < A)
  {
    result = A * divi + remaind;
  }
  else
  {
      result = A * divi + A;
  }
  
  printf("%ld", result);
  return 0;
}

Measured memory_bytes: 128
#include<cmath>
#include<iostream>
using namespace std;
const int MAXN = 51;
int a[MAXN], b[MAXN], c[MAXN], d[MAXN];
inline int dist(int x1, int y1, int x2, int y2) {
	return abs(x1-x2) + abs(y1-y2);
}
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		cin >> a[i] >> b[i];
	}
	for (int j = 1; j <= M; j++) {
		cin >> c[j] >> d[j];
	}
	for (int i = 1; i <= N; i++) {
		int min_dist = dist(a[i], b[i], c[1], d[1]);
		int id = 1;
		for (int j = 2; j <= M; j++) {
			int cur_dist = dist(a[i], b[i], c[j], d[j]);
			if (cur_dist < min_dist) {
				min_dist = cur_dist;
				id=j; 
			}
		}
		cout<<id<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;

int main() {
  ll n;
  cin >> n;
  vec d(n);
  vec c(2);
  for(ll i=0;i<n;i++) {
    cin >> d[i];
  }
  sort(d.begin(),d.end());
  ll t=24;
  for(ll i=0;i<n;i++) {
    t=min(t,d[i]-c[i&1]);
    c[i&1]=d[i];
  }
  cout << min(t,24-c[0]-c[1]) << endl;
}

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

int selectionSort(int num[],int len);

int main(void)
{
  int i,count;
  int len;
  int *num;

  scanf("%d",&len);
  
  num=calloc(len,sizeof(int));

  for(i=0;i<len;i++)
    {
      scanf("%d",&num[i]);
    }

  count=selectionSort(num,len);

  for(i=0;i<len;i++)
    {
      printf("%d",num[i]);

      if(i!=len-1)
	{
	  putchar(' ');
	}
    }
  
  putchar('\n');

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


int selectionSort(int num[],int len)
{
  int i,j,min,tmp,count=0;
  
  for(i=0;i<len-1;i++)
    {
      min=i;
      
      for(j=i;j<len;j++)
	{
	  if(num[j]<num[min])
	    {
	      min=j;
	    }
	}
      
      tmp=num[i];
      num[i]=num[min];
      num[min]=tmp;

      if(i!=min)
	{
	  count++;
	}
    }
  
  return count;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int N,K,X,Y;
  cin>>N>>K>>X>>Y;
  if(N<=K){
    cout<<N*X<<endl;
  }else{
    cout<<K*X+(N-K)*Y<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;
 
 
int main(){
    float r;
    cin >> r;
    cout << 2*M_PI*r << endl;
 
}


Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int n, m, i, j, k, s, c;
	cin >> n >> m;
	vector<set<int>> p(n);
	for (i = 0; i < m; i++) {
		cin >> s >> c;
		s--;
		p[s].insert(c);
	}

	vector<int> ans(n);
	bool valid = true;
	for (i = 0; i < n; i++) {
		if (p[i].empty()) {
			if ((i == 0) && (n > 1)) ans[i] = 1;
			else ans[i] = 0;
		}
		else {
			if (p[i].size() > 1) valid = false;
			else {
				ans[i] = *p[i].begin();
			}
		}
	}

	if ((ans[0] == 0) && (n > 1)) valid = false;
	if (!valid) cout << "-1\n";
	else {
		for (auto p : ans) cout << p;
		cout << "\n";
	}



	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;
constexpr double EPS = 1e-10;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n,s; cin >> n >> s;
    vector<int> a(n);
    REP(i,n) cin >> a[i];

    deque<int> dq;
    vector<int> ans;
    for(int i=0; i < n; ++i) {
        while(dq.size() && a[dq.back()] >= a[i]) dq.pop_back();
        dq.push_back(i);

        if(i - s + 1 >= 0) { 
            ans.push_back(a[dq.front()]);
            if(dq.front() == i - s + 1) dq.pop_front();
        }
    }

    for(int i=0; i < (int)ans.size(); ++i) {
        cout << ans[i] << (i == (int)ans.size()-1 ? '\n':' ');
    }
    return 0;
}


Measured memory_bytes: 11000
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& a) {
  for (int i = 0; i < (int)a.size(); ++i)
    os << a[i] << " \n"[i == (int)a.size() - 1];
  return os;
}

constexpr ll MOD = 1000000007;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), s(n + 1);
  rep(i, 0, n) {
    cin >> a[i];
    s[i + 1] = s[i] + a[i];
  }

  ll ans = INFL;
  // [l, r)
  int l = 1;
  int r = 3;
  rep(center, 2, n - 1) {
    ll pq = s[center];
    ll rs = s[n] - s[center];

    // lとrを動かす
    while (l + 1 < center &&
           abs((pq - s[l]) - s[l]) > abs((pq - s[l + 1]) - s[l + 1]))
      ++l;
    while (r + 1 < n && abs((s[r] - s[center]) - (s[n] - s[r])) >
                          abs((s[r + 1] - s[center]) - (s[n] - s[r + 1])))
      ++r;

    ll P = pq - s[l];
    ll Q = s[l];
    ll R = s[r] - s[center];
    ll S = rs - R;
    // cout << Q << " " << P << " " << R << " " << S << endl;
    ll v = max(P, max(Q, max(R, S))) - min(P, min(Q, min(R, S)));
    ans = min(ans, v);
  }
  cout << ans << endl;
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  string s;
  list<char> l;
  ll Q;
  bool startFront = true;
  cin >> s >> Q;
  for (auto c : s) {
    l.push_back(c);
  }
  while(Q--) {
    ll t;
    cin >> t;
    if (t == 1) {
      startFront = !startFront;
    } else {
      ll f;
      char c;
      cin >> f >> c;
      if (f == 1) {
        if (startFront)  l.push_front(c);
        else             l.push_back(c);
      } else {
        if (startFront)  l.push_back(c);
        else             l.push_front(c);
      }
    }
  }
  if (startFront) {
    for (auto c : l) {
      cout << c;
    }
  } else {
    for (auto it = l.rbegin(); it != l.rend(); it++) {
      cout << *it;
    }
  }
  cout << endl;
  return 0;
}


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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
    ll W, H, x, y;
    cin >> W >> H >> x >> y;

    double s = W * H / 2.0;
    int judge;
    if (W % 2 == 0 && W == 2 * x && H % 2 == 0 && H == 2 * y) judge = 1;
    else judge = 0;

    cout << setprecision(10) << s << ' ' << judge << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define INF 1e+8

using namespace std;

int fr[11101];
int cnt,temp,temp1,temp2;
int n,m;
int a[11100],b[11100];
int main(void){
    while(1){
        cin>>n>>m;
        if(n==0&&m==0)break;
        cnt=0;
        REP(i,11000){
            fr[i]=0;
            a[i]=0;
            b[i]=0;
        }
        REP(i,m){
            cin>>a[i]>>b[i];
            if(a[i]>b[i]){
                temp=a[i];
                a[i]=b[i];
                b[i]=temp;
            }
        }
        REP(i,m){
            REP(j,m-1){
                if(a[i]==1&&a[j]>a[i]){
                    temp1=a[i];
                    a[i]=a[j];
                    a[j]=temp1;
                    temp2=b[i];
                    b[i]=b[j];
                    b[j]=temp2;
                }
            }
        }
        REP(i,m){
            if(a[i]==1){
                fr[a[i]]=1;
                fr[b[i]]=1;
            }
            if(fr[a[i]]==1&&fr[b[i]]==0){
                fr[b[i]]=2;
            }
            if(fr[a[i]]==0&&fr[b[i]]==1){
                fr[a[i]]=2;
            }
        }
        FOR(i,2,m){
            if(fr[i]){
                cnt++;
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}

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

#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;

void solve()
{
	char x;
	cin >> x;
	if (tolower(x) == x)
		cout << 'a';
	else
		cout << 'A';
}


int main()
{

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

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

	int t = 1;
	// cin >> t;
	while (t--)
	{
		solve();
	}

	return 0;
}




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

//dp[i][j][k] : i行目まで決めて，j個の非0を使って，ｋ→0:そこまでの桁はｓと一致，→1：そこまでの桁で既にｓ以下であることが確定．
int dp[105][4][2];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	int K;
	cin >> K;
	//初期値
	dp[0][0][0] = 1;
	rep(i, n)rep(j, 4)rep(k, 2){
		//今見ている桁の数
		int nd = s[i]-'0';
		//この桁に入れる値
		rep(d, 10){
			//ni:次の桁，nj:何個の非0を使ったか，nk:s以下であることが既に確定されているか
			int ni = i+1, nj = j, nk = k;
			//dが0でなければ「非0の値を使う」という意味なのでnjの値をインクリメント
			if(d != 0) nj++;
			//njの値がKを超えることはない
			if(nj > K) continue;
			//sとの大小を比べる必要あり
			if(k == 0){
				//この桁に入れる予定の値がsとの大小関係を満たさない場合
				if(d > nd) continue;
				//s未満であることが確定する場合
				if(d < nd) nk = 1;
			}
			dp[ni][nj][nk] += dp[i][j][k];
		}
	}
	int ans = dp[n][K][0] + dp[n][K][1];
	cout << ans << endl;
	return 0;
}

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

#define PI 3.14159265

int main(void)
{

	double a,b,c;
	double kodoc,sinc,cosc,tanc,an;
	double S,L,h;

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

	kodoc = PI * c/ 180;
	sinc = sin(kodoc);
	cosc = cos(kodoc);
	tanc = tan(kodoc);

	S = a * b* sinc/2;
	an = a*a+b*b-2*a*b*cosc;
	L = a+b+sqrt(an);
	h= b*sinc;

	printf("%f %f %f\n",S,L,h);

	return 0;
}
	

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

int main() {
    string s;
    while (cin >> s && s != "#") {
        int n = s.length();
        int cnt = 0;
        vector<string> res;
        for (int mask = 0; mask < (1 << n); mask++) {
            vector<bool> seen(26, false);
            seen[0] = true;
            bool invalid = false;
            for (int i = 0; i < n; i++) {
                char c = s[i];
                if (mask & (1 << i)) {
                    if (c == 'z') {
                        invalid = true;
                        break;
                    } else {
                        c++;
                    }
                }
                if (!seen[c - 'a']) {
                    seen[c - 'a'] = true;
                    c--;
                }
                if (s[i] != c) {
                    invalid = true;
                    break;
                }
            }
            if (invalid) continue;
            string t;
            for (int i = 0; i < n; i++) {
                char c = s[i] + bool(mask & (1 << i));
                t += c;
            }
            cnt++;
            res.emplace_back(t);
            sort(res.begin(), res.end());
            if (res.size() == 11) res.erase(res.begin() + 5);
        }
        cout << cnt << endl;
        for (string s: res) cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
constexpr int P = 1E9 + 7, N = 3E2;
void inc(int &a, int b) {(a += b) >= P ? a -= P : 0;}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(2 * n), c(2 * n);
    for (int i = 0; i < 2 * n; ++i) {
        cin >> a[i];
        if (a[i] != -1)
            c[--a[i]] = 1;
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (a[2 * i] != -1 && a[2 * i + 1] != -1)
            c[a[2 * i]] = c[a[2 * i + 1]] = 2;
        if (a[2 * i] == -1 && a[2 * i + 1] == -1)
            ++cnt;
    }
    int f[2 * N + 1][N + 1][N + 1] {};
    f[2 * n][0][0] = 1;
    for (int i = 2 * n - 1; i >= 0; --i) {
        if (c[i] == 2) {
            memcpy(f[i], f[i + 1], sizeof(f[i]));
            continue;
        }
        for (int j = 0; j <= n; ++j) {
            for (int k = 0; k <= n; ++k) {
                int val = f[i + 1][j][k];
                if (val == 0)
                    continue;
                if (c[i] == 1) {
                    if (k < n)
                        inc(f[i][j][k + 1], val);
                    if (j > 0)
                        inc(f[i][j - 1][k], val);
                } else {
                    if (j < n)
                        inc(f[i][j + 1][k], val);
                    if (j > 0)
                        inc(f[i][j - 1][k], val);
                    if (k > 0)
                        inc(f[i][j][k - 1], 1LL * k * val % P);
                }
            }
        }
    }
    int ans = f[0][0][0];
    for (int i = 1; i <= cnt; ++i)
        ans = 1LL * ans * i % P;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 213120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5;
vector<ll> adj[N];
ll n,k,ans;
ll dfs(ll src,ll pr){
    ll mx=0;
    for(auto &v:adj[src])mx=max(mx,dfs(v,src));
    if(mx==k-1){
        if(pr!=0)ans++;
        return 0;
    }
    return mx+1;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>k;
    for(ll i=0;i<n;i++){
        ll p;cin>>p;
        p--;
        if(i==0){
            if(p!=0)ans++;
        }
        else adj[p].push_back(i);
    }
    dfs(0,0);
    cout<<ans;
}

Measured memory_bytes: 10368
#include<stdio.h>
int main(void)
{
    int a[3],b,c,d,n,i,j,k,tmp;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d",&a[0],&a[1],&a[2]);
    for(k=0;k<2;k++){
        for(j=k+1;j<3;j++){
        if(a[k]<a[j]){
            tmp=a[k];
            a[k]=a[j];
            a[j]=tmp;
        }
        }
    }
        b=a[0]*a[0];
        c=a[1]*a[1];
        d=a[2]*a[2];
        if(b==c+d){
            printf("YES\n");
        }
        if(b!=c+d){
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <stack>
#include <map>

using namespace std;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

template<int MOD> struct MInt {
  long long val;
  constexpr MInt(long long val = 0) : val(val % MOD) { if (val < 0) val += MOD; }
  MInt operator+(const MInt& n) const { return MInt(val) += n; }
  MInt& operator+=(const MInt& n) { val = (val + n.val) % MOD; return *this; }
  friend ostream& operator<<(ostream& os, const MInt& n) { os<<n.val; return os; }
};
constexpr int MOD = 1e9+7;
using mint = MInt<MOD>;

int main() {
  int in(N);

  stack<int> v;
  rep(i, N) {
    int in(c);
    if (v.empty() || v.top() != c)
      v.push(c);
  }
  map<int, int> m;
  vector<mint> dp(N+1, 0);
  map<int, mint> sum;
  mint ans;

  rep(i, v.size()) {
    int c = v.top(); v.pop();
    ans = dp[i+1] = dp[i] + m[c] + sum[c];
    sum[c] += dp[i];
    ++m[c];
  }
  cout << ans + 1 << endl;

  return 0;
}


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

int main() {
  
  long long A;
  string str;
  cin >> A >> str;
  long long B = 0;
  for(char ch : str){
    if(ch != '.'){
      B += (ch - '0');
      B *= 10;
    }
   }
   B /= 10;
   
  cout<<((long long) A*B/100)<<endl;
}


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

int main() {
      int a1, a2, a3;
      cin >> a1 >> a2 >> a3;
      if(22 <= a1 + a2 + a3) {
            cout << "bust" <<endl;
      }
      else {
            cout << "win" << endl;
      }
      return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define pb push_back
#define pf push_fron
#define INF 1e9
#define PI acos(-1)
typedef long long ll;


int main() {
	ll x, y, ans = 0;
	cin >> x >> y;
	
	while (x <= y) {
		ans++;
		x *= 2;
	}

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

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

int main() {
  int n; cin >> n;
  double ans,x;
  for(int i = 0; i < n; i++) {
      cin >> x;
      if(i == 0) ans = x;
      else{
          ans = (1.0 / (1/ans + 1/x));
      }
  }
  printf("%.6f", ans);
}


Measured memory_bytes: 256
import numpy
import itertools

n,d = list(map(int,input().split()))
count = 0
x = []

for i in range(n) :
    x.append(numpy.array(list(map(int,input().split()))))

for xs in itertools.combinations(x,2):
    dist = numpy.linalg.norm(xs[1] - xs[0])

    if dist % 1 == 0 :
        count += 1

print(count)

Measured memory_bytes: 12508
/*
There was a time, looking through myself
Wanting to pretend
If I escaped, I could fill myself
I don't think you can
Been far and wide
But that hole inside
Never really leaves
When I went away, what I really left
Left behind was me

It's telling me
To be on my way home
Million miles away
I can't stay

Each passing day, every passing face
Seems like such a blur
I long to be
Home, silently
Lying next to her
Just to get back, by her side is all
All I need to be
Cause I went away
But what I really left
Left behind was me

I need to be
Getting on my way home
A million miles away
Million miles away
I can't take
*/

//#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 510031;

int n,c,cnt[N];
int ans;

vector<pair<int,int> > block[1000];

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>n>>c;
	for (int i=1;i<=n;i++){
		int l,r,id;
		cin>>l>>r>>id;
		block[id].push_back(make_pair(l,r));
	}

	for (int i=1;i<=c;i++){
		sort(block[i].begin(),block[i].end());
		int qr=-1e9;
		int ql=-1e9;
		for (int j=0;j<block[i].size();j++){
			if (block[i][j].first!=qr){
				if (j){
					cnt[ql]++;
					cnt[qr+1]--;
				}
				ql=block[i][j].first;
			}
			qr=block[i][j].second;
		}
		//cout<<ql<<"$"<<qr<<endl;
		if (block[i].size())
			cnt[ql]++,cnt[qr+1]--;
	}

/*	for (int i=1;i<=10;i++){
		cout<<cnt[i]<<" ";
	}
*/
	ans=cnt[0];


	for (int i=1;i<=100000;i++){
		cnt[i]+=cnt[i-1];
		ans=max(ans,cnt[i]);
	}
	cout<<ans<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 1920
#include <algorithm>
#include <array>
#include <bitset>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
//region cp_helper
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vii vector<ii>
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define pin(n) in(n.first) >> n.second
#define vin(a, n) for (int i=0; i<n; i++) in(a[i])
#define viin(a, n) for (int i=0; i<n; i++) in2(a[i].first, a[i].second);
#define out(n) cout << n
#define outs(n) out(n) << ' '
#define outn(n) out(n) << '\n'
#define out2(n, m) cout << n << ' ' << m
#define out2s(n, m) out2(n, m) << ' '
#define out2n(n, m) out2(n, m) << '\n'
#define pout(n) out2(n.first, n.second)
#define pouts(n) pout(n) << ' '
#define poutn(n) pout(n) << '\n'
#define vout(a) for (auto i : a) outs(i)
#define viout(a) for (auto i : a) out2n(i.first, i.second)
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pp(a, b) emplace_back(make_pair(a, b))
#define fori(i, n) for (int i=0; i<n; i++)
#define foris(i, a, b) for (int i=a; i<=b; i++)
#define ford(i, n) for (int i=n-1; i>=0; i--)
#define fords(i, a, b) for (int i=a; i>=b; i--)
#define forr(i, a) for (auto i : a)
const int mod = (int)(1e9) + 7;
//endregion
using namespace std;

int n, m, a, b, arr[100005], total;

int main() {
    io();
    in2(n, m);
    fori(i, m) {
        in2(a, b);
        arr[a]++; arr[b+1]--;
    }
    fori(i, 100004) arr[i+1] += arr[i];
    forr(i, arr) total += (i == m);
    out(total);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
 
/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace std;
 
#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const LL MOD = 1000000000 + 7;
const LD EPS = 0.0000001 ;
#define MPP(a, b, c) MP(MP(a, b), c)
#define PII pair<pair<LL,LL>, LL>
 
LL pows(LL a, LL b)
{
	if (b == 0) return 1LL;
	LL temp = pows(a, b / 2);
	temp = (temp * temp) % MOD;
	if (b % 2) temp = (temp * a) % MOD;
	return temp;
}

const int N = 3001;

LL dp[N][N];
LL arr[N];
bool vis[N][N];

LL solve(int l, int r)
{
	if (l == r) return arr[l];
	if (r - l == 1) return abs(arr[r] - arr[l]);
	if (l > r) return 0;
	if (vis[l][r]) return dp[l][r];
	vis[l][r] = true;
	LL &ans = dp[l][r];
	if (solve(l + 2, r) - arr[l + 1] > solve(l + 1, r - 1) - arr[r]){
		ans = arr[l] - arr[r] + solve(l + 1, r - 1);
	} else {
		ans = arr[l] - arr[l + 1] + solve(l + 2, r);
	}
	LL temp2;
	if (solve(l + 1, r - 1) - arr[l] > solve(l, r - 2) - arr[r - 1]){
		temp2 = arr[r] - arr[r - 1] + solve(l, r - 2);
	} else {
		temp2 = arr[r] - arr[l] + solve(l + 1, r - 1);
	}
	ans = max(ans, temp2);
	return ans;
}

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

    memset(dp, -1, sizeof(dp));
    int n; cin >> n;
    for (int i = 1; i <= n; i++) cin >> arr[i];

    cout << solve(1, n) << endl;

	return 0;
}

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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};

int N;
string s;
vector<int> A[10];

int main() {
    cin >> N >> s;
    REP(i, N) A[s[i] - '0'].push_back(i);
    set<tuple<int, int, int>> res;
    REP(i, 10) {
        if (A[i].size() == 0)continue;
        int p1 = A[i][0];
        REP(j, 10) {
            if (A[j].size() == 0)continue;
            auto it = upper_bound(A[j].begin(), A[j].end(), p1);
            if (*it >= N || *it <= p1)continue;
            REP(k, 10) {
                if (A[k].size() == 0)continue;
                auto it2 = upper_bound(A[k].begin(), A[k].end(), *it);
                if (*it2 >= N || *it2 <= *it)continue;
                res.insert(make_tuple(p1, *it, *it2));
            }
        }
    }
    cout << res.size() << endl;
    return 0;

}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;






int main() {

    int n, k;
    cin >> n >> k;

    int ans;
    if (n%k == 0) ans = 0;
    else ans = 1; 

    out(ans);

    return 0;
}




//              g++ -std=c++1z






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	vi v(3); rep(i,3) cin >> v[i];
	SORT(v);
	if(v[0]==v[1]&&v[0]!=v[2]) cout << "Yes" << endl;
	else if(v[1]==v[2]&&v[0]!=v[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    bool ok=false;
    rep(i,s.size()){
        if(s[i]=='7')ok=true;
    }
    cout<<(ok==true?"Yes":"No")<<endl;
}


Measured memory_bytes: 3628