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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<int>& as, const vector<int>& bs)
{
    vector<int> ra(N), rb(N);
    ll ans = 0;

    for (int i = 0; i <= 28; ++i)
    {
        int T = (1 << i);
#ifdef DEBUG
    cout << "=== i = " << i << ", T = " << T << endl;
#endif

        for (int i = 0; i < N; ++i)
            ra[i] = as[i] % (2*T);

        for (int i = 0; i < N; ++i)
            rb[i] = bs[i] % (2*T);

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

#ifdef DEBUG
    cout << "    ra = ";
    for (auto a : ra)
        cout << a << ' ';
    cout << endl;
    cout << "    rb = ";
    for (auto b : rb)
        cout << b << ' ';
    cout << endl;
#endif

        // ai + bj tem o i-ésimo bit ligado se
        //
        //  1. T <= ai + bj < 2T
        //  2. 3T <= ai + bj < 4T
        ll count = 0;

        for (auto a : ra)
        {
            auto it = lower_bound(rb.begin(), rb.end(), T - a);
            auto jt = lower_bound(rb.begin(), rb.end(), 2*T - a);

            if (jt - it > 0)
                count += (jt - it);
#ifdef DEBUG
    cout << "-- a = " << a << ", size for [T, 2T) = " << jt - it << ", count = " << count << endl;
#endif

            it = lower_bound(rb.begin(), rb.end(), 3*T - a);
            jt = lower_bound(rb.begin(), rb.end(), 4*T - a);

            if (jt - it > 0)
                count += (jt - it);

#ifdef DEBUG
    cout << "-- a = " << a << ", size for [3T, 4T) = " << jt - it << ", count = " << count << endl;
#endif
        } 

        ans |= (count % 2 ? T : 0);
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> as(N), bs(N);

    for (int i = 0; i < N; ++i)
        cin >> as[i];

    for (int i = 0; i < N; ++i)
        cin >> bs[i];

    auto ans = solve(N, as, bs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3456
n,m = map(int,input().split())
A = list(map(int, input().split()))
BC = []
for i in range(m):
    b,c = map(int, input().split())
    BC.append([c,b])
A.sort()
BC=sorted(BC, key=lambda x :x[0])
BC.reverse()
ans = sum(A)
cnt=0
for i in range(m):
    for j in range(cnt,BC[i][1]+cnt):
        if BC[i][0]>A[j]:
            ans+=BC[i][0]-A[j]
            cnt+=1
            if j==n-1:
                print(ans)
                exit()
        else:
            break
print(ans)

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    while (1)
    {
        vector<int> a(4), b(4);
        rep(i, 4)
        {
            cin >> a[i];
        }

        rep(i, 4)
        {
            cin >> b[i];
            if (cin.eof())
                return 0;
        }

        int hit = 0, blow = 0;

        rep(i, 4)
        {
            if (a[i] == b[i])
            {
                hit++;
            }
            else if (find(ALL(a), b[i]) != a.end())
            {
                blow++;
            }
        }
        cout << hit << " " << blow << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(void){
  const string MINUSINF = "-";
  int N, M;
  cin >> N >> M;
  int A[M];
  string dp[11000]; // N本使った時の最大の数
  // dp[i] = dp[i-M]
  int cost[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  
  for(int i=0; i<M; i++) cin >> A[i];
  for(int i=0; i<N+1; i++) dp[i] = MINUSINF;
  dp[0] = "";
  
  for(int i=0; i<N+1; i++){
//    cout << "i: " << i << endl;
    for(int j=0; j<M; j++){
      if(i-cost[A[j]] < 0) continue;
      if(dp[i-cost[A[j]]] == MINUSINF) continue;
      
      string newVal;
      if(to_string(A[j]) > dp[i-cost[A[j]]]) newVal = to_string(A[j]) + dp[i-cost[A[j]]];
      else newVal = dp[i-cost[A[j]]] + to_string(A[j]);
      
      int csz = dp[i].size();
      int nsz = newVal.size();
      if(nsz > csz) dp[i] = newVal;
      else if(nsz == csz){
        if(newVal > dp[i]) dp[i] = newVal;
      }
//      cout << "i: " << i << ", j: " << j << ", dp[i]: " << dp[i] << endl;      
    }
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 31872
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;

int main()
{
    cin >> n;
    vector<int> v; 
    rep(i,1,n)
    {
        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    cout << v.back() - v.front() << endl;
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;
    if ((a&1) ==0 || (b&1) == 0) {
        cout << "No";
    } else {
        cout << "Yes";
    }
    cout << endl;
    return 0;
}



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

using namespace std;

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

    int n, tmp, n2;
    int cnt[200002];
    cin >> n;
    for(int i = 1;i <= n;++i) {
        cnt[i] = 0;
    }
    n2 = n - 1;
    while(n2--) {
        cin >> tmp;
        cnt[tmp]++;
    }
    for(int i = 1;i <= n;++i) {
        cout << cnt[i] << endl;
    }
}




Measured memory_bytes: 4324
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n, a;
    cin >> n >> a;
    vector<ll> x(n);
    REP(i, n){
        cin >> x.at(i);
    }

    vector<vector<ll>> dp(n + 1, vector<ll>(2501, 0));
    dp.at(0).at(0) = 1;
    dp.at(1).at(x.at(0)) = 1;
    for(ll i = 1; i < n; ++i){
        for(ll l = i; l >= 0; --l){
            for(ll v = 2500; v >= 0; --v){
                if(dp.at(l).at(v) == 0){ continue; }
                dp.at(l + 1).at(v + x.at(i)) += dp.at(l).at(v);
            }
        }
    }

    ll ans = 0;
    for(ll i = 1; i <= n; ++i){
        ans += dp.at(i).at(i * a);
    }
    cout << ans << endl;
    return 0;
}


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

int serch(int N){
    int maxN = 0;
    while(N){
    N = N / 10;
    maxN++;
    }
return maxN;
}

int main(void){
    int N;
    cin >> N;
    int maxN = serch(N);
    //if maxN == 0 then ans == N
    //0-9 100-999 10000-99999
    int ans;
    if(maxN == 1) ans = (N-0);
    if(maxN == 2) ans = (9-0);
    if(maxN == 3) ans = (9-0)+(N-100+1);
    if(maxN == 4) ans = (9-0)+(999-100+1);
    if(maxN == 5) ans = (9-0)+(999-100+1)+(N-10000+1);
    if(maxN == 6) ans = (9-0)+(999-100+1)+(99999-10000+1);
    cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  	int a,b,c;
	cin>> a >> b >> c;
  	if(a+b+c>=22){
      cout << "bust" << endl;     
    }
  	else if(a+b+c<22){
    	cout << "win" << endl;
    }
  return 0;
}


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

void solve() {
    double a, b, x; cin >> a >> b >> x;
    double t = x / a / a;
    double c = b - t;
    if(a * a * b > 2 * x) {
        auto isOK = [&](double d) -> bool {
            double r = (90 - d) * M_PI / 180.0;
            double s = b * tan(r);
            if(s > a) return true;
            double V = s * b * a / 2.0;
            return V >= x;
        };
        double l = 0, r = 90;
        rep(loop, 100)  {
            double mid = (l + r) / 2;
            if(isOK(mid)) l = mid;
            else r = mid;
        }
        printf("%.10lf\n", l);
    } else {
        auto isOK = [&](double d) -> bool {
            double r = d * M_PI / 180.0;
            double s = a * tan(r) / 2.0;
            return c >= s;
        };
        double l = 0, r = 90;
        rep(loop, 100)  {
            double mid = (l + r) / 2;
            if(isOK(mid)) l = mid;
            else r = mid;
        }
        printf("%.10lf\n", l);
    }
}

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


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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
	int n;cin>>n;
	vector<long long> A(n);
	rep(i,n){
		cin>>A[i];
	  }
	int ans = 0;
	rep(i,n){
	while(A[i]%2==0&&A[i]>=2){
		ans++;
		A[i]/=2;
	  }
	  }
	  cout<<ans<<endl;
	}


Measured memory_bytes: 384
#include <bits/stdc++.h>
//#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<double,double> P;
const ll INF = 1e16;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 



///////////////////////___modpow___////////////////////

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


signed main(){
  int a,b;cin>>a>>b;
  repd(i,1,10000){
    double aa = floor((double)i*1.08), bb = floor((double)i*1.1);
    if((int)aa-i == a && (int)bb-i == b){
      cout << i << endl;return 0;
    }
  }
  cout << -1 << endl;
}




Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n,k;
    cin>>n>>k;
    V vec;
    V dist(n,-1);
    vec.resize(n);
    rep(i,n){
        ll x;
        cin>>x;
        x--;
        vec[i]=x;
    }
    ll start;
    ll loop;
    ll cnt=0;
    ll now=0;
    ll s;
    while(1){
        if(dist[now]!=-1){
            s=now;
            start=dist[now];
            loop=cnt-dist[now];
            break;
        }
        dist[now]=cnt;
        cnt++;
        now=vec[now];
    }
    //cout<<start<<" "<<loop<<endl;
    if(k<start){
        ll temp=0;
        rep(i,k){
            temp=vec[temp];
        }
        cout<<temp+1<<endl;
    }else{
        k-=start;
        ll path=k%loop;
        ll temp=s;
       // cout<<path<<endl;
        //cout<<k<<endl;
        for(int i=0;i<path;i++){
            temp=vec[temp];
        }
        cout<<temp+1<<endl;
    }
}


Measured memory_bytes: 6368
using System.Linq;
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var result = GettingStarted.SortingThreeNumbers();
            System.Diagnostics.Trace.WriteLine(result);
            Console.WriteLine(result);
        }
    }

    public static class GettingStarted
    {
        public static string SortingThreeNumbers()
        {
            var input = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            foreach (var _ in Enumerable.Range(0, 2))
            {
                foreach (var i in Enumerable.Range(0, 2))
                {
                    if (input[i] > input[i + 1])
                    {
                        var g = input[i + 1];
                        input[i + 1] = input[i];
                        input[i] = g;
                    }
                }
            }

            return string.Join(" ", input.Select(i => i.ToString()).ToArray());
        }
    }
}

Measured memory_bytes: 5976
#include <bits/stdc++.h>
using namespace std;
 
// vector<int> vec(3); = vector<int> vec={0,0,0}
// vec.at()
// sort(num.begin(),num.end(), greater<int>());
// reverse(num.begin(),num.end());
// transform(a.begin(), a.end(), a.begin(), ::toupper);
 
// 切り上げ　a/b+1
//  1からNの総和　N*(N+1)/2
 
int main() {
  string a,b,c;
  cin >> a >> b >> c;
  char A, B, C;
  
	transform(a.begin(), a.end(), a.begin(), ::toupper);
	transform(b.begin(), b.end(), b.begin(), ::toupper);
	transform(c.begin(), c.end(), c.begin(), ::toupper);
  
  cout << a.at(0) << b.at(0) << c.at(0) << endl;
}

Measured memory_bytes: 256
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    A = il()
    sm = sum(A)
    mi = sm / (4*M)
    cnt = 0

    for a in A:
        if a >= mi: cnt += 1

    print('Yes' if cnt >= M else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
#else

#endif

const double eps = 1e-10;
const LL mod = 1000000007;


LL mcd(LL a, LL b) {
    if (a == 0 and b == 0) return 1;
    if (a == 0) return b;
    if (b == 0) return a;
    if (a < b) return mcd(b, a);
    return mcd(b, a%b);
}

struct Direction{
    LL x, y;

    int sign = 0;

    Direction(){}

    Direction (LL a, LL b) {
        if (b < 0) a = -a, b = -b;
        if (b == 0 and a < 0) a = -a;
        if (a <= 0) swap(a, b), b = -b, sign = 1;
        LL d = mcd(a, b);
        a /= d, b /= d;
        x = a, y = b; 
    }

    bool operator < (const Direction& other) const {
        if (x == other.x) return (y < other.y);
        return (x < other.x);
        //~ if (x > 0 and other.x > 0) return ((double)y/(double)x < (double)other.y/(double)other.x);
        //~ if (y > 0 and other.y > 0) return (-(double)x/(double)y < -(double)other.x/(double)other.y);
        //~ return (x < other.x);
    }

    bool operator == (const Direction& other) const {
        return (x == other.x and y == other.y);
        //~ return ((double)y/(double)x - (double)other.y/(double)other.x) < eps;
    }
};


LL esp(LL x, LL e) {
    if (e == 0) return 1;
    if (e % 2 == 1) return (x*esp(x,e-1))%mod;
    return esp(x*x%mod, e/2);
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Togliere nei problemi con query online

    int N;
    cin >> N;

    vector<Direction> dirs(N);
    
    for (int i = 0; i < N; i++) {
        LL A, B;
        cin >> A >> B;
        dirs[i] = Direction(A, B);
    }
    vector<int> zeros, nonz;
    for (int i = 0; i < N; i++) {
        if (dirs[i].x == 0 and dirs[i].y == 0) zeros.push_back(i);
        else nonz.push_back(i);
    }
    sort(nonz.begin(), nonz.end(), [&](int i, int j){return dirs[i] < dirs[j];});

    int at = 0;
    LL res = 1;
    while (at < (int)nonz.size()) {
        int bt = at;
        LL u = 0, v = 0;
        //~ cout << "blocco\n";
        while (bt < (int)nonz.size() and dirs[nonz[bt]] == dirs[nonz[at]]) {
            //~ cout << dirs[nonz[bt]].x << " " << dirs[nonz[bt]].y << endl;
            if (dirs[nonz[bt]].sign == 0) {
                //~ cout << "sign 0\n";
                u++;
            }
            else v++;
            bt++;
        }
        //~ cout << "u, v: " << u << " " << v << endl;
        at = bt;
        LL at_res = (esp(2, u) + esp(2, v) - 1) % mod;
        //~ cout << at_res << endl;
        res = (res * at_res) % mod;
    }
    res--;
    res += (int)zeros.size();
    res += mod;
    res %= mod;
    cout << res << endl;
    
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n, k; cin >> n >> k;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int h; cin >> h;
        if(k <= h) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3540
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
ll dp[105][4][4][4];
// A C T G

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

    int n;
    cin >> n;

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                if (k == 0 && j == 3 && i == 1) continue; // AGC
                if (k == 0 && j == 1 && i == 3) continue; // ACG
                if (k == 3 && j == 0 && i == 1) continue; // GAC
                dp[3][i][j][k] = 1;
            }
        }
    }

    for (int i = 4; i <= n; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                for (int l = 0; l < 4; l++) {
                    for (int x = 0; x < 4; x++) {
                        if (x == 1 && l == 3 && k == 0) continue; // AGC
                        if (x == 3 && l == 1 && k == 0) continue; // ACG
                        if (x == 1 && l == 0 && k == 3) continue; // GAC
                        if (x == 1 && k == 3 && j == 0) continue; // AG?C
                        if (x == 1 && l == 3 && j == 0) continue; // A?GC

                        (dp[i][x][l][k] += dp[i-1][l][k][j]) %= MOD;
                    }
                }
            }
        }
    }

    ll ans = 0;
    for (int j = 0; j < 4; j++) {
        for (int k = 0; k < 4; k++) {
            for (int l = 0; l < 4; l++) {
                (ans += dp[n][j][k][l]) %= MOD;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    string s;
    cin>>s;
    int w=count(s.begin(),s.end(),'W'),r=n-w,wc=0;
    for(i=0;i<n;i++)
    {
        int c=0;
        if(s[i]=='W')
        {
            for(int j=n-1;j>=i;j--)
            {
                if(s[j]=='R')
                {
                    wc++;swap(s[i],s[j]);c=1;break;
                }

            }
            if(c==0)
                break;
        }
    }
    cout<<min(w,min(r,wc));

}



Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll x,k,d;
	scanf("%lld%lld%lld",&x,&k,&d);
	x=abs(x);
	ll m=x%d;
	ll t=x/d;
	if(k<t)
	{
		printf("%lld\n",x-d*k);
	}
	else
	{
		if(k==t)printf("%lld\n",m);
		else
		{
			if((k-t)%2==0)printf("%lld\n",m);
			else printf("%lld\n",min(abs(m-d),abs(m+d)));
		}
	}
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
vector<int> g[2002];
bool vis[2002];
int D[2002];
void dfs(int u, int d){
    vis[u] = 1;
    D[u] = d;
    for(int i=0;i<g[u].size();i++){
        int v = g[u][i];
        if(vis[v]) continue;
        dfs(v, d+1);
    }
}
int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i=1;i<=n-1;i++){
        int a, b;
        scanf("%d%d", &a, &b);
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    if(k%2 == 0){
        int ans = 1e9;
        for(int i=1;i<=n;i++){
            memset(vis, 0, sizeof(vis));
            dfs(i, 0);
            int res = 0;
            for(int j=1;j<=n;j++){
                if(D[j] > k/2) res++;
            }
            ans = min(ans, res);
        }
        printf("%d\n", ans);
    }
    else{
        int ans = 1e9;
        for(int i=1;i<=n;i++){
            for(int j=0;j<g[i].size();j++){
                memset(vis, 0, sizeof(vis));
                int u = i, v = g[i][j];
                vis[u] = 1, vis[v] = 1;
                dfs(u, 0);
                dfs(v, 0);
                int res = 0;
                for(int j=1;j<=n;j++){
                    if(D[j] > k/2) res++;
                }
                ans = min(ans, res);
            }
        }
        printf("%d\n", ans);
    }
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long sum = 0;
    for(int a=1; a<=n; a++){
        for(int b=1; b<=n; b++){
            if(a*b < n){
                sum++;
            }
            else{
                break;
            }
        }
    }
    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  while (tn--) {
    int x0, y0, x1, y1, w, h;
    cin >> x0 >> y0 >> w >> h;
    x1 = x0 + w;
    y1 = y0 + h;

    int n;
    cin >> n;

    int count = 0;

    while (n--) {
      int x, y;
      cin >> x >> y;
      if (x0 <= x && x <= x1 && y0 <= y && y <= y1) count++;
    }

    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	string a; cin>>a;
	ll n=a.length();
	ll ans=0;
	ll s=0;
	for (ll x=0;x<n;x++) {
		if (a[x]=='S') s++;
		else {
			if (s>0) {s--; ans++;}
		}
	}
	printf("%lld\n",n-ans*2);
}

Measured memory_bytes: 720
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n;
  cin>>n;
  long long int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  sort(a,a+n);
  int min=0,min1=0;
  while(a[n-2]!=0)
  {
    for(int i=min+1;i<n;i++)
    {
      a[i]=a[i]%a[min];
      if(a[i]==0)
      {
        min1++;
      }
    }
    min=min1;
    sort(a,a+n);
  }
  cout<<a[n-1];
  return 0;
}

Measured memory_bytes: 1024
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;
const int MOD=1e9+7;

int main()
{
    ll n,ans=1;
    in n;

    for(ll i=1;i<n+1;++i)
    {
        ans*=i;
        ans%=MOD;
    }
    cout<<ans<<endl;
}


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

int main() {
    int N[100][100];
    int n;
    int u, k, v;
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            N[i][j] = 0;
        }
    }
    
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        if (k != 0) {
            for (int j = 0; j < k; j++) {
                cin >> v;
                N[u-1][v-1] = 1;
            }
        }
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j) cout << " ";
            cout << N[i][j];
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3108
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  std::map<std::string, int> m;
  int N; std::cin >> N;
  for (int i = 0; i < N; ++i) {
    std::string S; std::cin >> S;
    m[S]++;
  }

  int vmax = 0;
  for (const auto& p : m) {
    vmax = std::max(vmax, p.second);
  }

  for (const auto& p : m) {
    if (p.second == vmax) std::cout << p.first << std::endl;
  }
}


Measured memory_bytes: 25216
module.exports=function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){i(1)(i(3).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(t,e,i){var n=i(2);t.exports=function(t){for(var e=t[0].split(" "),i=Number(e[0]),r=Number(e[1]),s=[],o=0,u=new n(1e3),d=0;d<i;d++){for(var f=t[d+1].split(""),l=0;l<r;l++)"#"==f[l]?u.enq({x:l,y:d,dist:0}):o+=1;s.push(f)}for(;u.size>0;){var c=u.deq();if("."==s[c.y][c.x]||0==c.dist){if("."==s[c.y][c.x]&&(s[c.y][c.x]="#",o-=1),o<=0)return void console.log(c.dist);c.x+1<r&&"#"!=s[c.y][c.x+1]&&u.enq({x:c.x+1,y:c.y,dist:c.dist+1}),c.x-1>=0&&"#"!=s[c.y][c.x-1]&&u.enq({x:c.x-1,y:c.y,dist:c.dist+1}),c.y+1<i&&"#"!=s[c.y+1][c.x]&&u.enq({x:c.x,y:c.y+1,dist:c.dist+1}),c.y-1>=0&&"#"!=s[c.y-1][c.x]&&u.enq({x:c.x,y:c.y-1,dist:c.dist+1})}}}},function(t,e,i){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;this.size=0,this.items=[],this.ind=0,this.maxGap=t}enq(t){this.size+=1,this.items.push(t),this.items.size-this.ind>this.maxGap&&(this.items=this.items.slice(this.ind))}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}}},function(t,e){t.exports=require("fs")}]);

Measured memory_bytes: 200640
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();
      int K = sc.nextInt();
      int[] A = new int[N];
      int[] B = new int[M];
      long[] Atotal = new long[N+1];
      long[] Btotal = new long[M+1];
      int Amax = -1;
      int Bmax = -1;
      
      Atotal[0] = 0;
      for(int i = 0; i < N+1; i++){
        if(i < N){
          A[i] = sc.nextInt();
        }
        if(i > 0){
          Atotal[i] = Atotal[i-1] + A[i-1];
          if(Amax == -1 && Atotal[i] > K){
            Amax = i-1;
          }
        }
      }
      if(Amax == -1){
        Amax = N;
      }
      
      Btotal[0] = 0;
      B[0] = sc.nextInt();
      for(int i = 1; i < M+1; i++){
        if(i < M){
          B[i] = sc.nextInt();
        }
        if(i > 0){
          Btotal[i] = Btotal[i-1] + B[i-1];
          if(Bmax == -1 && Btotal[i] > K){
            Bmax = i-1;
          }
        }
      }
      if(Bmax == -1){
        Bmax = M;
      }
      
      // 全部読み切れるか
      int result = 0;
      if(Atotal[N] + Btotal[M] <= K){
        result = N+M;
      }else if(Amax == 0 && Bmax == 0){
        // 1冊も読めないか
        result = 0;
      }else{
        long totalTime = 0;
        int totalMax = 0;
        if(Amax > Bmax){
          totalMax = Amax;
        }else{
          totalMax = Bmax;
        }
        
        for(int i = 0; i <= Amax; i++){
          for(int j = totalMax - i; j <= Bmax; j++){
            totalTime = Atotal[i] + Btotal[j];
            if(totalTime <= K){
              //System.out.println(i + " " + j + " " + totalTime);
              
              int max = i+j;
              if(totalMax < max){
                totalMax = max;
              }
            }else{
              break;
            }
          }
        }
        result = totalMax;
      }
      
      // 出力
      //System.out.println(Amax);
      //System.out.println(Bmax);
      System.out.println(result);
    }
    

}

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

int main()
{
	int iN, Temp;
	int iNum[3], iTrueFlag[1000];

	cin >> iN;

	for( int i=0; i<iN; i++ ){
		cin >> iNum[0] >> iNum[1] >> iNum[2];

		for( int j = 0; j < 3; j++ ){
			for( int k = j + 1; k < 3; k++ ){
				if( iNum[j] > iNum[k] ){
					Temp    = iNum[j];
					iNum[j] = iNum[k];
					iNum[k] = Temp;
				}
			}
		}

		if( (iNum[0] * iNum[0]) + (iNum[1] * iNum[1]) == (iNum[2] * iNum[2]) ) iTrueFlag[i] = 1;
		else																   iTrueFlag[i] = 0;

	}

	for( int i=0;i<iN;i++ ){
		if( iTrueFlag[i] == 1 ) cout << "YES" << endl;
		else				    cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl 	"\n"

typedef vector< ll > 	vi;
typedef vector< vi > 	vvi;
typedef pair< ll,ll > 	ii;
#define pb 		push_back
#define all(c) 		(c).begin(),(c).end()
#define tr(c,i) 	for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) 	((c).find(x) != (c).end())

#define MOD 	1000000007
#define INF 	(int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

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

	ll n;
	cin>>n;
	string s;
	cin>>s;
	if(n < 3200)
		cout<<"red";
	else cout<<s;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b > c+d)cout << "Left" << endl;
  if(a+b == c+d)cout << "Balanced" << endl;
  if(a+b < c+d)cout << "Right" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int n;
using namespace std;
int ask(int x) {
	char s[10];
	printf("%d\n",x);
	fflush(stdout);
	scanf(" %s",s);
	fflush(stdin);
	if(s[0]=='M') return 0;
	if(s[0]=='F') return 1;
	return 2;
}
int main() {
	int l,r,x,t,val;
	scanf("%d",&n);
	fflush(stdin);
	l = 1; r = n-1;
	val = ask(0);
	while(1) {
		x = (l+r)/2;
		t = ask(x);
		if(t==2) return 0;
		if(x&1) {
			if(val==t) r = x-1;
			else l = x+1;
		}
		else {
			if(val==t) l = x+1;
			else r = x-1;
		}
	}
}


Measured memory_bytes: 852
N,K = list(map(int,input().split()))

h_list = [int(input()) for i in range(N)]

sorted_li = sorted(h_list)
min_a = 10**10
for i in range(N-K+1):
    a = sorted_li[i+K-1]-sorted_li[i]
    min_a = [min_a,a][a < min_a]
print(min_a)

Measured memory_bytes: 8204
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	if(a+b==15){
        	System.out.println("+");
        }else if(a*b==15){
        	System.out.println("*");
        }else{
        	System.out.println("x");
        }
    }
}

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

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n;
	cin >> n;
	ll x[n], l[n];
	zep(i, 0, n){
		cin >> x[i] >> l[i];
	}
	
	vector<P> v;
	zep(i, 0, n){
		v.push_back(P(x[i]+l[i], x[i]-l[i]));
	}
	sort(v.begin(), v.end());
	
	ll ans = 0;
	ll at = -INF;
	zep(i, 0, n){
		ll left = v[i].second;
		ll right = v[i].first;
		if(left >= at){
			ans++;
			at = right;
		}
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll INF = 1000000000000000000LL;

bool solve(ll b, ll N, ll S){
  ll sum = 0;
  while(N>0){
    sum += N%b;
    N/=b;
  }
  return S == sum;
}


int main(){
  ll N, S;
  cin >> N >> S;

  if(S > N){
    cout << -1 << endl;
    return 0;
  }
  if(S == N){
    cout << N+1 << endl;
    return 0;
  }

  ll SQRTN = sqrt(N)+5;
  
  // 3桁以上の範囲
  REP(b,2,SQRTN){
    if(solve(b, N, S)){
      cout << b << endl;
      return 0;
    }
  }
  
  // 2桁
  ll ret = INF;
  REP(p,1,SQRTN){
    ll b = (N-(S-p))/p;
    if(b<=1) continue;
    if(solve(b, N, S)){
      ret = min(ret, b);
    }    
  }

  if(ret == INF) cout << -1 << endl;
  else cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[123456];
int main(){
    int n;
    scanf("%d",&n);
    int h=0,s=0,k=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]%4==0) h++;
        else if(a[i]%2==0) s++;
        else k++;
    }
    if(h>=k){
        puts("Yes");
    } else {
        if(s==0){
            if(h+1>=k){
                puts("Yes");
            } else {
                puts("No");
            }
        } else {
            n-=(2*h);
            n-=s;
            if(n>0){
                puts("No");
            } else {
                puts("Yes");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    ll N, M;
    cin >> N >> M;
    vector<ll> Pref(M), Year(M);
    vector<vector<int>> pref_year(N+1);  // 県ごとの誕生年を管理する
    REP(i, M) {
        cin >> Pref[i] >> Year[i];
        pref_year[Pref[i]].push_back(Year[i]);
    }
    
    // calculation
    // 各県の誕生年をソート
    map<ll, ll> year_rank;
    REPN(i, N) {
        sort(pref_year[i].begin(), pref_year[i].end());
        for (ll j = 0; j < pref_year[i].size(); ++j) {
            year_rank[pref_year[i][j]] = j + 1;
        }
    }
    
    REP(i, M) {
        cout << zero_pad(6) << Pref[i] << zero_pad(6) << year_rank[Year[i]] << "\n";
    }
    
    return 0;
}


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

int BusStop[] ={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};
int Offset[]={0,13,11,9,7,5};
vector<int> Result1, Result2;
	
int main(void){
    int n,start,end,i,j;
    
    cin>>n;
    while(n--){
        cin>>start>>end;
        Result1.clear();
        Result2.clear();
        if(start>5 || start==0){	//0 || 6:9
			for(int i=start; BusStop[i%15]!=end; i++){
				cout<<BusStop[i%15]<<" ";
			}
		}else{
			int i=start, j=start+Offset[i]; 
			while(1){
				if(BusStop[i%15] == end){
					for(int k=0; k<Result1.size(); k++){
						cout<<Result1[k]<<" ";
					}
					break;
				}
				if(BusStop[j%15] == end){
					for(int k=0; k<Result2.size(); k++){
						cout<<Result2[k]<<" ";
					}
					break;
				}
				Result1.push_back(BusStop[i%15]);
				Result2.push_back(BusStop[j%15]);
				i++;
				j++;
			}
		}
		cout<<end<<endl;
    }
	
    return 0;
}


Measured memory_bytes: 3116
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;

class Sobaya
{
    static void Main(){
      new Sobaya().calc();
      return;
    }
      
    Scanner cin;
    
    void calc(){
        cin = new Scanner();
        int n = cin.nextInt();
        int[] std = cin.ArrayInt(n);
        Array.Sort(std);
        
        Console.WriteLine(string.Join(" ",std[n/2]-std[n/2 -1]));
    }
}




class Scanner
{
    string[] s;
    int i;
 
    char[] cs = new char[] { ' ' };
 
    public Scanner()
    {
        s = new string[0];
        i = 0;
    }
 
    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }
 
    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }
 
    public long nextLong()
    {
        return long.Parse(next());
    }
 
    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }
 
    public double nextDouble()
    {
        return double.Parse(next());
    }
 
 
    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 19240
fn a() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    let pattern = input.trim_right();

    for c in pattern.chars() {
        if c.is_ascii_lowercase() {
            println!("a");
        }
        else {
            println!("A");
        }
    }
}

fn main() {
    a();
}


Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    vector<int> a(9);
    for(int i = 0; i < 9; i++) {
        cin >> a[i];
    }
    bool w=false,x=false;
    if(a[1]-a[0]==a[4]-a[3] && a[4]-a[3]==a[7]-a[6]) w=true;
    if(a[1]-a[2]==a[4]-a[5] && a[4]-a[5]==a[7]-a[8]) x=true;

    if(w && x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int h, w;
	cin >> h >> w;

	vector<string>s(h);

	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

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


	int maxd = 0;

	
	queue<P>que;

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			vector<vector<int>>d(h, vector<int>(w, -1));
			if (s[i][j] == '.') {
				que.push(P(i, j));
				d[i][j] = 0;
				while (que.size()) {
					P p = que.front(); que.pop();
					for (int i = 0; i < 4; i++) {
						int nx = p.first + dx[i];
						int ny = p.second + dy[i];

						if (0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] != '#' && d[nx][ny] == -1) {
							que.push(P(nx, ny));
							d[nx][ny] = d[p.first][p.second]+1;
							maxd = max(maxd, d[nx][ny]);
						}

					}
				}


			}
			

		}
	}

	cout << maxd << endl;

	return 0;

}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
        mut aa: [i128; n]
    }
    aa.sort();
    let mut ans = 1;
    for i in 0..n {
        let a = aa[i];
        ans *= a;
        if ans == 0 {
            println!("0");
            return;
        }
        if ans > 10i128.pow(18) {
            println!("-1");
            return;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6116
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int n,m,res = 0;
int a[20][20] = {};

void dfs(int i,vector<bool> f){
    
    bool F = true;
    for(int j = 0; j < n; j++)
        if(!f[j]) F = false;
    if(F) res++;
    
    for(int j = 0; j < n; j++){
        if(a[i][j] && !f[j] ){
            f[j] = true;
            dfs(j,f);
            f[j] = false;
        }
    }
    
}

void solve(){
    vector<bool> f(n);
    f[0] = true;
    dfs(0,f);
}


int main(void){
    
    cin >> n >> m;
    
    for(int i = 0; i < m; i++){
        int b,c;
        cin >> b >> c;
        b--;c--;
        a[b][c] = 1;
        a[c][b] = 1;
    }
    
    solve();
    
    cout << res << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, k;
    cin >> n >> k;
    vector<lint> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    vector<lint> neg, pos;
    lint zero = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] < 0)
            neg.push_back(-a[i]);
        else if (a[i] > 0)
            pos.push_back(a[i]);
        else
            zero++;
    }
    lint np = pos.size(), nn = neg.size();
    sort(neg.begin(), neg.end());
    lint ok    = 1e18;
    lint ng    = -1e18;
    auto check = [&](lint mid) {
        lint cnt = 0;
        if (mid >= 0) {
            for (int i = 0; i < np; ++i) {
                cnt += upper_bound(pos.begin(), pos.end(), mid / pos[i]) - pos.begin();
                if (pos[i] * pos[i] <= mid)
                    cnt--;
            }
            for (int i = 0; i < nn; ++i) {
                cnt += upper_bound(neg.begin(), neg.end(), mid / neg[i]) - neg.begin();
                if (neg[i] * neg[i] <= mid)
                    cnt--;
            }
            cnt /= 2;
            cnt += nn * np;
        } else {
            for (int i = 0; i < np; ++i) {
                cnt += neg.end() - lower_bound(neg.begin(), neg.end(), (abs(mid) + pos[i] - 1) / pos[i]);
            }
        }
        cnt += mid < 0 ? 0 : zero * (n - zero) + zero * (zero - 1) / 2;
        return cnt >= k;
    };
    while (abs(ok - ng) != 1) {
        lint mid               = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    cout << ok << "\n";
    return 0;
}

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bit(n) (1LL<<(n))
// functions
template <typename T> void unique(T& c){c.erase(std::unique(c.begin(), c.end()), c.end());}
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;

using ld = long double;

int main(int argc, char const* argv[])
{
  ld L; cin >> L;
  ld res = (L / 3.) * (L / 3.) * (L / 3.);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256