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

int main() {
  string s; cin >> s;
  int ans = 0;
  REP(i, s.length()) {
    if (i % 2 == 0) {
      ans -= s[i] == 'p';
    } else {
      ans += s[i] == 'g';
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef double ld;

vector<pair<ll,ll>> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define MAX_N 100010
bool x[MAX_N];
ll num[MAX_N];

ll fibl[MAX_N]={0};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    
    return p;
}

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

int main(){
    ll n,k,q;
    cin >> n >> k >> q;
    ll score[n];
    fill(score,score+n,q);
    for (ll i=0;i<q;i++){
        ll x;
        cin >> x;
        score[x-1]=score[x-1]-1;
    }
    for (ll i=0;i<n;i++){
        if (k-score[i]>0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=2e5+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,a[N],tp=0;
pii st[N];
int check(int mid) {
    tp=0;
    if(mid==1) {
        for(int i=2;i<=n;i++) if(a[i]<=a[i-1]) return 0;
        return 1;
    }
    for(int i=1;i<=n;i++) {
        if(i==1||a[i]>a[i-1]) continue;
        while(tp&&st[tp].fi>a[i]) --tp;
        int j=a[i];
        while(tp&&st[tp].fi==j&&st[tp].se==mid) --j,--tp;
        if(!j) return 0;
        else if(st[tp].fi==j) st[tp].se++;
        else st[++tp]=mp(j,2);
    }
    return 1;
}
int main() {
    n=gi();
    for(int i=1;i<=n;i++) a[i]=gi();
    int l=1,r=n,ret=0;
    while(l<=r) {
        int mid=(l+r)>>1;
        if(check(mid)) ret=mid,r=mid-1;
        else l=mid+1;
    }
    cout<<ret;
    return 0;
}


Measured memory_bytes: 1024
import sys

def solve():
    N,M=map(int,sys.stdin.readline().rstrip().split())
    AB=[]
    for i in range(N):
        a,b=map(int,sys.stdin.readline().rstrip().split())
        AB.append((a,b))
    AB = sorted(AB, key=lambda e:e[0])
    ans=0
    for ab in AB:
        if M <= ab[1]:
            ans += ab[0]*M
            return ans
        else:
            ans += ab[0]*ab[1]
            M -= ab[1]

print(solve())


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



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    	int h,n;
    	cin>>h>>n;
    	vector<int> vec(n);
    	for(int i=0;i<n;++i)
    	{
    		cin>>vec[i];
    	}
    	ll sum=0;
    	for(int i=0;i<n;++i)
    	{
    		sum+=vec[i];
    	}
    	if(sum>=h)
    	{
    		cout<<"Yes"<<endl;
    	}
    	else
    	{
    		cout<<"No"<<endl;
    	}


    

}


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
#define P pair<int, int>
struct data{
	int place;
	int cost;

	bool operator<(const data &ri) const{
		return cost < ri.cost;
	}
	bool operator>(const data &ri) const{
		return cost > ri.cost;
	}
};
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

int N;
int cnt = 0;
int tfs[4] = {0,3,5,7};

void solve(llong num, int jo){
	if(jo >= 10){
		bool use[4] = {};
		llong tnum = 0;
		vector<int> si;
		while(num){
			si.pb(num%4);
			num /= 4;
		}
		for(int i = si.size()-1; i >= 0; i--){
			tnum *= 10;
			tnum += tfs[si[i]];
			use[si[i]]++;
		}
		if(!use[0] && use[1] && use[2] && use[3] && tnum <= N){
			cnt++;
			// cout << tnum << endl;
		}

		return;
	}

	for(int i = 0; i < 4; i++)
		solve(num*4+i, jo+1);

	return;
}

int main(){
	cin >> N;
	solve(0,0);
	cout << cnt << endl;

	return 0;
}

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

#define REP(i,n) REPN(i,0,n)
#define REPN(i,m,n) for(int i=m; i<(n); i++)

#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
    int x, i;
    x = A[r];
    i = p - 1;
    REPN(j, p, r) {
        if (A[j] <= x) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i+1], A[r]);
    return i + 1;
}

int main() {
    int i, q;

    cin >> n;
    REP(i, n) {
        cin >> A[i];
    }

    q = partition(0, n-1);

    REP(i, n) {
        if (i) {
            cout << " ";
        }
        if (i == q) {
            cout << "[";
        }
        cout << A[i];
        if (i == q) {
            cout << "]";
        }
    }
    cout << "\n";
}


Measured memory_bytes: 3492
#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;i++)
#define frd(i,x,y) for(int i=x;i>=y;i--)
#define fi first
#define se second
#define ll long long
#define pb push_back
#define add push
using namespace std;
string s;
ll f[500010];
ll res;
ll n;
vector<ll> a[500010];
ll dd[500010];
void io()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    freopen("testt.inp","r",stdin);
    freopen("testt.out","w",stdout);
}
void inp()
{
    cin>>s;
    s=" "+s;
    n=s.size();
}
void DFS(int par,int u)
{
    if(a[u].size()>0)
    {
        for(int i=0;i<a[u].size();i++)
        {
            int v=a[u][i];
            if(v==par) continue;
            DFS(u,v);
            f[u]=max(f[u],f[v]);
        }
    }
    if(a[u].size()==0)
    {
        f[u]=0;
    }
    else
    {
        f[u]++;
    }
}

void proc()
{
    for(int i=1;i<s.size();i++)
    {
        if(s[i]=='>')
        {
            a[i].pb(i+1);
            dd[i+1]=1;
        }
        else
        {
            a[i+1].pb(i);
            dd[i]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(dd[i]==0)
        {
            DFS(i,i);
        }
    }
    for(int i=1;i<=n;i++)
    {
        res+=f[i];
    }
    cout<<res;
}
int main()
{
    //io();
    inp();
    proc();
    return 0;
}


Measured memory_bytes: 74904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

ll n,m;
vector<ll> cumulative_vec(200001, 0);
vector<ll> cumulative_sum(200001, 0);

bool solve(ll k,vector<ll> vec){
  ll sum = 0;
  rep(i,n){
    sum += cumulative_sum[max(0ll,k-vec[i])];
  }
  return sum >= m;
}
ll calc(ll k,vector<ll> vec){
  ll sum = 0;
  ll ans = 0;
  rep(i,n){
    tmp1 = cumulative_sum[max(0ll,k-vec[i])];
    sum += tmp1;
    if(tmp1){
      ans += cumulative_vec[tmp1-1] + tmp1 * vec[i];
    }
  }
  ans -= k * (sum - m);
  return ans;
}
int main() {
  cin >> n >> m;
  vector<ll> vec(200001,0);
  rep(i,n){
    cin >> vec[i];
    cumulative_sum[vec[i]]++;
  }
  tmp1 = 0;
  rep_rev(i,100001){
    tmp1 += cumulative_sum[i];
    cumulative_sum[i] = tmp1;
  }
//  rep(i,100){
//    cout << cumulative_sum[i] << " ";
//  }
//  cout << endl;
  sort(all(vec),greater<ll>());
  tmp2 = 0;
  rep(i,100001){
    tmp2 += vec[i];
    cumulative_vec[i] = tmp2;
  }
  ll ans;
  ll ok = 0;
  ll ng = 200004;
  while(abs(ok-ng) > 1){
    ll mid = (ok + ng) / 2;
    //cout << mid << endl;
    if(solve(mid,vec) != 0){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  //cout << ok << endl;
  ans = calc(ok,vec);
  cout << ans << endl;
}


Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

struct Edge{
    ll to;
    ll cost;
};

vector<vector<Edge> > G;
ll dis[100005];
ll V,E,r;

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

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        for(auto e : G[v]){
            if(dis[e.to] > dis[v]+e.cost){
                dis[e.to] = dis[v] + e.cost;
                que.push(P(dis[e.to],e.to));
            }
        }
    }
}

int main(){
    cin >> V >> E >> r;
    G.resize(V);
    for(int i=0;i<E;i++){
        ll a,b,c;
        cin >> a >> b >> c;
        struct Edge x = { b,c };
        G[a].push_back(x);
    }

    dijkstra(r);
    rep(i,V){
        if(dis[i]==INF){
            cout << "INF" << endl;
            continue;
        }
        cout << dis[i] << endl;
    }
}


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

int main()
{
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << fixed << setprecision(6) << hypot(x1 - x2, y1 - y2) << endl;

    return 0;
}



Measured memory_bytes: 3340
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
#include <cctype>
#include <cstdlib>
using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;
typedef long long ll;

int main(int argc, char *argv[]){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;

    if(s[k-1]=='A') s[k-1]='a';
    if(s[k-1]=='B') s[k-1]='b';
    if(s[k-1]=='C') s[k-1]='c';
    if(s[k-1]=='D') s[k-1]='d';
    if(s[k-1]=='E') s[k-1]='e';
    if(s[k-1]=='F') s[k-1]='f';
    if(s[k-1]=='G') s[k-1]='g';
    if(s[k-1]=='H') s[k-1]='h';
    if(s[k-1]=='I') s[k-1]='i';
    if(s[k-1]=='J') s[k-1]='j';
    if(s[k-1]=='K') s[k-1]='k';
    if(s[k-1]=='L') s[k-1]='l';
    if(s[k-1]=='M') s[k-1]='m';
    if(s[k-1]=='N') s[k-1]='n';
    if(s[k-1]=='O') s[k-1]='o';
    if(s[k-1]=='P') s[k-1]='p';
    if(s[k-1]=='Q') s[k-1]='q';
    if(s[k-1]=='R') s[k-1]='r';
    if(s[k-1]=='S') s[k-1]='s';
    if(s[k-1]=='T') s[k-1]='t';
    if(s[k-1]=='U') s[k-1]='u';
    if(s[k-1]=='V') s[k-1]='v';
    if(s[k-1]=='W') s[k-1]='w';
    if(s[k-1]=='X') s[k-1]='x';
    if(s[k-1]=='Y') s[k-1]='y';
    if(s[k-1]=='Z') s[k-1]='z';

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))

using namespace std;

int f(int n)
{
    if (n & 1) {
        return 3 * n + 1;
    } else {
        return n / 2;
    }
}

int baket[1000005];

int main()
{
    int s;
    int i = 1;

    cin >> s;

    baket[s] = 1;
    while (baket[f(s)] == 0) {
        i++;
        
        s = f(s);
        baket[s] = i;
    }

    cout << i + 1 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void);

int main(void)
{
    int a, b, c, i, count;
    scanf("%d %d %d", &a, &b, &c);
    count = 0;
        for(i = a; i <= b; i++){
            if(c % i == 0){
                count = count + 1;
                }
                else{
                }
        }
    printf("%d\n", count);
    return(0);
}


Measured memory_bytes: 2148
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#define inf 0x3f3f3f3f
#define LL long long

using namespace std;

int main()
{
    int a[4];
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    sort(a,a+3);
    int sum=a[1]-a[0]+a[2]-a[1];
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

int main(void){
    int X;
    cin >> X;
    if(X==1) cout << 0 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3656
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		List<Integer> list = new ArrayList<>();

		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		String result = s.substring(0,k-1) + s.substring(k-1,k).toLowerCase() + s.substring(k,n);


		System.out.println(result);
	}
}


Measured memory_bytes: 21844
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a == b){
          System.out.println(a*2);
        }else if(a > b){
          System.out.println(a*2-1);
        }else{
          System.out.println(b*2-1);
        }
	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t T=0; T<v.size(); ++T){cout << " " << #v << "[" << T << "]=" << v[T];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    lint m, n;
    cin >> m >> n;
    lint ans = 0;
    if (n >= 2*m) {
        ans += m;
        n -= 2*m;
        ans += (n/4);
    }
    else {
        ans += (n/2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
h=int(input())
bin_str = format(h, 'b')
cost = 0
x = [1,0] 
l = len(bin_str)
if h >= 2:
  for i in range(0,l-1):
    cost = cost + (x[int(bin_str[l-i-1])])*2**i
print(h+cost)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))
 
using namespace std;
 
typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;
 
template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
 
const int N = 100000 + 10;
int a[N];
 
vector<int> g[N];
 
bool is_leaf(int n)
{
  return g[n].size() == 1;
}
 
lli f(int curr, int prev)
{
  if (is_leaf(curr)) return a[curr];
 
  vector<lli> b;
  each (next, g[curr]) {
    if (next == prev) continue;
    b.emplace_back(f(next, curr));
  }
 
  lli sum = accumulate(b.begin(), b.end(), 0LL);
  if (b.size() == 1) {
    if (a[curr] != b[0]) throw "";
    return b[0];
  }

  lli mx = *max_element(b.begin(), b.end());
  lli n = sum - a[curr];
  if (n > sum - mx) throw "";
  if (sum < a[curr]) throw "";
  
  lli paired = min<lli>(sum / 2, mx);
  lli passed = a[curr] * 2 - sum;
  if (paired < 0 || passed < 0 || (curr == prev && passed)) throw "";
  return passed;
}
 
int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
 
  int n;
  while (cin >> n) {
    fill(g, g + N, vector<int>());
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    for (int i = 0; i < n - 1; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    int r = 0;
    for (int i = 0; i < n; ++i) {
      if (!is_leaf(i)) { r = i; break; }
    }
    if (n == 1) {
      puts(a[0] ? "NO" : "YES");
    } else if (n == 2) {
      puts(a[0] == a[1] ? "YES" : "NO");
    } else try {
      f(r, r);
      cout << "YES" << endl;
    } catch (const char* e) {
      cout << "NO" << endl;
    }
  }
 
  return 0;
}


Measured memory_bytes: 14080
(let* ((n (read))
       (vec (make-array n :initial-element 0 :element-type 'fixnum)))
  (loop :for a :from 0 :upto (1- n) :do(setf (aref vec a) (read)))
  (sort vec #'<)
  (princ (- (aref vec (/ n 2)) (aref vec (1- (/ n 2))))))

Measured memory_bytes: 57704
#                         author:  kagemeka 
#                         created: 2019-11-08 12:38:16(JST)
## internal modules
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## external modules
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version) 

def main():
    a, b = (int(x) for x in sys.stdin.readline().split())
    if abs(a - b) <= 1:
        ans = 'Yay!'
    else:
        more_eat = max(a, b) - (min(a, b) + 1)
        remainder = 16 - (min(a, b) * 2 + 1)
        
        if more_eat <= remainder // 2:
            ans = 'Yay!'
        else:
            ans = ':('

    print(ans)

if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 3060
using System;

public class Sample20{
    public static void Main(){

            int multipleOfThree = int.Parse(Console.ReadLine());
            
             //バリデーション
            if (  multipleOfThree < 3 || 10000 < multipleOfThree){
                
                Console.WriteLine("入力された値が範囲外です。");
                Environment.Exit(0);
            }
           
           //処理
            for (int count = 1; count <= multipleOfThree ; count++){
                
                int number = count;
                
                //3で割り切れたら3の倍数なので出力
                if (number % 3 == 0) { 
                    Console.Write(" " + count);
                    continue; 
                }
                //
                while (number!=0){
                    if (number % 10 == 3) {
                        Console.Write(" "+ count);
                        break;
                    }
                    number /= 10;
                }
            }
        Console.WriteLine();
    }
}




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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
int n, m;
vll x;
int ans;

struct N {
  int t, f;
  ll v;
};
bool operator<(const N &l, const N &r) { return l.v < r.v; }

class BIT {
public:
  int n;
  vector<int> bit;
  BIT(int n_) {
    n = n_;
    bit.resize(n + 1);
  }
  // add v[a] + w
  void add(int a, int w) {
    a++;
    if (a == 0 || a > n)
      return;
    for (int x = a; x <= n; x += x & -x)
      bit[x] += w;
  }
  // [0, a)
  int sum(int a) {
    if (a == 0)
      return 0;
    int ret = 0;
    for (int x = a; x > 0; x -= x & -x)
      ret += bit[x];
    return ret;
  }
};
BIT bit(1 << 18);

class U {
public:
  int n;
  vector<int> p;
  vector<ll> v;
  vector<pair<ll, int>> s;
  U(vll a) {
    n = a.size();
    p.resize(n);
    s.resize(n);
    v = a;
    for (int i = 0; i < n; i++) {
      p[i] = i;
    }
  }
  bool connect(int a, int b, ll r) {
    int ap, bp;
    for (ap = p[a]; ap != p[ap]; ap = p[ap])
      ;
    for (bp = p[b]; bp != p[bp]; bp = p[bp])
      ;
    if (ap == bp) {
      s[ap].first = r;
      s[ap].second += 1;
      if (s[ap].first <= v[ap]) {
        bit.add(ap, -(bit.sum(ap + 1) - bit.sum(ap)));
        bit.add(ap, s[ap].second);
        ans = m - bit.sum(n);
      }
      return true;
    }
    int mi = min(ap, bp), ma = max(ap, bp);
    p[ma] = mi;
    v[mi] += v[ma];
    v[ma] = 0;
    if (r <= v[mi]) {
      bit.add(ma, -(bit.sum(ma + 1) - bit.sum(ma)));
      bit.add(mi, -(bit.sum(mi + 1) - bit.sum(mi)));
      bit.add(mi, s[mi].second + s[ma].second + 1);
      ans = m - bit.sum(n);
    } else {
      int sa = bit.sum(ma + 1) - bit.sum(ma);
      int si = bit.sum(mi + 1) - bit.sum(mi);
      bit.add(ma, -sa);
      bit.add(mi, -si);
      bit.add(mi, sa + si);
    }
    s[mi].first = r;
    s[mi].second += s[ma].second + 1;
    for (int pp = a; pp != mi;) {
      int next = p[pp];
      p[pp] = mi;
      pp = next;
    }
    for (int pp = b; pp != mi;) {
      int next = p[pp];
      p[pp] = mi;
      pp = next;
    }
    return false;
  }
  int parent(int a) {
    int ap;
    for (ap = a; ap != p[ap]; ap = p[ap])
      ;
    return p[ap];
  }
  bool query(int a, int b) { return parent(a) == parent(b); }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  x.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  U uf(x);
  vector<N> ns(m);
  for (int i = 0; i < m; i++) {
    cin >> ns[i].t >> ns[i].f >> ns[i].v;
    ns[i].t--;
    ns[i].f--;
  }
  sort(ns.begin(), ns.end());
  ans = m;
  for (int i = 0; i < m; i++) {
    uf.connect(ns[i].t, ns[i].f, ns[i].v);
  }
  cout << ans << endl;
  return 0;
}


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

ll f( ll a, ll m ){
  return a*a%m;
}

int main(){
  ll n,x,m;cin >> n >> x >> m;
  map<ll,ll> mp;
  vector<ll> v;
  ll a = x;
  v.push_back(a);
  mp[a]++;
  ll l,r;
  rep(i,1000000){
    a = f(a,m);
    if( mp[a] > 0 ){
      l = find(v.begin(),v.end(),a)-v.begin();
      r = i;
      break;
    }
    v.push_back(a);
    mp[a]++;
  }
  ll ans = 0;
  if( n-1 <= l-1 ){
    for(ll i=0;i<n;++i){
      ans += v.at(i);
    }
    cout << ans << endl;
    return 0;
  }
  for(ll i=0;i<l;++i) ans += v.at(i);
  n -= l;

  ll len = r-l+1;
  ll sum = 0;
  for(ll i=l;i<=r;++i) sum += v.at(i);

  ans += n/len*sum;
  if( n%len != 0 )
    for(ll i=l;i<=n%len+l-1;++i) ans += v.at(i);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6684
'use strict'

function main(input) {

    input = input.split(' ').map(x => Number(x))
    let a = Math.pow(100, input[0]) * input[1]
    if (input[1] == 100) {
        a += Math.pow(100, input[0]);
    }

    console.log(a)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21192
///17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define pb          push_back
#define MP          make_pair
#define int         long long
#define ll          long long
#define inf         0x3f3f3f3f
#define MOD         1000000007
#define ld          long double
#define eb          emplace_back
#define pii         pair<int,int>
#define ull         unsigned long long
#define all(v)      v.begin(), v.end()
#define f(i,x,n)    for(int i=x;i<n;i++)
#define fr(i,x,n)   for(int i=x;i>=n;i--)
#define fastio      ios::sync_with_stdio(false)

#define n_l '\n'
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define debug(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl

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

int32_t main() {
    //IO();
    fastio;
    cin.tie(nullptr);
    cout.tie(nullptr);
    char x; cin >> x;
    if (isupper(x)) {
    	cout << "A" << endl;
    } else cout << 'a' << endl;
    

    return 0;
}


Measured memory_bytes: 3612
<?php
trim(fgets(STDIN));
$A = explode(" ",trim(fgets(STDIN)));
$sum = array_sum($A);

$m = trim(fgets(STDIN));
while($m > 0){
list($n,$x) = explode(" ",trim(fgets(STDIN)));
$ans = $sum + $x - $A[$n - 1];
echo $ans . PHP_EOL;
--$m;
}


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

int main()
{
   int n,t=-1,p,i,c=0,f;
   cin >> p;

   for(i=1;i<=p;i++)
   {
       n=i;
       while(n%2==0&&n!=0)
       {
           c++;
           n=n/2;
       }
      if(c>t)
     {
         t=c;f=i;
     }
      c=0;
   }

   cout << f << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	int r, c; cin >> r >> c;
	vector< vector<int> > a(r + 1, vector<int>(c + 1));
	for (int i = 0; i < r; i++)
		for (int j = 0; j < c; j++) {
			cin >> a[i][j];
			a[i][c] += a[i][j];
			a[r][j] += a[i][j];
		}
	for (int j = 0; j < c; j++)
		a[r][c] += a[r][j];
	for (int i = 0; i <= r; i++)
		for (int j = 0; j <= c; j++)
			cout << a[i][j] << (j < c ? ' ' : '\n');
}

Measured memory_bytes: 1256
#include <iostream>

using namespace std;

int main(){
  int k,s;
  cin >> k >> s;

  int ans = 0;
  for(int i=0; i<=k; i++){
    for(int j=0; j<=k; j++){
      int x = s - j - i;
      if(s == i+j+x && 0 <= x && x <= k ) ans++;
    }
  }

  cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;


int main(){
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int ans = min(B, D) - max(A, C);
	if (ans < 0){
		cout << 0 << endl;
	}
	else{
		cout << ans << endl;
	}
	return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int a,b; cin>>a>>b;
  if (a<=8 && b<=8) out("Yay!");
  out(":(");
  

  return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  string msg[3] = {
	"Opened by ",
	"Closed by ",
	"Unknown "
  };
  int t = 0;
  set<string> s;
  int N, M; cin >> N;
  REP(i,N){ string x; cin >> x; s.insert(x);}
  cin >> M;
  REP(i,M){
	string in; cin >> in;
	if(s.find(in) != s.end()){
	  cout << msg[t] << in << endl;
	  t = 1 - t;
	}
	else
	  cout << msg[2] << in << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1236
n = int(input())
L = []
for _ in range(n):
    x, y, h = map(int, input().split())
    if h > 0:
        sx, sy, sh = x, y, h
    L.append((x, y, h))
for cy in range(101):
    for cx in range(101):
        d = abs(sx - cx) + abs(sy - cy)
        H = sh + d
        for x, y, h in L:
            if h == 0:
                if H > abs(x - cx) + abs(y - cy):
                    break
            else:
                if H - abs(x - cx) - abs(y - cy) != h:
                    break
        else:
            print(cx, cy, H)
            exit()


Measured memory_bytes: 3064
n=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
key=2**18
from heapq import heappop, heappush
push = lambda x,i: heappush(BB,-(x*key+i))
BB=[]

for i,b in enumerate(B):
  push(b,i)

ans=0
while BB:
  bb=heappop(BB)
  bb=-bb
  b,ind=bb//key,bb%key
  ai=A[ind]
  if b<ai:
    ans=-1
    break
  d=B[(ind-1)%n]+B[(ind+1)%n]
  dd=(b-ai)//d
  if dd==0:
    if b==ai:
      continue
    ans=-1
    break
  ans+=dd
  B[ind]-=d*dd
  push(B[ind],ind)
  
print(ans)


Measured memory_bytes: 121208
from itertools import permutations, combinations, chain
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

def dpinit(ps, val=0):
    import copy
    res = [val for i in [0]*ps[-1]]
    for i in ps[:-1][::-1]:
        res = [copy.deepcopy(res) for k in [0]*i]
    return res

inf = 10**10
dp = [defaultdict(lambda : inf) for i in range(2**N+1)]
dp[0][0] = 0

for b in range(2**N):
    c = bin(b).count('1')
    for i in range(1,N+1):
        p = N-i
        f = 1<<p
        if b & f:
            continue
        nb = b | f
        k = bin(b % f).count('1')
        v = A[i-1] if (i-c) % 2 == 1 else B[i-1]
        for val, inv in dp[b].items():
            if val <= v:
                dp[nb][v] = min(dp[nb][v], inv+abs(c+1-(i+k)))

if not dp[2**N-1]:
    print(-1)
    exit()
ans = min(dp[2**N-1].values())
print(ans if ans != inf else -1)




Measured memory_bytes: 220680
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll mod = 1e9+7;

int main()
{
    ll N; cin >> N;
    vll A(N); rep(i, N) cin >> A[i];
    vll cnt(61, 0);

    rep(i, 61) {
        rep(j, N) {
            cnt[i] += ((A[j] & (1ll << i)) > 0);
        }
    }

    ll ans = 0;
    rep(i, 61) {
        ll a = cnt[i], b = N - cnt[i];
        (ans += (((a * b) % mod) * ((1LL << i) % mod)) % mod) %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
def dist(a, b):
	res = 0
	for i in range(D):
		res += (a[i] - b[i]) ** 2
	res = res ** 0.5
	return res


N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N - 1):
	for j in range(i + 1, N):
		if dist(X[i], X[j]).is_integer():
			ans += 1
print(ans)

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


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

    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);

    for(int i = 0; i < N; i++){
    cin >> A.at(i);
      A.at(i) --;
    }

    for(int i = 0; i < N; i++){
    cin >> B.at(i);
    }

    for(int i = 0; i < N-1; i++){
    cin >> C.at(i);
    }

    int Ans = 0;

    for(int i = 0; i < N; i++){
        Ans += B.at(A.at(i));
    }
  
      for(int i = 0; i < N-1; i++){
        if(A.at(i+1) - A.at(i) == 1) Ans += C.at(A.at(i));
      }

    cout << Ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long ll;
map<int, int>mp;
vector<int>v;

int main()
{
	ll N;
	cin >> N;
	for (ll i = 2; i*i < N; i++)
	{
		while (N%i == 0)
		{
			if (mp.find(i) != mp.end())
				mp[i] += 1;
			else
			{
				mp.insert({ i,1 });
				v.push_back(i);
			}
			N /= i;
		}
	}
	if (N > 1)
	{
		mp.insert({ N,1 });
		v.push_back(N);
	}
	int plus[45] = { 0, };
	int n=2, cnt = 2, value = 1;
	for (int i = 1; i < 45; i++)
	{
		plus[i] = value;
		cnt--;
		if (cnt == 0)
		{
			n += 1;
			cnt = n;
			value++;
		}
	}
	int ans = 0;
	for (auto i : v)
	{
		ans += plus[mp[i]];
	}
	cout << ans;
}

Measured memory_bytes: 3604
x,k,d=map(int,input().split())

if abs(x)>=k*d: print(abs(x)-k*d)
else:
    if (k-abs(x)//d)%2==0: print(abs(x)-d*(abs(x)//d))
    else: print(abs(abs(x)-d*(abs(x)//d)-d))


Measured memory_bytes: 9172
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  int H,W;
  cin>>H>>W;
  
  char A[H+2][W+2];
  int DIS[H+2][W+2];
  queue<pair<int,int>> Q;
  for(int i=1; i<=H; ++i){
    for(int j=1; j<=W; ++j){
      cin>>A[i][j];
      DIS[i][j]=MAX;
      if(A[i][j]=='#'){
        Q.emplace(i,j);
        DIS[i][j]=0;
      }
    }
  }
  
  while(!Q.empty()){
    auto P=Q.front();
    Q.pop();
    REP(i,4){
      int ny=P.first+dy[i],nx=P.second+dx[i];
      if(nx<=0||nx>=W+1||ny<=0||ny>=H+1) continue;
      if(DIS[ny][nx]<MAX) continue;
      DIS[ny][nx]=DIS[P.first][P.second]+1;
      Q.emplace(ny,nx);
    }
  }
  
  int ans=0;
  for(int i=1; i<=H; ++i){
    for(int j=1; j<=W; ++j){
      chmax(ans,DIS[i][j]);
    }
  }
  
  co(ans);
  return 0;
}

Measured memory_bytes: 13328
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;

int main()
{
	int n;
	cin >> n;
	char a[n];
	rep(i,n){
		cin >> a[n];
		if(a[n] == 'Y'){
			puts("Four");
			return 0;
		}
	}
	puts("Three");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//一个万能库
using namespace std;

int a,b,c,len;

int main()
{
    scanf("%d%d",&a,&b);//读入~~
    c=b;//备份一个b
    while(c>0)//用一个while求出b的位数
    {
        c/=10;//删掉末尾
        len++;//位数加1
    }
    a=a*pow(10,len)+b;//pow()函数用于求幂
                      //至于为什么是10的位数次方
                      //嗯...好像是因为位值原理...
    if(sqrt(a)==floor(sqrt(a)))printf("Yes");//判断部分比较a的平方和它平方的整数部分，如相等，就是完全平方数，输出Yes
    else printf("No");//否则输出No
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

        signed main() {
        int n,k,s1,s2,ans=-1,ans2;
        cin>>n;
        int a[n],b[n];
       
        for(int i=0;i<n;i++)cin>>a[i];
        for(int i=0;i<n;i++)cin>>b[i];
        for(int i=0;i<n;i+=2)swap(a[i],b[i]);
        if(n==1){
            cout<<0;
            return 0;
        }
         pair<int,int> p[n-n/2],q[n/2];
         int num[n];
        for(long long i=0;i<(1ll<<n);i++){
            k=0;
            for(int j=0;j<n;j++ )if(i&(1ll<<j))k++;
            if(k!=n-n/2)continue;
            s1=0;s2=0;
            for(int j=0;j<n;j++){
                if(i&(1ll<<j)){
                    p[s1]=make_pair(b[j],j);
                    s1++;
                }else{
                    q[s2]=make_pair(a[j],j);
                    s2++;
                }
            }
            ans2=0;
            sort(p,p+n-n/2);sort(q,q+n/2);
            for(int i=0;i<n-n/2;i++){
                if(i<n/2&&p[i].first>q[i].first){
                    ans2=1;
                    break;
                }
                if(i+1<n-n/2&&p[i+1].first<q[i].first){
                    ans2=1;
                    break;
                }
            }
            if(ans2)continue;
            for(int j=0;j<n-n/2;j++)num[p[j].second]=j*2;
            for(int j=0;j<n/2;j++)num[q[j].second]=j*2+1;
            ans2=0;
            for(int j=0;j<n;j++){
                for(int q=n-1;q>j;q--){
                    if(num[q-1]>num[q]){
                        swap(num[q-1],num[q]);
                        ans2++;
                    }
                }
            }
        //   cerr<<ans2<<' ';
            if(ans==-1)ans=ans2;
            else ans=min(ans2,ans);

        }
        cout<<ans;
         return 0;

        }


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

main()
{
    int k;
    cin>>k;
    priority_queue<pair<int,int> >q1;
    vector<int>r(k);
    vector<int>used(k);
    q1.push(make_pair(0,0));

    while(!q1.empty())
    {
        pair<int,int>q=q1.top();
        q1.pop();
        swap(q.first,q.second);
        q.second*=-1;


        if(used[q.first]!=0)
        continue;
        used[q.first]=1;
      //  cout<<q.first<<' '<<q.second<<endl;


        for(int i=0;i<10;i++)
        {
            int x=(q.first*10+i)%k;
            if(r[x]>q.second+i||r[x]==0)
            {

                r[x]=q.second+i;
                q1.push(make_pair(-1*r[x],x));
            }
        }

    }
    cout<<r[0];




}


Measured memory_bytes: 7792
n,m=gets.split.map(&:to_i)
lmax = 0
rmin = n
m.times do
    l,r = gets.split.map(&:to_i)
    lmax = (lmax<l)?l:lmax
    rmin = (rmin>r)?r:rmin
end
p (lmax<=rmin)?rmin-lmax+1:0


Measured memory_bytes: 1788
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#include <bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int cnt[200000];
int main(){
    int n,m;
    cin >> n >> m;
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int x;
            cin >> x;
            cnt[x]++;
        }
    }
    int ans = 0;
    rep(i,10000){
        if(cnt[i] == n)ans++;
    }
    cout << ans << endl;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

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

signed main()
{
	int n;
	cin >> n;

	vi a(n);
	int cnt = 0;
	rep(i, 0, n){
		cin >> a[i];
		if(a[i] < 0) cnt++;
		a[i] = abs(a[i]);
	}

	sort(all(a));
	int ans = cnt%2 ? -a[0] : a[0];
	rep(i, 1, n){
		ans += a[i];	
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
	int N, A;
	cin >> N >> A;
	int change; // 金額を500円で割ったあまり
	change = N % 500;
	if(change<=A) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define all(v) v.begin(),v.end()
#define fio() ios::sync_with_stdio(0);cin.tie(0);
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define fornn(i,a,n) for(ll i=a;i<=n;i++)
#define pb push_back
#define MAXN 100005LL
#define INF 1000000005LL
ll A[2][500];
ll calc(ll i,ll j){
	if(i==0 && j==0)
		return A[i][j];
	if(i==0)
		return A[i][j]+calc(i,j-1);
	if(j==0)
		return A[i][j]+calc(i-1,j);
	else
		return A[i][j]+max(calc(i-1,j),calc(i,j-1));
}
inline void solve(){
	ll n;
	cin>>n;
	for(ll i=0;i<2;i++)
		for(ll j=0;j<n;j++)
			cin>>A[i][j];
	ll ans=calc((1),(n-1));
	cout<<ans<<endl;
}
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("output.txt","w",stdout);
	// freopen("input.txt","r",stdin);
	// #endif
	fio();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
} 

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,K;
vint G[2222];

int dist[2222];

int calc(int a,int b){
    fill_n(dist,N,INT_MAX);
    dist[a]=dist[b]=0;
    queue<int>que;
    que.push(a);que.push(b);
    while(que.size()){
        int v=que.front();
        que.pop();
        for(auto u:G[v]){
            if(dist[u]!=INT_MAX)continue;
            dist[u]=dist[v]+1;
            que.push(u);
        }
    }

    int ret=0;
    rep(i,N)if(dist[i]>K/2)ret++;
    return ret;
}

signed main(){
    cin>>N>>K;
    vint A(N-1),B(N-1);
    rep(i,N-1){
        cin>>A[i]>>B[i];
        A[i]--;B[i]--;
        G[A[i]].pb(B[i]);
        G[B[i]].pb(A[i]);
    }

    int ans=INT_MAX;
    if(K&1){
        rep(i,N-1)chmin(ans,calc(A[i],B[i]));
    }
    else{
        rep(i,N)chmin(ans,calc(i,i));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384