akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int N;
  cin>>N;
  int A[80];
  for(int i=0;i<N;i++) cin>>A[i];
  long long answer=1000;
  long long ticket=0;
  for(int i=0;i<N;i++){
    if(i==N-1) answer+=A[i]*ticket;
    else{
      if(A[i]<A[i+1]){
        ticket+=answer/A[i];
        answer%=A[i];
      }
      if(A[i]>A[i+1]){
        answer+=ticket*A[i];
        ticket=0;
      }
    }
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 3188
import numpy as np

N, M = map(int, input().split())
P = []
Y = []
for _ in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)
P = np.array(P)
Y = np.array(Y)
PY = np.c_[P, Y]
sort_ind = np.argsort(Y)

PY_sort = PY[sort_ind]
count = [0] * (int(1e+5) + 1)
id_list = []
for p, y in PY_sort:
    count[p] += 1
    id_list.append(str(p).zfill(6) + str(count[p]).zfill(6))

id_list = np.array(id_list)
id_list = id_list[np.argsort(sort_ind)]
for city_id in id_list:
    print(city_id)

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

ll a,b,n;

ll floor(ll N){
  ll fl1 = a*N/b;
  ll fl2 = N/b;
  ll sum = fl1+a*fl2;
  return sum;
}

int main() {
  cin >>a >>b >>n;
  cout << floor(min(b-1,n)) << endl;
  return 0;
}

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

using namespace std;
using namespace std::chrono;

#define rep(i,a,b) for(int i = a;i<(b);++i)
#define trav(a,v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

const ll big = 1000000007ll;
const ll big2 = 1000000009ll;
ll n,m,k,q,h,T;
ll x;

vector<ll> A;

ll i2;

void gobak(){
    ll i = i2;
    A[i]--;
    if(A[i] != 0){
        for(ll c1 = n-1; c1 > i; c1--){
            A[c1] = k;
        }
        i2 = n-1;
    }
    else{
        i2--;
    }
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d;

    cin >> k >> n;
    i2 = n-1;
    if(n == 1){

        cout << (k+1)/2 << "\n";

    }
else{
    if(k%2 == 0){

        for(ll c1 = 0; c1 < n; c1++){
            if(c1 == 0){
                cout << k/2 << " ";
            }
            else{
                cout << k << " ";
            }
        }

    }
    else{

        for(ll c1 = 0; c1 < n; c1++){
            A.push_back(k/2+1);
        }

        for(ll c1 = 0; c1 < n/2; c1++){
            gobak();
        }
        for(ll c1 = 0; c1 < n; c1++){
            if(A[c1] > 0){
                cout << A[c1] << " ";
            }
        }

    }
}
    return 0;
}


Measured memory_bytes: 5744
# input
N = int(input())
A = list(map(int, input().split()))

# define combination
combs = [0, 0]
for i in range(2, N+1):
    combs.append(i*(i-1)//2)

# process
nums = [0]*(N+1)
for a in A:
    nums[a] += 1

sumall = 0
for n in nums:
    sumall += combs[n]

ans = [sumall]*N
for i, a in enumerate(A):
    n = nums[a]
    ans[i] += combs[n-1] - combs[n]

# output
for a in ans:
    print(a)


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

using namespace std;

bool solve(const std::string& s) {
  static const std::string suffixCandidates[] = {"dream", "dreamer", "erase",
                                                 "eraser"};
  std::string suffix;
  for (auto itr = s.rbegin(); itr != s.rend(); itr += suffix.size()) {
    suffix = "";
    for (const auto& suffixCandidate : suffixCandidates) {
      if (suffixCandidate.size() > s.size()) {
        continue;
      }
      if (std::equal(suffixCandidate.rbegin(), suffixCandidate.rend(), itr)) {
        suffix = suffixCandidate;
        break;
      }
    }
    if (suffix.size() == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  std::string s;
  std::cin >> s;
  std::cout << (solve(s) ? "YES" : "NO") << std::endl;
  return 0;
}


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

const int maxn = 2e5 + 10;

int cnt[2], ans[maxn];
vector<int> g[maxn], p[2];

void dfs(int o,int d,int pa = 0) {
	cnt[d&1] += 1;
	p[d&1].push_back(o);
	for(auto u : g[o]) if(u != pa) dfs(u, d + 1, o);
}
int main() {
	int n;
	scanf("%d", &n);
	for(int i = 1;i < n;++i) {
		int a , b;
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1, 0);
	int a = 0,b = 1;
	if(cnt[a] > cnt[b]) swap(a, b);
	int o = 1, t = 2, z = 3;
	if(cnt[a] <= n / 3) {
		for(auto u : p[a]) {
			ans[u] = z, z += 3;
		}
		for(auto u : p[b]) {
			if(z <= n) ans[u] = z, z += 3;
			else if(o <= n) ans[u] = o, o += 3;
			else ans[u] = t,t += 3;
		}
	}
	else {
		for(auto u : p[a]) {
			if(o <= n) ans[u] = o, o += 3;
			else if(z <= n) ans[u] = z, z += 3;
		}
		for(auto u : p[b]) {
			if(t <= n) ans[u] = t,t += 3;
			else if(z <= n) ans[u] = z, z += 3;
		}
	}

	for(int i = 1;i <= n;++i) printf("%d%c", ans[i], i == n ?'\n' :' ');
}

Measured memory_bytes: 21620
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }
 

void solve()
{
	ll a,b,c;
	cin>>a>>b>>c;
	if(2*b==a+c)
		cout<<"YES";
	else
		cout<<"NO";
	}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

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

using namespace std;

long long mem[100005][3];
int arr[100005][3];
int n;

long long go(int x,int y)
{
	if(x>=n) return 0;
	if(mem[x][y]!=-1) return mem[x][y];
	for(int i=0;i<3;i++)
	{
		if(i==y&&x!=0) continue;
		mem[x][y]=max(mem[x][y],go(x+1,i)+arr[x][i]);
	}
	return mem[x][y];
}

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
		for(int j=0;j<3;j++)
			cin >> arr[i][j];
	memset(mem,-1,sizeof mem);
	cout << go(0,0) << endl;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define pb emplace_back
#define em emplace
#define fi first
#define se second
#define USE1(...) template <typename __VA_ARGS__> inline
#define USE2(T, ...) USE1(T, typename __VA_ARGS__)
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
using ll = long long;
template<typename T> using vec = std::vector<T>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE2(T=int,V=vec<T>)V reserved(int n){V v;v.reserve(n);return v;}
USE1(T=int)vec<T>in(int n){auto v=reserved<T>(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=std::pair<T,int>)vec<U>enume(const vec<T>&x,int s=0){int N=x.size();auto v=reserved<U>(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE2(T,U)void prif(bool b,T t,U f){if(b)pr(t);else pr(f);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(20);
    std::cout.setf(std::ios::fixed);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

int buf[128];

signed main() {
  int H = in(), W = in();
  int N = in();
  auto A = in(N);

  int c = 0;
  rep(i, H) {
    if (i % 2 == 0) {
      rep(j, W) {
        while (A[c] == 0 && c < N)
          c++;
        A[c]--;
        buf[j] = c + 1;
      }
    } else {
      rep(j, W) {
        while (A[c] == 0 && c < N)
          c++;
        A[c]--;
        buf[W - j - 1] = c + 1;
      }
    }
    rep(j, W) {
      cout << buf[j] << " \n"[j == W - 1];
    }
  }

  return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
using namespace std;
long long mod = 1e9 + 7;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n;
	cin >> s; 
	long long ans = 1;
	int cnt[30] = { 0 };
	for (int i = 0; i < n; i++) {
		cnt[s[i]-'a'] += 1;
	}
	for (int i = 0; i < 30; i++) {
		ans *= (cnt[i] + 1);
		ans %= mod;
	}
	cout << ans-1;
}

Measured memory_bytes: 512
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int main()
{
	int x;scanf("%d",&x);
	if(x % 1000)	printf("%d",1000 - x % 1000);
    else puts("0");
    return 0;
}


Measured memory_bytes: 3220
#include "bits/stdc++.h"

/**
 * e.g. P = 998244353 = 7 * 17 * 2^23 + 1 -> ω = 3, 31...
 *      P = 163577857 = 39 * 2^22 + 1 -> 23...
 *      P = 167772161 = 5 * 2^25 + 1 -> 3,...,
 *      P = 469762049 = 7 * 2^26 + 1 -> 3,...,
 */
class NTT {
  using ll = long long;
  // mod = 998244353
  const int mod = 7 * 17 * (1 << 23) + 1;

  static const int omega_max = 23;
  static const int root = 31;
  std::vector<int> omega;

  int mod_inv(ll a, ll m) {
    ll b = mod, u = 1, v = 0;
    while (b > 0) {
      ll t = a / b;
      a -= t * b;
      std::swap(a, b);
      u -= t * v;
      std::swap(u, v);
    }
    return (u % m + m) % m;
  }
  std::vector<int> fft(std::vector<int> v, bool inv) {
    const int n = v.size();
    // assert(n == 2冪);
    int _logn = 0;
    while ((1 << _logn) < n) _logn++;
    assert(1 << _logn == n);
    int ww = omega[_logn];
    if (inv) ww = mod_inv(ww, mod);
    for (int m = n; m >= 2; m >>= 1) {
      const int mh = m >> 1;
      int w = 1;
      for (int i = 0; i < mh; i++) {
        for (int j = i; j < n; j += m) {
          const int k = j + mh;
          int x = v[j] - v[k];
          if (x < 0) x += mod;
          v[j] += v[k];
          if (v[j] >= mod) v[j] -= mod;
          v[k] = (1LL * w * x) % mod;
        }
        w = (1LL * w * ww) % mod;
      }
      ww = (1LL * ww * ww) % mod;
    }

    int i = 0;
    for (int j = 1; j < n - 1; j++) {
      for (int k = n >> 1; k > (i ^= k); k >>= 1)
        ;
      if (j < i) std::swap(v[i], v[j]);
    }
    if (inv) {
      const int inv_n = mod_inv(n, mod);
      for (auto &x : v) {
        x = (1LL * x * inv_n) % mod;
      }
    }
    return v;
  }

 public:
  NTT() {
    omega.resize(omega_max + 1);
    int x = root;
    for (int i = omega_max; i >= 0; i--) {
      omega[i] = x;
      x = (1LL * x * x) % mod;
    }
  }
  std::vector<int> convolution(std::vector<int> f, std::vector<int> g) {
    int sz = 1;
    const int m = f.size() + g.size() - 1;
    while (sz < m) sz *= 2;
    f.resize(sz), g.resize(sz);
    f = this->fft(std::move(f), false);
    g = this->fft(std::move(g), false);
    for (int i = 0; i < sz; i++) {
      f[i] = (1LL * f[i] * g[i]) % mod;
    }
    return this->fft(std::move(f), true);
  }
};

using namespace std;

int main() {
  int n, m, k, l;
  cin >> n >> m >> k >> l;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  string com;
  cin >> com;
  int x = 0, y = 0;
  vector<vector<int>> cnt(m, vector<int>(m, 0));
  for (int i = 0; i < l; i++) {
    if (com[i] == 'U')
      x--;
    else if (com[i] == 'D')
      x++;
    else if (com[i] == 'R')
      y++;
    else
      y--;
    cnt[x][y]++;
  }
  vector<int> A(m * m, 0), B(m * m, 0);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (s[i][j] == 'X') A[i + j * m] = 1;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) B[i + j * m] = cnt[i][j];
  NTT ntt;
  auto ret = ntt.convolution(A, B);
  // printv(ret);
  int sum = 0;
  for (const auto &v : ret) {
    if (v >= k) sum++;
  }
  cout << sum << endl;
}



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

void MakePrimeArray(bool A[],int n){
	A[0] = A[1] = false;
	for(int i=2;i<n;i++){
		A[i] = true;
	}
	
	for(int	i=2;i*i<n;i++){
		if(A[i]){
			for(int j=i*i;j<n;j+=i){
				A[j] = false;
			}
		}
	}
}

int main(){
	
	int n=1000000;

	bool primearray[n];
	
	MakePrimeArray(primearray,n);
	
	int NumPrimeArray[n];
	
	int count=0;
	for(int i=0;i<n;i++){
		if(primearray[i]){
			count++;
		}
		NumPrimeArray[i] = count;
	}
	
	while(true){
		int innum;
		cin >> innum;
		
		if(cin.eof()) break;
		
		cout << NumPrimeArray[innum] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 7960
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define FIELDW  ( 10 )
#define FIELDH  ( 10 )
#define ISVALID(X,Y)  ( (X) >= 0 && (Y) >= 0 && (X) < FIELDW && (Y) < FIELDH )
int field[ FIELDH ][ FIELDW ] = { { 0 } };

/** Application main entry point. */
int main (
  int argc,
  char *argv[ ]
  )
{
  int res = 0;
  int max = 0;
  int x, y, s;
  int i, j;

  while ( scanf ( " %d,%d,%d", &x, &y, &s ) == 3 )
  {
    ++field[ y ][ x ];

    if ( ISVALID( x, y - 1 ) ) ++field[ y - 1 ][ x ];
    if ( ISVALID( x - 1, y ) ) ++field[ y ][ x - 1 ];
    if ( ISVALID( x + 1, y ) ) ++field[ y ][ x + 1 ];
    if ( ISVALID( x, y + 1 ) ) ++field[ y + 1 ][ x ];

    if ( s < 2 ) continue;

    if ( ISVALID( x - 1, y - 1 ) ) ++field[ y - 1 ][ x - 1 ];
    if ( ISVALID( x + 1, y - 1 ) ) ++field[ y - 1 ][ x + 1 ];
    if ( ISVALID( x - 1, y + 1 ) ) ++field[ y + 1 ][ x - 1 ];
    if ( ISVALID( x + 1, y + 1 ) ) ++field[ y + 1 ][ x + 1 ];

    if ( s < 3 ) continue;

    if ( ISVALID( x, y - 2 ) ) ++field[ y - 2 ][ x ];
    if ( ISVALID( x - 2, y ) ) ++field[ y ][ x - 2 ];
    if ( ISVALID( x + 2, y ) ) ++field[ y ][ x + 2 ];
    if ( ISVALID( x, y + 2 ) ) ++field[ y + 2 ][ x ];
  }

  for ( j = 0; j < FIELDH; ++j )
  for ( i = 0; i < FIELDW; ++i )
  {
    res += !( field[ j ][ i ] );
    if ( field[ j ][ i ] > max )
      max = field[ j ][ i ];
  }

  printf ( "%d\n%d\n", res, max );

  return ( 0 );
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    int a,b,c,d;cin>>a>>b>>c>>d;
    int x=c-a;
    int y=d-b;
    cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x<<endl;

}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	
	{
		bool flag = true;
		for (int i = 0; i < n; i++) flag &= (a[i] <= i);
		for (int i = 0; i + 1 < n; i++) {
			if (a[i] < a[i + 1]) flag &= (a[i + 1] == a[i] + 1);
		}
		if (not flag) {
			cout << -1 << '\n';
			return 0;
		}
	}
	
	long long ans = 0;
	for (int i = 0; i + 1 < n; i++) {
		if (a[i + 1] == a[i] + 1) ans++;
		else ans += a[i + 1];
	}

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

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,i,m;
    cin >> n;
    vector<int> a(n);
    for(i=0;i<n;i++) cin >> a[i];
    m = a[0];
    for(i=1;i<n;i++){
        if(m>a[i]+1){
            cout << "No" << endl;
            return 0;
        }
        if(m<a[i]) m = a[i];
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define re register
using namespace std;
int n,m,dis[22][22],ans;
char mp[22][22];
inline bool check(re int x,re int y){
	if(x<1||x>n||y<1||y>m)return 0;
	if(mp[x][y]=='#')return 0;
	if(dis[x][y])return 0;
	return 1;
}
queue <int> q;
inline void bfs(re int x,re int y){
	q.push(x);
	q.push(y);
	while(!q.empty()){
		x=q.front();q.pop();
		y=q.front();q.pop();
		if(check(x+1,y))dis[x+1][y]=dis[x][y]+1,q.push(x+1),q.push(y);
		if(check(x-1,y))dis[x-1][y]=dis[x][y]+1,q.push(x-1),q.push(y);
		if(check(x,y+1))dis[x][y+1]=dis[x][y]+1,q.push(x),q.push(y+1);
		if(check(x,y-1))dis[x][y-1]=dis[x][y]+1,q.push(x),q.push(y-1);
	}
}
signed main(){
scanf("%d%d",&n,&m);
for(re int i=1;i<=n;++i)scanf("%s",mp[i]+1);
for(re int i=1;i<=n;++i){
	for(re int j=1;j<=m;++j){
		if(mp[i][j]=='.'){
	
		memset(dis,0,sizeof(dis));
		dis[i][j]=1;
		bfs(i,j);
		for(re int ii=1;ii<=n;++ii){
			for(re int jj=1;jj<=m;++jj){
				ans=max(ans,dis[ii][jj]);
			}
		}	}
	}
}
cout<<ans-1;
	}



Measured memory_bytes: 256
<?php
/*
    Problem URL : http://abc047.contest.atcoder.jp/tasks/abc047_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

fscanf(STDIN, "%d %d %d", $W, $H, $N);

$x_min = 0;
$x_max = $W;
$y_min = 0;
$y_max = $H;

for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d %d %d", $x, $y, $a);
    switch ($a) {
        case "1":
            $x_min = max($x_min, $x);
            break;

        case "2":
            $x_max = min($x_max, $x);
            break;

        case "3":
            $y_min = max($y_min, $y);
            break;

        case "4":
            $y_max = min($y_max, $y);
            break;
    }
}

$width = 0;
$height = 0;
if ($x_max > $x_min) {
    $width = $x_max - $x_min;   
}
if ($y_max > $y_min) {
    $height = $y_max - $y_min;   
}

echo ($width * $height) . PHP_EOL;


Measured memory_bytes: 2936
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int main()
{
	int dp[100][100];
	int P[101];

	int n;
	cin >> n;
	cin >> P[0] >> P[1];
	for (int i = 1; i < n; i++)
	{
		int t;
		cin >> t >> P[i + 1];
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; (j + i) < n; j++)
		{
			if (i == 0)
			{
				dp[j][j + i] = 0;
			}
			else if (i == 1)
			{
				dp[j][j + i] = P[j] * P[j + 1] * P[j + 2];
			}
			else
			{
				int mini = 10000000;
				for (int k = 0; k < i; k++)
				{
					mini = min(mini, dp[j][j + k] + dp[j + k + 1][j + i] + P[j] * P[j + k + 1] * P[j + i + 1]);
				}
				dp[j][j + i] = mini;
			}
		}
	}

	cout << dp[0][n - 1] << endl;

	return 0;
}


Measured memory_bytes: 3108
const val mod = 1000000007

fun main(A: Array<String>) {
    val a = LongArray(13) { 0L }
    val b = LongArray(13) { 0L }
    a[0] = 1

    for (c in readLine()!!) {
        val range = if (c == '?') 0..9 else (c - '0')..(c - '0')

        for (j in range)
            for (k in a.indices)
                b[(k * 10 + j) % 13] += a[k] % mod

        System.arraycopy(b, 0, a, 0, 13)
        b.fill(0)
    }
    println(a[5] % mod)
}


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

int main(){
  string S;
  cin >> S;
  int A, B, C, D;
  A = S[0] - '0';
  B = S[1] - '0';
  C = S[2] - '0';
  D = S[3] - '0';
  string op1;
  string op2;
  string op3;
  bool flag = false;
  
  for(int i=0;i<2;i++){
    if(i==0) op1 = "+";
    else op1 = "-";
    for(int j=0;j<2;j++){
      if(j==0) op2 = "+";
      else op2 = "-";
      for(int k=0;k<2;k++){
        if(k==0) op3 = "+";
        else op3 = "-";
        int res = A;
        if(op1 == "+") res = res + B;
        else res = res - B;
        if(op2 == "+") res = res + C;
        else res = res - C;
        if(op3 == "+") res = res + D;
        else res = res - D;
        if(res == 7){
          flag = true;
          break;
        }
      }
      if(flag) break;
    }
    if(flag) break;
  }
  
  string output;
  output = to_string(A) + op1 + to_string(B) + op2 + to_string(C) + op3 + to_string(D) + "=7";
  cout << output << endl;
  
  return 0;
}

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

int main(){
    int K, X, a, z;
    cin >> K >> X;
    a = max(-1000000 , X-K+1);
    z = min( 1000000 , X+K-1);
    for(int i=a ; i<=z ; ++i){
        cout << i;
        if(i!=z){
            cout << " " ;
        }
    }
    cout << endl;
    
}

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

int main() {
    int x, y;
    while (true) {
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        if (x > y) {
            int tmp = x;
            x = y;
            y = tmp;
        }
        cout << x << ' ' << y << endl;
    }
    return 0;
}


Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ll long long
long long min(long long x,long long y){return (x<y ? x:y);}
long long max(long long x,long long y){return (x>y ? x:y);}
#define ld long double
int stoi(string s) {return atoi(s.c_str());}

int main(){
  int A,B; cin >> A>>B;
  int r = -1;
  if(A<=B){
    for(double i=1;i<B*100;i++){
      if((int)(i*0.08)==A){
        if((int)(i*0.1)==B){
          r = i; break;
        }
      }
    }
  }
  cout << r << "\n";
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
double Do(int x)
{
	double ans = 1;
	int c = 1;
	while(c<x)
	{
		c*=2;
		ans /= 2;
	}
	return ans;
}
int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	double ans = 0;
	for(int i=1; i<=N; ++i)
		ans += Do((K+i-1)/i);
	printf("%.12lf\n", ans/N);
}

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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
  if (a < b) {
    swap(a, b);
  }

  /* ユークリッドの互除法 */
  ll r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
  if (p == 0) {
    return 1;
  }
  if (p % 2 == 0) {
    int64_t t = __pow_mod(n, p / 2, mod);
    return (t * t) % mod;
  }
  return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
  int64_t res = __pow_mod(n, p, mod);
  if (res == 0) {
    res = mod;
  }
  return res;
}

constexpr int64_t nCr_mod(int64_t n, int64_t r, int64_t mod) noexcept {
  int64_t count = 1;
  auto a = r;
  for (auto i = n; i > n - r; i--) {
    count *= i;
    if (count % mod != 0) {
      count %= mod;
    }
    int64_t inv = pow_mod(a, mod - 2, mod);
    count *= inv;
    if (count % mod != 0) {
      count %= mod;
    }
    a--;
  }
  return count;
}

void solve(long long K) {
    vi v={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<v[K-1]<<endl;
    return;

}

int main() {
  long long K;
  std::cin >> K;
  solve(K);
  return 0;
}


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

int main()
{
	double px = 0, py = 0, cx = 0, cy = 0, r = 0,
		vx = 0, vy = 0, wx = 0, wy = 0;

	cin >> px >> py >> cx >> cy >> r;

	if (py == cy) {
		vx = cx + (r * r) / (px - cx);
		wx = vx;
		vy = cy - r * sqrt(1 - (r * r) / pow(px - cx, 2));
		wy = cy + r * sqrt(1 - (r * r) / pow(px - cx, 2));
	}
	else {
		double a = 0, b = 0, s = 0, t = 0, u = 0;

		a = (cx - px) / (py - cy);
		b = (px * cx - cx * cx + r * r) / (py - cy) + cy;

		s = 1 + pow(a, 2);
		t = cx - a * b + a * cy;
		u = pow(cx, 2) + pow(b - cy, 2) - pow(r, 2);
		
		vx = (t - sqrt(t * t - s * u)) / s;
		wx = (t + sqrt(t * t - s * u)) / s;
		vy = a * vx + b;
		wy = a * wx + b;
	}

	cout << setiosflags(ios::showpoint | ios::fixed) << setprecision(10)
		<< vx << " " << vy << endl << wx << " " << wy << endl;

	return 0;
}


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin>>n;
    vector<ll> d(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    sort(ALL(d));
    cout << d[n / 2] - d[n / 2 - 1] << endl;
}

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

using namespace std;

int merge(vector<int> &a, int left, int mid, int right,  int &counter) {
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> l(n1 + 1, 0);
	vector<int> r(n2 + 1, 0);

	for (int i = 0; i < n1 ; i++) {
		l[i] = a[left + i];
	}
	for (int i = 0; i < n2 ; i++) {
		r[i] = a[mid + i];
	}
	l[n1] = INT_MAX;
	r[n2] = INT_MAX;

	int i = 0;
	int j = 0;

	for (int k = left; k < right;k++) {
		counter++;
		if (l[i] <= r[j]) {
			a[k]=l[i];
				i++;
		}
		else {
			a[k]=r[j];
			j++;
		}
	}
	return 0;
}

int mergeSort(vector<int> &a, int left, int right,int &counter) {
	if (left + 1 >= right) {
		return 0;
	}
	
	int mid = (left + right) / 2;

	mergeSort(a, left, mid,  counter);
	mergeSort(a, mid, right,  counter);
	merge(a, left, mid, right, counter);
	return 0;
}


int main() {

	int n;
	cin >> n;
	vector<int> a(n,0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int left=0, right=n;
	int counter = 0;
	mergeSort(a, left, right,counter);
	
	for (int i = 0; i < n; i++) {
		cout << a[i] << (i != n - 1 ? " " : "\n");
	}
	cout << counter << endl;


}


Measured memory_bytes: 6744
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    ll K;
    string S;
    cin >> K;
    cin >> S;

    if(S.size()<=K)cout<<S<<endl;
    else{
        for(int i = 0;i<K;i++){
            cout <<S[i];
        }
        cout <<"..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3656
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def yn(f) return (f)? "Yes": "No" end
def ynb(f) return (f)? "YES": "NO" end
def ap(a) a.each{|u| p u} end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
def ser(d,t)
  if d == ($n)
    f = false
    $t.each.with_index do |tt,i|
      b = 0
      tt.each do |d|
        b += t[d]
      end
      f = true if(b%2 != $pt[i])
      return  if(f)
    end
    $ans += 1
    return
  end
  ser(d+1,t+[1])
  ser(d+1,t+[0])
end
$n,$m = inp
$t = []
$ans = 0
$m.times do |i|
  $t.push(inp)
  $t[i].shift
end
$pt = inp
ser(0,[nil])
p $ans
=begin

=end

Measured memory_bytes: 1916
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>


int main() {

    int a, b, i;
    scanf("%d %d", &a, &b);

    if (a < b) {
        for (i = 0; i < b; i++) {
            printf("%d", a);
        }
    }
    else {
        for (i = 0; i < a; i++) {
            printf("%d", b);
        }
    }

    return 0;
}


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

bool isPrime(unsigned x){
    if(x==2)
        return true;
    if(x<2||x%2==0)
        return false;
    
    unsigned i=3;
    while(i<=sqrt(x)){
        if(x%i==0)
            return false;
        i += 2;
    }

    return true;
}

int main(){
    int n, x, cnt=0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x;
        cnt += isPrime(x);
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3096
h,w = [int(i)  for i in input().split()]

listHW = []
flag = False
for i in range(0, h):
  listHW.append(list(input()))

  
for i in range(0, len(listHW)):
  if flag:
    break
  listw = listHW[i]
  #print("listw", listw)
  for ii in range(0, len(listw)):
    w = listw[ii]
    if w == "#":
      #print(i, ii)
    
      if i == 0:
        #右上
        if ii == len(listw)-1:
          if w == listHW[i+1][ii] or w == listw[ii-1]:
            continue
        #左上
        elif ii == 0:
          if w == listHW[i+1][ii] or w == listw[ii+1]:
            continue 
        #上段
        elif w == listw[ii+1] or w == listw[ii-1] or w == listHW[i+1][ii]:
          continue

      elif i == len(listHW)-1:
        #右下
        if ii == len(listw)-1:
          if w == listHW[i-1][ii] or w == listw[ii-1]:
            continue
        #左下
        elif ii == 0:
          if w == listHW[i-1][ii] or w == listw[ii+1]:
            continue 
        #下段
        elif w == listw[ii+1] or w == listw[ii-1] or w == listHW[i-1][ii]:
          continue
      
      #左列
      elif ii == 0:
        if w == listw[ii+1]  or w == listHW[i-1][ii] or w == listHW[i+1][ii]:
          continue
      #右列
      elif ii == len(listw)-1:
        if w == listw[ii-1]  or w == listHW[i-1][ii] or w == listHW[i+1][ii]:
          continue
              
      #通常
      elif w == listw[ii-1] or w == listw[ii+1]or w == listHW[i-1][ii] or w == listHW[i+1][ii]:
        continue

      #print("break後")
      #隣接するものがなかった時点で終了      
      flag = True
      break
    
    #「.」だったときはとばす
    else:
      continue
    



if flag:
  print("No")
else:
  print("Yes")


Measured memory_bytes: 3188
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::HashMap;
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::usize;

#[allow(unused_macros)]
macro_rules! read_cols {
    ($($t:ty),+) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();

        let mut it = line.trim()
            .split_whitespace();

        ($(
            it.next().unwrap().parse::<$t>().ok().unwrap()
        ),+)
    }}
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let (d, t, s) = read_cols!(usize, usize, usize);

    if s * t >= d {
        println!("Yes")
    } else {
        println!("No")
    }
}

Measured memory_bytes: 2104
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct Words
{
    char	word[31];
    int		page[100];
} WORDS;

WORDS	wordArray[100];

WORDS* printMinWord(WORDS*);
WORDS* printMinPage(WORDS*);

int main()
{
    char	tempWord[31];
    int		tempPage;
    int		wordCnt;
    int		pageCnt;
    int		inputCnt = 0;
	
    while (scanf("%s %d", &tempWord, &tempPage) != EOF)
    {
        wordCnt = 0;
        /*sort page to each words*/
        while(1)
        {
            if(!strcmp(tempWord, wordArray[wordCnt].word))
            {
                for(pageCnt = 1; pageCnt < 100; pageCnt++)
                {
                    if(!(wordArray[wordCnt].page[pageCnt]))
                    {
                        break;
                    }
                }
                wordArray[wordCnt].page[pageCnt] = tempPage;
                break;
            }
            else if(!strcmp("", wordArray[wordCnt].word))
            {
                strcpy(wordArray[wordCnt].word, tempWord);
                wordArray[wordCnt].page[0] = tempPage;
                break;
            }
            wordCnt++;
        }
    }

    printMinWord(wordArray);


    return 0;
} 

WORDS* printMinWord(WORDS* word_array)
{
	int		word_cnt;
	char	min_word[31]	= "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
	int		min_word_index	= -1;
	
	/*find min word and its index*/
	for(word_cnt = 0; word_cnt < 100; word_cnt++)
	{
		if(!strcmp(word_array[word_cnt].word, ""))
		{
			continue;
		}
		if(strcmp(word_array[word_cnt].word, min_word) <= 0)
		{
			strcpy(min_word, word_array[word_cnt].word);
			min_word_index = word_cnt;
		}
	}
	
	/*no recursion if no word content*/
	if(min_word_index == -1)
	{
		return word_array;
	}
	printf("%s\n", word_array[min_word_index].word);
	
	/*print subsequential pages of min word*/
	printMinPage(&word_array[min_word_index]);
	
	strcpy(word_array[min_word_index].word, "");
	
	return printMinWord(word_array);
}

WORDS* printMinPage(WORDS* word_array)
{
	int		page_cnt;
	int		min_page = 1001;
	int		min_page_index	= -1;
		
	/*find min page and its index*/
	
	
	for(page_cnt = 0; page_cnt < 100; page_cnt++)
	{
		if(word_array->page[page_cnt] == 0)
		{
			continue;
		}
		if(word_array->page[page_cnt] < min_page)
		{
			min_page = word_array->page[page_cnt];
			min_page_index = page_cnt;
		}
	}
	
	/*no recursion if no page content*/
	if(min_page_index == -1)
	{
		printf("\n");
		return word_array;
	}
	printf("%d", word_array->page[min_page_index]);
	word_array->page[min_page_index] = 0;
	
	for(page_cnt = 0; page_cnt < 100; page_cnt++)
	{
		if(word_array->page[page_cnt] == 0)
		{
			continue;
		}
		printf(" ");
		return printMinPage(word_array);
	}
	
	return printMinPage(word_array);
}

Measured memory_bytes: 644
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<a/b<<" "<<a%b<<" "<<setiosflags(ios::fixed)<<setprecision(5)<<(double)a/(double)b<<endl;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)
const int INF=1e9;
using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  ll n,m;
  cin>>n>>m;
  ll x[m];
  rep(i,0,m) cin>>x[i];
  if(m==1 || n>=m){
    cout<<0<<endl;
    return;
  }
  sort(x,x+m);
  multiset<ll,greater<ll>> s;
  ll ans=0;
  rep(i,1,m){
    ll mov=x[i]-x[i-1];
    ans+= mov;
    s.insert(mov);
  }
  auto it=s.begin();
  rep(i,0,n-1) ans-=*it,it++;
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 9084
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    string s;
    cin>>n>>k>>s;
    if(s[k-1]=='A'){
        s[k-1]='a';
    } else if(s[k-1]=='B'){
        s[k-1]='b';
    }else{
        s[k-1]='c';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 200010 
#define inf 2000000001
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,m,a[N],ans;
int calc_head(int k)
{
	int s=0;
	for (int i=1;i<=k/2;i++) 
	{
		if (a[i]+a[k-i+1]>=m) return inf;
		s=max(s,a[i]+a[k-i+1]);
	}
	return s;
}
int calc_tail(int k)
{
	int s=0;
	for (int i=k;i<=n;i++)
	{
		if (a[i]+a[n-(i-k)]<m) return inf;
		s=max(s,a[i]+a[n-(i-k)]-m);
	}
	return s;
}
signed main()
{
	n=read()*2,m=read();
	for (int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	int x;
	int L=0,R=n/2;
	while (L<=R)
	{
		int mid=L+R>>1;
		if (calc_tail(mid*2+1)==inf) L=mid+1;
		else R=mid-1,x=mid*2;
	}
	cout<<max(calc_head(x),calc_tail(x+1));
	return 0;
	//NOTICE LONG LONG!!!!!
}
//枚举分界线 

Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))
#不正解
#for i in range(1,N):
#    print(A.count(i))

ans = [0]*N #listのansにN個の0を入力
#print(ans)
for i in A:
    ans[i-1] += 1


for i in ans:
   print(i)


Measured memory_bytes: 32200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int64_t Comb(int n,int m){
    if(m==0) return 1;

    int64_t v=1;
    m=min(m,n-m);
    rep(i,n-m+1,n+1) v*=i;
    rep(i,1,m+1) v/=i;
    return v;
}

int main(){
    int N,P; cin>>N>>P;
    vector<int> A(N);
    rep(n,0,N) cin>>A.at(n);

    int even=0,odd=0;
    for(auto a:A){
        if(a%2) odd++;
        else even++;
    }

    uint64_t ans=0;
    if(P){
        for(int i=1;i<=odd;i+=2){
            ans+=(uint64_t)pow(2,even)*Comb(odd,i);
        }
    }else{
        for(int i=0;i<=odd;i+=2){
            ans+=(int64_t)pow(2,even)*Comb(odd,i);
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

ans = 0
prev = H[0]
count = 0
for i in range(1, N):
    if H[i] <= prev:
        count += 1
    else:
        ans = max(ans, count)
        count = 0
    prev = H[i]

ans = max(ans, count)
print(ans)



Measured memory_bytes: 63856
x,y=map(int,input().split())
def gcd(x,y):
    if x==y:
        return x
    elif x>y:
        r=-1
        while r!=0:
            r=x%y
            x=y
            y=r
        return x
    else:
        r=-1
        while r!=0:
            r=y%x
            y=x
            x=r
        return y
print(gcd(x,y))



Measured memory_bytes: 5600
#include"bits/stdc++.h"
using namespace std;

void Main() {
	long N, b, f, r, v;
	int nums[4][3][10];
	cin >> N;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				nums[i][j][k] = 0; 
			}
		}
	}
	for (long i = 0; i < N; i++) {
		cin >> b >> f >> r >> v;
		nums[b - 1][f - 1][r - 1] = nums[b - 1][f - 1][r - 1] + v;
	}
	
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << " " << nums[i][j][k];
			}
			cout << endl;
		}
		if (i != 3) {
			cout << "####################";
			cout << endl;
		}
	}

}

int main() {
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


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

#define ll   long long int
#define rep(i,n)    for(int i=0;i<(int)n;i++)
#define show(s)     cout<<s<<endl

int main() {

    int N;
    cin >> N;

    show(N*N*N); 

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
int main(void){
    ll N;
    scanf("%lld", &N);
    printf("%lld\n", N*(N-1)/2);
    return 0;
}
int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
package main
import (
  "fmt"
  "os"
)
func main() {
  var s string
  var ok []string = []string{"KIHBR",
                             "AKIHBR","KIHABR","KIHBAR","KIHBRA",
                             "AKIHABR","AKIHBAR","AKIHBRA","KIHABAR","KIHABRA","KIHBARA",
                             "AKIHABAR","AKIHABRA","AKIHBARA","KIHABARA",
                             "AKIHABARA"}
  fmt.Scan(&s)
  for i:=0;i<16;i++ {
    if s == ok[i] {
      fmt.Println("YES")
      os.Exit(0)
    }
  }
  fmt.Println("NO")
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  vector<int> ans(100000, 0);
  vector<vector<vector<int>>> vec(100, vector<vector<int>>(100, vector<int>(100)));
  
  rep(i, 100) rep(j, 100) rep(k, 100) {
    vec.at(i).at(j).at(k) = i*i + j*j + k*k + i*j + j*k + k*i;
    ans.at(vec.at(i).at(j).at(k))++;
  }
  
/*  rep(i, 100) {
    rep(j, 100) {
      rep(k, 100) {
        vec.at(i).at(j).at(k) = i*i + j*j + k*k + i*j + j*k + k*i;
        if (n < vec.at(i).at(j).at(k)) 
        ans.at(vec.at(i).at(j).at(k))++;
      }
    }
  }
  
  */
  
  for (int i = 0; i < n; i++) {
    cout << ans.at(i+1) << endl;
  }
  
}


Measured memory_bytes: 7944
N,K=map(int,input().split())
h=[int(i) for i in input().split()]
dp=[float("inf")]*N
dp[0]=0
for i in range(N):
  for k in range(1,K+1):
    if i+k>=N:
      break
    dp[i+k]=min(dp[i+k],dp[i]+abs(h[i]-h[i+k]))
print(dp[N-1])
    

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

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

  int n, a[100100], ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 1, len = 0; i < n; i++)
    if (a[i] <= a[i - 1]) ans = max(ans, ++len);
    else len = 0;
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

typedef int64_t ll;
#define SPRE(x) setprecision(x) // 精度を指定
int main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);

	int a, b, c;
	cin >> a >> b >> c;
	int start = a % b;
	int sum = start;
	do{
		sum += start;
		sum %= b;
		if(sum == c) {
			cout << "YES\n";
			return 0;
		}
	}while(sum != start);
	cout << "NO\n";

}




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

class Group {
public:
    string name;
    vector<string> members;
    Group(){}
    void add(string name) {
        if (find(members.begin(), members.end(), name) == members.end()) {
            members.push_back(name);
        }
    }
    void add(Group g) {
        for (string name: g.members) add(name);
    }
    static Group parse(string s) {
        Group g;
        string t = "";
        for (int i=0; i<(int)s.size(); ++i) {
            if (s[i] == ':') {
                g.name = t;
                t = "";
            } else if (s[i] == ',') {
                g.add(t);
                t = "";
            } else  if (s[i] == '.') {
                g.add(t);
                break;
            } else {
                t += s[i];
            }
        }
        return g;
    }
};

Group expand(map<string, Group> &list, Group g) {
    while (1) {
        bool update = false;
        Group tmp;
        for (string name: g.members) {
            if (list.count(name)) { // グループ名の場合は展開+結合
                tmp.add(list[name]);
                update = true;
            } else {
                tmp.add(name);
            }
        }
        if ( ! update) break;
        g = tmp;
    }
    return g;
}

int main() {
    int n;
    string s;
    while (cin >> n, n) {
        map<string, Group> list;
        cin >> s;
        Group g = Group::parse(s);
        list[g.name] = g;
        Group g1 = g; // first group
        for (int i=1; i<n; ++i) {
            cin >> s;
            Group g = Group::parse(s);
            list[g.name] = g;
        }

        Group t = expand(list, g1);
        cout << (int)t.members.size() << endl;
    }
    return 0;
}


Measured memory_bytes: 3140
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def debug(*x): stderr.write(reduce(add,repr(x)).strip("()\',")+'\n')

n,a,b = f()
x = sorted(f())
ans = 0

for i in range(n-1):
    if (x[i+1] - x[i])*a > b:
        ans += b
    else:
        ans += (x[i+1]-x[i])*a

print(ans)

Measured memory_bytes: 14748
#include <iostream>

int main(void)
{
    int a, b;
    std::cin >> a >> b;
    if(a < b) {
        std::cout << "a < b" << std::endl;
    } else if (a > b) {
        std::cout << "a > b" << std::endl;
    } else {
	std::cout << "a == b" << std::endl;
    }
    return 0;
}





Measured memory_bytes: 3108
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=200010;
long long ans,sum,tot;
int n,a[N],b[N];
int main()
{
//	freopen("B.in","r",stdin);
//	freopen("B.out","w",stdout);
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]),tot+=a[i];
	bool f=0;
	for (int i=1;i<=n;i++) if (a[i]!=b[i]) {f=1;break;}
	if (!f) {printf("0");return 0;}
	int minn=1e9;
	for (int i=1;i<=n;i++) if (a[i]>b[i]) minn=min(minn,b[i]);
	printf("%lld",tot-minn);
}

Measured memory_bytes: 384