akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int s = 0;
  rep(i,n) s += a[i];
  int cnt = 0;
  rep(i,n) {
    if (a[i]*(4*m) >= s) cnt++;
  }
  if (cnt >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static long MOD = (long)Math.pow(10, 9) + 7;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    long[][] dp = new long[b - a + 1][n + 1];
    long[] kai = new long[n + 1];
    kai[0] = 1;
    for(int i = 1; i <= n; i++) {
      kai[i] = (kai[i - 1] * (long)i) % MOD;
    }
    dp[0][0] = 1;
    for(int j = c; j <= Math.min(d, (n / a)); j++) {
      int t = a * j;
      dp[0][t] = (kai[n] * func(kai[n - t], MOD - 2)) % MOD;
    //  dp[0][t] = (dp[0][t] * func(n - t, MOD - 2)) % MOD;
      dp[0][t] = (dp[0][t] * func(kai[a], (long)j * (MOD - 2))) % MOD;
      dp[0][t] = (dp[0][t] * func(kai[j], MOD - 2)) % MOD;  
    }
    /**
    long[] inv = new long[n + 1];
    for(int i = 0; i <= n; i++) {
      inv[i] = func(kai[i], MOD - 2);
    } */
    long[][] inv = new long[n + 1][d + 1];
    for(int i = 0; i <= n; i++) {
      for(int j = 0; j <= d; j++) {
        inv[i][j] = func(kai[i], (long)j * (MOD - 2));
      }
    }
    for(int i = 1; i < (b - a + 1); i++) {
      dp[i][0] = 1;
      for(int j = 1; j <= n; j++) {
        dp[i][j] = dp[i - 1][j];
        for(int k = c; k <= Math.min(d, j / (i + a)); k++) {
          int s = (i + a) * k;
          long t = (dp[i - 1][j - s] * kai[n - j + s]) % MOD;
          t = (t * inv[n - j][1]) % MOD;
          t = (t * inv[i + a][k]) % MOD;
          t = (t * inv[k][1]) % MOD;
          /**
          t = (t * func(kai[n - j], MOD - 2)) % MOD;
          t = (t * func(kai[i + a], (long)k * (MOD - 2))) % MOD;
          t = (t * func(kai[k], MOD - 2)) % MOD;
          */
          dp[i][j] = (dp[i][j] + t) % MOD;
        }
      }
    } 
    System.out.println(dp[b - a][n]);
  }

  public static long func(long a, long x) {
    if(x == 0) return 1;
    if((x % 2) == 0) {
      long t = func(a, x / 2);
      return (t * t) % MOD;
    } else {
      long t = func(a, x - 1);
      return (a * t) % MOD;
    }
  }
}

Measured memory_bytes: 52052
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

int n;
vector<pair<int, int> > es[10001];
vector<int> d(10001);
vector<int> c(10001);

bool cmp(pair<int, int> a, pair<int, int> b) {
    return a.first < b.first;
}

priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > q;

int MX = INT_MAX / 3;

void dijkstra() {
    for (int i = 0; i < n; ++i) {
        d[i] = MX;
        c[i] = 0;
    }
    q.push(make_pair(0, 0));
    d[0] = 0;

    while(!q.empty()) {
        auto next = q.top(); q.pop();
        if(next.first > d[next.second]) continue;

        c[next.second] = 1;
        for (auto v : es[next.second]) {
            if(d[next.second] + v.first < d[v.second] && c[v.second] == 0) {
                d[v.second] = d[next.second] + v.first;
                q.push(make_pair(d[v.second], v.second));
            }
        }
    }

}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            int v, c;
            cin >> v >> c;
            es[i].push_back(make_pair(c, v));
        }
    }
    dijkstra();

    for (int l = 0; l < n; ++l) {
        cout << l << " " << d[l] << endl;
    }

    return 0;
}



Measured memory_bytes: 8148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<PP,vector<PP>,greater<PP>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
ll gcd(ll a,ll b){
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}
int main(){
  ll a,b;cin>>a>>b;
  cout<<a*b/gcd(a,b)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	int n = Read(), m = Read();
	if (n == 1)
	{
		while (m --)
			printf("%d\n", min(Read(), Read()));
		return 0;
	}
	while (m --)
	{
		int a = Read(), b = Read();
		while (a ^ b)
		{
			if (a < b)
				swap(a, b);
			a = (a + n - 2) / n;
		}
		printf("%d\n", a);
	}
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[1010];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	cout << a[0]-a[n-1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
using namespace std;

vector<int> gowland = {1,4,1,4,1,2,1,2};

int main() {
    vector<int> p(8);
    while (cin >> p[0]) {
        for (int i=1; i<8; ++i) {
            cin >> p[i];
        }
        vector<int> ans;
        int mn = INT_MAX;
        for (int k=0; k<8; ++k) {
            int cnt = 0;
            for (int i=0; i<8; ++i) {
                cnt += max(0, p[i] - gowland[i]);
            }
            if (cnt < mn || (cnt == mn && gowland < ans)) {
                ans = gowland;
                mn = cnt;
            }
            rotate(gowland.begin(), gowland.begin()+1, gowland.end());
        }
        for (int i=0; i<(int)ans.size(); ++i) {
            cout << (i == 0 ? "" : " ") << ans[i];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#include<iostream>

using namespace std;

typedef long long int ll;
const long long MOD = (long long)1e9 + 7;

ll dp[101][4][4][4];

bool is_ng(int a, int b, int c, int d){
    if(b == 0 && c == 1 && d == 2){return true;}//*AGC
    if(b == 0 && c == 2 && d == 1){return true;}//*ACG
    if(b == 1 && c == 0 && d == 2){return true;}//*GAC
    if(a == 0 && c == 1 && d == 2){return true;}//A*GC
    if(a == 0 && b == 1 && d == 2){return true;}//AG*C
    return false;
}

int main(){
    int n;
    cin >> n;
    dp[0][3][3][3] = 1;
    for(int i = 0; i < n; i++){
        for(int w = 0; w < 4; w++){
            for(int x = 0; x < 4; x++){
                for(int y = 0; y < 4; y++){
                    for(int z = 0; z < 4; z++){
                        if(is_ng(w, x, y, z)) continue;
                        dp[i + 1][x][y][z] += dp[i][w][x][y];
                        dp[i + 1][x][y][z] %= MOD;
                    }
                }
            }
        }
    }
    ll ans = 0;
    for(int x = 0; x < 4; x++){
        for(int y = 0; y < 4; y++){
            for(int z = 0; z < 4; z++){
                ans += dp[n][x][y][z];
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int C;
  if (A>B) {
    C = A;
    cout << C+C-1 << endl;
  }
  else if (A<B){
    C = B;
    cout << C+C-1 << endl;
  }
  else {
    cout << A+B << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);std::cout<<std::fixed<<std::setprecision(10);
    int N;
    cin >> N;
    vector<double> A(N);
    REP(i,N)cin >> A[i];
    sort(A.begin(),A.end());
    double total = A[0];
    REP(i,N-1){
        total = (A[i+1] + total)/2;
    }
    cout <<total<< "\n";
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

def sieve(n):
    count = [i for i in range(n+1)]
    count[0] = 0

    for i in range(1, n+1):
        j = 2 * i
        while j <= n:
            count[j] += j
            j += i
    return count

N = ii()
l = sieve(N)
#print(l)
#print(sum([l[i] * i for i in range(1, N+1)]))
print(sum(l))

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline void chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
}

template <class T1, class T2>
inline void chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

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

    int max_num = 0;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
        chmax(max_num, A[i]);
    }

    vector<int> prime(max_num + 1, 0);

    for (int i = 2; i < max_num + 1; ++i) {
        if (prime[i] == 0) {
            for (int j = i; j <= max_num + 1; j += i) {
                if (prime[j] == 0) {
                    prime[j] = i;
                }
            }
        }
    }

    vector<int> s(max_num + 1, 0);
    for (int i = 0; i < N; ++i) {
        int num = A[i];
        set<int> tmp;
        while (num != 1) {
            tmp.emplace(prime[num]);
            num /= prime[num];
        }
        for (auto x : tmp) {
            ++s[x];
        }
    }

    bool is_pairwise = true;
    for (auto x : s) {
        if (x == N) {
            cout << "not coprime" << endl;
            return 0;
        } else if (x > 1) {
            is_pairwise = false;
        }
    }
    if (is_pairwise) {
        cout << "pairwise coprime" << endl;
    } else {
        cout << "setwise coprime" << endl;
    }
}


Measured memory_bytes: 14732
import java.util.*;

public class Main {
    public static void main(String[] args) {
        final long DIV = 1000000007;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for(int i=0; i<n; i++){
            a[i] = sc.nextLong();
        }
        sc.close();

        long[] p = new long[n];
        long[] sump = new long[n+1];
        for(int i=0; i<n; i++){
            p[i] = inverseElement(i+1, DIV);
            sump[i+1] = sump[i] + p[i];
            sump[i+1] %= DIV;
        }

        long ans = 0;
        for(int i=0; i<n; i++){
            ans += a[i] * (sump[i-0+1] + sump[n-i] - p[0]);
            if(ans < 0) ans += DIV*DIV;
            if(ans > 0) ans %= DIV;
        }

        for(int i=0; i<n; i++){
            ans *= (i+1);
            ans %= DIV;
        }

        System.out.println(ans);
    }

    public static long inverseElement(long a, long n){
        long b = n, u=1, v=0;
        while(b > 0) {
            long t = a/b;
            a -= t*b;
            u -= t*v;
            //swap
            t = a;
            a = b;
            b = t;
            t = u;
            u = v;
            v = t;
        }
        u = u % n;
        if(u < 0) u += n;
        return u;
    }
}

Measured memory_bytes: 57992
import java.util.Scanner;

public class Main{
	public static int p, q, a, n;
	public static double pq;
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			p = in.nextInt();
			q = in.nextInt();
			a = in.nextInt();
			n = in.nextInt();
			if(n == 0) return;
			count = 0;
			pq = (double)p/q;
			dfs(0, 1, 0, 1);
			System.out.println(count);
		}
	}
	
	public static final double EPS = 1e-8;
	public static int count;
	// depth <= n
	// denom <= a
	// num/denom <= upper
	public static void dfs(long num, long denom, int depth, int start){
		if(depth > n) return;
		double now = (double) num/denom;
		if(Math.abs(now-pq) < EPS){
			count++;
			return;
		}
		if(now > pq) return;
		for(int i=start; (double)(n-depth)/i+now+EPS >= pq && i*denom <= a; i++){
			dfs(num*i + denom, denom*i, depth+1, i);
		}
	}
}

Measured memory_bytes: 23696
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll n, k; cin >> n >> k;
  vll p(n); rep(i, n) cin >> p[i];
  sort(all(p));
  ll ans = 0;
  rep(i, k)
  {
    ans += p[i];
  }
  fin(ans);
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[4];
	cin>>a[1]>>a[2]>>a[3];
	if(a[1]==a[3] || a[2]==a[3] || a[1]==a[2])
	{
		if(a[1]==a[2] && a[2]==a[3])cout<<"No";
		else cout<<"Yes";
	 } 
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

out=sum(B)

for i in range(N-1):
    if A[i]==A[i+1]-1:
        out+=C[A[i]-1]

print(out)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
 
using namespace std;
 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
 
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
 
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
 
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
 
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}
 


int a[4];


int main(){
  string t;
  cin >> t;
  rep(i,4) a[i] = t[i] - '0';
  string s;
  if(a[0]+a[1]+a[2]+a[3] == 7){
    s = to_string(a[0]) + '+' + to_string(a[1]) + '+' + to_string(a[2]) + '+' + to_string(a[3]) +  "=7";
    cout << s << endl;
  }
  else if(a[0]-a[1]+a[2]+a[3] == 7){
    s = to_string(a[0]) + '-' + to_string(a[1]) + '+' + to_string(a[2]) + '+' + to_string(a[3]) +  "=7";
    cout << s << endl;
  }
  else if(a[0]+a[1]-a[2]+a[3] == 7){
    s = to_string(a[0]) + '+' + to_string(a[1]) + '-' + to_string(a[2]) + '+' + to_string(a[3]) +  "=7";
    cout << s << endl;
  }
  else if(a[0]+a[1]+a[2]-a[3] == 7){
    s = to_string(a[0]) + '+' + to_string(a[1]) + '+' + to_string(a[2]) + '-' + to_string(a[3]) +  "=7";
    cout << s << endl;
  }
  else if(a[0]-a[1]-a[2]+a[3] == 7){
    s = to_string(a[0]) + '-' + to_string(a[1]) + '-' + to_string(a[2]) + '+' + to_string(a[3]) +  "=7";
    cout << s << endl;
  }
  else if(a[0]+a[1]-a[2]-a[3] == 7){
    s = to_string(a[0]) + '+' + to_string(a[1]) + '-' + to_string(a[2]) + '-' + to_string(a[3]) +  "=7";
    cout << s << endl;
  }
  else if(a[0]-a[1]+a[2]-a[3] == 7){
    s = to_string(a[0]) + '-' + to_string(a[1]) + '+' + to_string(a[2]) + '-' + to_string(a[3]) +  "=7";
    cout << s << endl;
  }
  else if(a[0]-a[1]-a[2]-a[3] == 7){
    s = to_string(a[0]) + '-' + to_string(a[1]) + '-' + to_string(a[2]) + '-' + to_string(a[3]) +  "=7";
    cout << s << endl;
  }
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        U_Grouping solver = new U_Grouping();
        solver.solve(1, in, out);
        out.close();
    }

    static class U_Grouping {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.ni();
            int[][] a = new int[n][];
            for (int i = 0; i < n; i++) {
                a[i] = in.na(n);
            }
            long[] sum = new long[1 << n];
            for (int mask = 1; mask < 1 << n; mask++) {
                for (int i = 0; i < n; i++) {
                    if ((mask & (1 << i)) != 0) {
                        for (int j = 0; j < i; j++) {
                            if ((mask & (1 << j)) != 0) {
                                sum[mask] += a[i][j];
                            }
                        }
                    }
                }
            }
            long[] dp = new long[1 << n];
            long ans = 0;
            for (int mask = 1; mask < 1 << n; mask++) {
                for (int submask = mask; submask > 0; submask = (submask - 1) & mask) {
                    int rest = mask ^ submask;
                    dp[mask] = Math.max(sum[submask] + dp[rest], dp[mask]);
                }
                ans = Math.max(dp[mask], ans);
            }
            out.println(ans);
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

        public int[] na(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = ni();
            return a;
        }

    }
}



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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector <double> d(n);
    double s = 0;
    for (int j = 0; j < n; j++) {
        cin >> d[j];
        s += d[j];
    }
    s /= n;
    double mn = 1e9;
    int i;
    for (int j = 0; j < n; j++) {
        if (mn > abs(d[j] - s)) {
            i = j;
            mn = abs(d[j] - s);
        }
    }
    cout << i;
}


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



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

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<char>> table(H, vector<char>(W));
  vector<bool> rows_have_black(H, false);
  vector<bool> columns_have_black(W, false);

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> table.at(i).at(j);
      if (table.at(i).at(j) == '#') {
        rows_have_black.at(i) = true;
        columns_have_black.at(j) = true;
      }
    }
  }

  for (int i = 0; i < H; i++) {
    if (rows_have_black.at(i)) {
      for (int j = 0; j < W; j++) {
        if (columns_have_black.at(j)) {
          cout << table.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define D(a) (double)(a)
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' '; cout<<endl;
#define PI acos(-1.0)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
#define rt return true
#define rf return false
///................function.....................///
#define siz(s) (int)(s.size())
#define mod 1000000007
#define dbg(a) cout << #a << " = " << a << " ";
int main()
{
    ///freopen("input.txt","r",stdin);
    ///freopen("input15.txt","w",stdout);
    int x;
    cin>>x;
    x^=1;
    cout<<x<<endl;
}


Measured memory_bytes: 3628
A = list()
for i in range(3):
  A.append([int(j) for j in input().split()])

N = int(input())
for i in range(N):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if b == A[j][k]:
        A[j][k] = 0

flg = 0
for i in range(3):
  if sum(A[i]) == 0:
    flg = 1
  if A[0][i]+A[1][i]+A[2][i] == 0:
    flg = 1
  
if A[0][0]+A[1][1]+A[2][2] == 0:
  flg = 1
if A[2][0]+A[1][1]+A[0][2] == 0:
  flg = 1

print("Yes" if flg==1 else "No")



Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


const int INF = 1e9 + 5;
const int N_MAX = 100;
const int V_MAX = 1000;

int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    int N, W;
    cin >> N >> W;
    vector<int> dp(N_MAX * V_MAX + 1, INF);
    dp[0] = 0;

    for (int i = 0; i < N; i++) {
        int w, v;
        cin >> w >> v;

        for (int tot = i * V_MAX; tot >= 0; tot--)
            dp[tot + v] = min(dp[tot + v], dp[tot] + w);
    }

    int ans = N_MAX * V_MAX;

    while (dp[ans] > W)
        ans--;

    cout << ans << '\n';
}


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

int main() {
	int n;
	cin >> n;
	int *b = new int[n];

	if(n % 2 == 0) {
		for(int i = 0; i < n / 2; i++) {
			cin >> b[n/2+i] >> b[n/2-1-i];
		}
	} else {
		cin >> b[n/2];
		for(int i = 0; i < n / 2; i++) {
			cin >> b[n/2+1+i] >> b[n/2-1-i];
		}
	}
	cout << b[0];
	for(int i = 1; i < n; i++) {
		cout << ' ' << b[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2944
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk)
{
  var x = chunk.split(" ");
  x[0] = Number(x[0])
  x[1] = Number(x[1])
  x[2] = Number(x[2])
  if ((x[0] < x[1]) && (x[1] < x[2])) {
    console.log("Yes")
  }else{
    console.log("No")
  }
});

Measured memory_bytes: 15488
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#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 vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

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

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

ll dp[18][2][2];

int main(void) {
	ll n; cin >> n;
	if(n%2){
		out(0);
		return 0;
	}

	ll ans = 0;
	ll num = n;
	ll md = 10;
	while(num/md){
		ans += num/md;
		md *= 5;
	}
	out(ans);
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		int[] q = new int[n];
		for(int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
			q[i] = sc.nextInt();
		}
		boolean flag = false;
		long ans = 0;
		for(int i = 0; i < n; i++) {
			if(flag) {
				if(i == n - 1)
					ans++;
				long temp = 0;
				for(int j = i + 1; j < n; j++) {
					if(p[j] < p[i]) {
						temp++;
					}
				}
				for(int j = 1; j < n - i; j++) {
					temp *= j;
				}
				ans += temp;
				temp = 0;
				for(int j = i + 1; j < n; j++) {
					if(q[j] > q[i]) {
						temp++;
					}
				}
				for(int j = 1; j < n - i; j++) {
					temp *= j;
				}
				ans += temp;
			} else {
				if(i == n - 1 && p[i] != q[i])
					ans++;
				if(p[i] != q[i]) {
					if(p[i] < q[i]) {
						int[] temp = q;
						q = p;
						p = temp;
					}
					flag = true;
					for(int j = i + 1; j < n; j++) {
						if(p[j] < p[i] && p[j] > q[i]) {
							ans++;
						}
					}
					for(int j = 1; j < n - i; j++) {
						ans *= j;
					}
				}
			}
		}
		System.out.println(ans);

	}

}


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

int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;cin>>n;
    ll sum=0;
    for(ll i=1;i<n;i++){
        sum+=(n-1)/i;
    }
    cout<<sum;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
  long int N, pairs=0, check;
  cin >> N ;
  long int A[N], B[N+1] ;
  for(int i=0;i<N+1;i++){
    B[i] = 0 ;
  }
  for(int i=0;i<N;i++){
    cin >> A[i] ;
    B[A[i]]++ ;
  }
  for(int i=0;i<N+1;i++){
    pairs += (B[i] * (B[i] - 1) / 2) ;
  }
  for(int i=0;i<N;i++){
    cout << (pairs - B[A[i]] + 1) << endl ;
  }
  return 0 ;
}

Measured memory_bytes: 5760
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    S = S[::-1]

    dp = [0] * 13
    dp[0] = 1
    p = 1

    for c in S:
        dp, dp_prev = [0] * 13, dp
        for k in range(13):
            if c == '?':
                for j in range(10):
                    dp[(p * j + k) % 13] = (dp[(p * j + k) % 13] + dp_prev[k]) % MOD
            else:
                dp[(p * int(c) + k) % 13] = (dp[(p * int(c) + k) % 13] + dp_prev[k]) % MOD

        p = p * 10 % 13

    print(dp[5])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 74032
# -*- coding: utf-8 -*-
import sys
N=int(sys.stdin.readline().strip())
A=[]
B=[]
for _ in range(N):
    a,b=map(int, sys.stdin.readline().split())
    A.append(a)
    B.append(b)

A=A[::-1]
B=B[::-1]

ans=0
t=0 #これまでの増分

for a,b in zip(A,B):
    a+=t
    if a%b!=0:
        t+=b-a%b
        ans+=b-a%b

print ans


Measured memory_bytes: 46364
N = int(input())
p = list(map(int,input().split()))
count = 0
F = True
for i in range(0,N):
    if p[i] != i+1:
        count += 1
    if count == 3:
        F = False
        break
if F:
    print("YES")
else:
    print("NO")



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

void fnInput(vector<int> &rvnSort)
{
  int nMaxSiz;
  
  cin >> nMaxSiz;
  rvnSort.resize(nMaxSiz);

  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnSort[i];
}

void fnBubbleSort(vector<int> &rvnSort, int &rnSortCnt)
{
  int nSorting = 0;
  bool bSorting = true;

  while (bSorting)
  {
    bSorting = false;
    for (int i = rvnSort.size() - 1; i > nSorting; i--)
    {
      if (rvnSort[i] < rvnSort[i - 1])
      {
        bSorting = true;
        swap(rvnSort[i], rvnSort[i - 1]);
        rnSortCnt++;
      }
    }
    nSorting++;
  }
}

void fnOutput(const vector<int> &cnrvnSort, int nSortCnt)
{
  for (int i = 0; i < cnrvnSort.size(); i++)
  {
    if (i) cout << " ";
    cout << cnrvnSort[i];
  }
  cout << endl;
  cout << nSortCnt << endl;
}
    
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int nSortCnt = 0;
  vector<int> vnSort;

  fnInput(vnSort);
  fnBubbleSort(vnSort, nSortCnt);
  fnOutput(vnSort, nSortCnt);

  return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll,ll>
#define pint pair<int,int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 100001
#define endl '\n'
#define mp make_pair
#define INF 1000000000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)			//counts no of ones in binary representation
#define w(t) 	int t; cin>>t; while(t--)
#define pi 3.141592653589793238
#define sortt(v)  sort(v.begin(),v.end())
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;
 

int main() {
	fast;
	ld a,b;
	cin>>a>>b;
	ld ans=a*b;
	ll ans2=floor(ans);
	cout<<ans2;
}




 

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/
int main(){
  int64_t n;
  cin >> n;
  vector<pair<int64_t,int64_t>> a(n);
  rep(i,n){
    cin >> a.at(i).first >> a.at(i).second ;
  }
  sort(a.begin(),a.end());
  cout << a.at(n-1).first + a.at(n-1).second << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()) {
			 
			String a = sc.nextLine();
			String b[] = a.split("\\s+");
			
			System.out.println(b[1]+b[0]);
			
			
		}
		
	}

}


Measured memory_bytes: 21588
n=int(input())
a=list(map(int,input().split()))

s=[0]*8
c=0
for ai in a:
    if ai<3200:
        s[ai//400]=1
    else:
        c+=1

ssum=sum(s)
if ssum==0:
    smin=1
else:
    smin=ssum
smax=ssum+c
print(str(smin)+" "+str(smax))



Measured memory_bytes: 3060
#include <cstdio>
using namespace std;
int N;
int a[100001];
int f,g;
int can;
int main(){
  scanf("%d",&N);
  for(int i=0;i<N;i++)scanf("%d",&a[i]);
  for(int i=0;i<N;i++){
    if(a[i]%2==0)f++;
    else g++;
  }

  if(g==0){
    if(f==0)can=0;
    else can=1;
  }
  else if(g==1){
    if(f==0)can=1;
    else can=0;
  }
  else if(g%2==0){
    can=1;
  }
  else{
    can=0;
  }
  if(can==1)printf("YES\n");
  else printf("NO\n");
  return 0;
}


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

int main() {
	int N, a, b, c, d;
	cin >> N;
	d = N / 1000;
	c = (N % 1000) / 100;
	b = (N % 100) / 10;
	a = N % 10;
	if (b != c) {
		cout << "No" << endl;
	}
	else if (c == d || b == a){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

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

int main()
{
   int n,x;
   double sum=0;
   cin>>n;
   int arr[n];
   for(int i=0;i<n;i++)
   {
       cin>>arr[i];
       sum+=arr[i];
   }
   int avg=sum/n;
  // cout<<avg;
   double avvg=sum/n;
   //cout<<avvg<<endl;
   double dif=avvg-avg;
   if(dif>0.5)
   {
       avvg=ceil(sum/n);
   }
   else
   {
       avvg=floor(sum/n);

   }
   int ans=0;
   for(int i=0;i<n;i++)
   {
       ans=ans+((arr[i]-avvg)*(arr[i]-avvg));
   }
   cout<<ans;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int counter[100010];
const int mod = 998244353;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> a(N);
  rep(i, N) {
    cin >> a[i];
    counter[a[i]+1]++;
  }

  if(a[0] != 0) {
    cout << 0 << endl;
    return 0;
  }
  long long ans = 1LL;
  rep(i, N) {
    if(i == 0) continue;
    (ans *= counter[a[i]]) %= mod;
  }
  cout << ans % mod << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const double pi=3.141592653585;
int main(){
	int a,b,x;
	double ans;
	scanf("%d%d%d",&a,&b,&x);
	int V=a*a*b;
	if(x*2<=V)
	{
		double l=(double)(a*b*b/2.0/x);
		ans=atan(l)*180.0/pi;
	}
	else{
		x=V-x;
		double l=(double)(2.0*x/a/a/a);
		ans=atan(l)*180.0/pi;
	}
	printf("%.10lf",ans);
	return 0;
} 

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
condition = True
for i in range(0, n - 3) :
    if a[i] == a[i + 1] :
        for j in range(i + 2, n - 1) :
            if a[j] == a[j + 1] :
                print(a[i] * a[j])
                break
        break
else :
    print(0)

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if((A-B-C) < 0)
    cout << abs(A-B-C) << endl;
  else
    cout << "0" << endl;
  return 0;
}


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

int main(void)
{
  int N, K;
  std::cin >> N >> K;

  std::vector<int> price(N);
  for (int i = 0; i < N; i++) {
    std::cin >> price.at(i);
  }

  std::sort(price.begin(), price.end());
  
  int sum = 0;
  for (int i = 0; i < K; i++) {
    sum += price.at(i);
  }

  std::cout << sum << std::endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  set<int>st;
  rep(i,3){
    int x;
    cin >> x;
    st.insert(x);
  }
  cout << st.size() << endl;

  return 0;
}


Measured memory_bytes: 3588
from collections import deque
import numpy as np


def bfs(i, j):
    queue = deque()
    queue.append((i, j))
    visited = [[0] * (w + 2) for _ in range(h + 2)]
    visited[i][j] = 1
    moves = [[0] * (w + 2) for _ in range(h + 2)]
    while queue:
        i, j = queue.popleft()
    
        next_points = (
            (i, j + 1),
            (i + 1, j),
            (i, j - 1),
            (i - 1, j)
        )
        
        for next_i, next_j in next_points:
            if not visited[next_i][next_j] and maze[next_i][next_j] == '.':
                queue.append((next_i, next_j))
                visited[next_i][next_j] = 1
                moves[next_i][next_j] = moves[i][j] + 1
    
    return moves


h, w = map(int, input().split())
end = '#' * (w + 2)
maze = [end]
for _ in range(h):
    s = input()
    maze.append('#' + s + '#')
maze.append(end)

max_move = 0
for i in range(1, h+1):
    for j in range(1, w+1):
        if maze[i][j] == '#':
            continue
        moves = np.array(bfs(i, j))
        max_move = max(max_move, np.max(moves))
        
print(max_move)

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

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

  for(int i = 0 ; i < s.size() - 1 ; i++)
  {
    if(s.at(i) == 'A' && s.at(i + 1) == 'C')
    {
      cout << "Yes" << endl ;
      return 0 ;
    }
  }

  cout << "No" << endl ;
}


Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{

  ll n,k;
  cin >> n >> k;

  double ans = 0;

  for(ll i = 1; i <= n; ++i)
  {
    ll cnt;
    ll buf = i;
    for(cnt = 0;;cnt++)
    {
      if(k <= buf)
      {
        break;
      }
      buf = buf * 2;
    }
    ans += 1.0 / n / pow(2,cnt);
  }

  cout << fixed << setprecision(10) << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  cout << s.substr(0,4) SP s.substr(4) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================
	

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;

int main()
{
	int n, m; cin >> n >> m;
	vector<int> x(m); rep(i, m)cin >> x[i];
	sort(all(x));
	vector<int> sa(m - 1); rep(i, m - 1)sa[i] = x[i + 1] - x[i];
	sort(all(sa));
	int sum = 0;
	rep(i, m - n)
		sum += sa[i];
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 1024
S = list(input())
ans1 = 0
ans2 = 0
for i in range(len(S)):
    if i%2 == 0:
        if S[i] == '0':
            ans1 += 1
        else:
            ans2 += 1
    elif i%2 == 1:
        if S[i] == '0':
            ans2 += 1
        else:
            ans1 += 1
print(min(ans1,ans2))

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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for(int i = 0; i < n; i++){
    int a_tmp;
    cin >> a_tmp;
    a[i] = make_pair(a_tmp - 1, i);
  }
  sort(a.begin(), a.end());
  
  int ans = 0;
  for(int i = 0; i < n; i++){
    int b;
    cin >> b;
    ans += b;
  }
  
  for(int i = 0; i < n - 1; i++){
    int c;
    cin >> c;
    if(a[i].second + 1 == a[i + 1].second){
      ans += c;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
while n = gets.chomp.to_i
  break if n == 0

  a = []

  n.times do
    a << gets.chomp.split.map(&:to_i)
  end

  a.each do |i|
    i << i.inject { |sum, n | sum + n }
  end

  a = a.transpose

  a.each do |i|
    i << i.inject { |sum, n | sum + n }
  end

  a = a.transpose

  a.each do |i|
    puts i.map { |item| sprintf('%5d', item) }.join
  end

end

Measured memory_bytes: 8748
d = {'N': (1,5,2,3,0,4), 'E': (3,1,0,5,4,2), 'S': (4,0,2,3,5,1), 'W': (2,1,5,0,4,3)}
l = input().split()
for c in input():
	l = [l[i] for i in d[c]]
print(l[0])



Measured memory_bytes: 5568
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n, res = 0;
	cin >> n;
	for (ll cur = 1; cur <= n; cur = n / (n / cur) + 1)
	{
		ll l = cur, r = n / (n / cur), x = n / l;
		if (n % x == 0 && n / x - 1 >= l && n / x - 1 <= r) res += n / x - 1;
	}
	cout << res << endl;
}

Measured memory_bytes: 256