akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>

using namespace std;

struct Cell{
	double x,y,z,r;
	Cell(){}
	Cell(double x,double y,double z,double r):x(x),y(y),z(z),r(r){}
};

double getdist(const Cell& a,const Cell& b)
{
	double dx=a.x-b.x,dy=a.y-b.y,dz=a.z-b.z;
	double d=sqrt(dx*dx+dy*dy+dz*dz);
	return max(.0,d-(a.r+b.r));
}

int main()
{
	for(int n;cin>>n,n;){
		vector<Cell> cs(n);
		for(int i=0;i<n;i++)
			cin>>cs[i].x>>cs[i].y>>cs[i].z>>cs[i].r;
		vector<vector<double> > dist(n,vector<double>(n));
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				dist[i][j]=getdist(cs[i],cs[j]);
		
		vector<double> ds(n,1e10),fs(n);
		ds[0]=0;
		for(int i=0;i<n;i++){
			int cur=-1;
			for(int j=0;j<n;j++)
				if(!fs[j] && (cur==-1 || ds[cur]>ds[j]))
					cur=j;
			fs[cur]=1;
			for(int j=0;j<n;j++)
				if(!fs[j])
					ds[j]=min(ds[j],dist[cur][j]);
		}
		
		cout<<fixed<<setprecision(3)<<accumulate(ds.begin(),ds.end(),.0)<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
/*
AUTHOR: Aman Raj
LANG: C++
*/

using namespace std;

typedef   long long  int ll;
#include <bits/stdc++.h>


//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define all(a) a.begin(),a.end()
//#define mod 998244353


#define mod   1000000007

#define inf 1e18
//#define mod 3
#define flush fflush(stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<ll, ll, hash< ll > > ht;

// find_by_order()  // order_of_key
typedef tree<
    ll,
    null_type,
    less<ll>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;






ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;c%=mod;if(b%2==1) c*=a;c%=mod;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }



 struct less_then_greater {
    template<typename T, typename U>
    bool operator()(T const& lhs, U const& rhs) const {
        if (lhs.first < rhs.first) return true;
        if (rhs.first < lhs.first) return false;
        return lhs.second > rhs.second;
    }
};
 /*std::priority_queue<std::pair<int, int>,
                    std::vector<std::pair<int, int>>,
                    less_then_greater
                   > pq;*/
  /*   #define MAXN 1000001
ll spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)

        // marking smallest prime factor for every
        // number to be itself.
        spf[i] = i;

    // separately marking spf for every even
    // number as 2
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        // checking if i is prime
        if (spf[i] == i)
        {
            // marking SPF for all numbers divisible by i
            for (int j=i*i; j<MAXN; j+=i)

                // marking spf[j] if it is not
                // previously marked
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}
vector<ll> getFactorization(ll x)
{
    vector<ll> ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}
*/
// take multiset of all edges
// meanwhile for all cc keep record of all edges in multiset too which can be used to digest
// one line or two lines
//

 int main()
 {  ll n;cin>>n;
     ll a=0,w=0,t=0,r=0;
      for(ll i=0;i<n;i++)
      {
          string s;cin>>s;
           if(s[0]=='A')a++;
           else if(s[0]=='W')w++;
           else if(s[0]=='T')t++;
           else r++;
      }
      cout<<"AC x "<<a<<endl;
      cout<<"WA x "<<w<<endl;
      cout<<"TLE x "<<t<<endl;
      cout<<"RE x "<<r<<endl;
     return 0;
 }



Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define W V<long long>
#define L long long
#define R(n) for(L i=0;i<n;i++)
W S(V<W>&p,L E){if(!E){return{1,0};}V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}V<W>c(4,W(3));c[3]=W(3,1);R(2){for(W x:T[i]){L Q=(2*x[0]+x[1])%3;c[i][Q]^=1;}}R(2){if(c[1-i]==c[2]||c[1-i]==c[3]){W ans=S(T[i],E-1);ans[0]*=2;ans[1]*=2;ans[1]+=i;return ans;}}for(W&v:p){v[0]++;}W A=S(p,E);A[0]--;return A;}
int main(){L M=2e17;L n;cin>>n;V<W>p(n);R(n){L a,b;cin>>a>>b;p[i]={a+M,b+M};}W Q=S(p,70);cout<<Q[0]-M<<" "<<Q[1]-M;}

Measured memory_bytes: 37052
var
    s:string;
    i,j,k:longint;
    b:boolean;
begin
    readln(s);
    b:=false;
    for i:=1 to length(s) do
    begin
        if(not(b))and(s[i]='C')then
        b:=not(b);
        if(b)and(s[i]='F')then
        begin
            writeln('Yes');
            exit;
        end;
    end;
    writeln('No');
end.


Measured memory_bytes: 128
#include <iostream>

int main()
{
  int a, b, c, x;
  int i, j, k, count = 0;

  std::cin >> a >> b >> c >> x;

  for (i = 0; i <= a; i++)
  {
    for (j = 0; j <= b; j++)
    {
      for (k = 0; k <= c; k++)
      {
        if (500 * i + 100 * j + 50 * k == x)
        {
          count++;
        }
      }
    }
  }
  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;
using uint64 = unsigned long long;
using int128 = __int128_t;
using uint128 = __uint128_t;
using float64 = long double;

template <typename T = int>
struct Range {
  struct RangeIterator {
    T i, step;

    RangeIterator(T i, T step) : i{i}, step{step} {}

    T &operator*() { return i; }
    RangeIterator &operator++() {
      i += step;
      return *this;
    }
    bool operator!=(const RangeIterator &rhs) const {
      return (step > 0 && i < rhs.i) || (step < 0 && i > rhs.i);
    }
  };

  T start, stop, step;

  Range(T start, T stop, T step) : start{start}, stop{stop}, step{step} {}
  Range(T start, T stop) : Range(start, stop, 1) {}
  Range(T stop) : Range(0, stop, 1) {}

  RangeIterator begin() const { return RangeIterator{start, step}; }
  RangeIterator end() const { return RangeIterator{stop, step}; }
};

template <typename T>
inline void ChooseMax(T &a, const T &b) {
  a = std::max(a, b);
}

template <typename T>
inline void ChooseMin(T &a, const T &b) {
  a = std::min(a, b);
}

template <typename T>
std::ostream& operator<<(std::ostream& ostr, const std::vector<T>& vec) {
  ostr << "[";
  for (auto itr = vec.begin(); itr != vec.end(); itr++) {
    if (itr != vec.begin()) {
      ostr << ", ";
    }
    ostr << *itr;
  }
  ostr << "]";
  return ostr;
}

template <typename K, typename V>
std::ostream& operator<<(std::ostream& ostr, const std::map<K, V>& map) {
  ostr << "{";
  for (auto itr = map.begin(); itr != map.end(); itr++) {
    if (itr != map.begin()) {
      ostr << ", ";
    }
    ostr << itr->first << " => " << itr->second;
  }
  ostr << "}";
  return ostr;
}

template <typename T>
std::ostream& operator<<(std::ostream& ostr, const std::set<T>& set) {
  ostr << "{";
  for (auto itr = set.begin(); itr != set.end(); itr++) {
    if (itr != set.begin()) {
      ostr << ", ";
    }
    ostr << *itr;
  }
  ostr << "}";
  return ostr;
}

template <typename F, typename S>
std::ostream& operator<<(std::ostream& ostr, const std::pair<F, S>& pair) {
  ostr << "(" << pair.first << ", " << pair.second << ")";
  return ostr;
}

int64 GCD(int64 a, int64 b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

void SolveProblem() {
  int64 n, k;
  std::cin >> n >> k;

  if (n >= k) {
    n = n % k;
  }
  n = std::min(n, k - n);
  std::cout << n << std::endl;
}

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

  std::cout.setf(std::ios::fixed);
  std::cout.precision(10);

  SolveProblem();

  return 0;
}


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

typedef long long ll;
const int maxn = 2e5 + 10;
int n;
ll ans, a[maxn];
map<ll, ll> cnt;

int main() {
    scanf("%d", &n);
    ll sum = 0;
    cnt[0] = 1;
    for (int i = 1; i <= n; i++) {
        ll x;
        scanf("%lld", &x);
        sum += x;
        cnt[sum]++;
        ans += cnt[sum] - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12800
import re

s = input()

s = re.sub('eraser','',s)
#print(s)
s = re.sub('erase','',s)
#print(s)
s = re.sub('dreamer','',s)
#print(s)
s = re.sub('dream','',s)
#print(s)


if s == "":
    print("YES")
else:
    print("NO")


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

typedef long long ll;
typedef pair<int,int> P;

int main() {
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    if (a*2 > w || b*2 > h) {
        cout << "No" << endl;
        return 0;
    }
    vector<vector<bool>> ans(h,vector<bool>(w,false));
    for (int i = 0;i < b;++i) for (int j = 0;j < w;++j) ans[i][j] = true;
    for (int i = 0;i < h;++i) for (int j = 0;j < a;++j) ans[i][j] = !ans[i][j];
    for (int i = 0;i < h;++i) {
        for (int j = 0;j < w;++j) cout << ans[i][j];
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 1408
target = input()
length = len(target)
binary = length - 1
target_list = []
answers = 0
for i in range(length):
    if i:
        target_list.append("")
    target_list.append(target[i])
for bit in range(2 ** binary):
    temp = target_list.copy()
    for i in range(binary):
        if bit & (1 << i):
            temp[1 + 2 * i] = "+"
    # print(temp, bit)
    answers += eval("".join(temp))
print(answers)

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

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

    if(N == floor(floor(N/1.08)*1.08)){
        cout <<floor(round(N/1.08)) << endl;
    }else if(N == floor(ceil(N/1.08)*1.08)){
        cout <<floor(ceil(N/1.08)) << endl;
    }
    else{
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
march = [0] * 5
for i in range(N):
    tmp = input()
    if tmp[0] == 'M' :
        march[0] += 1
    elif tmp[0] == 'A' :
        march[1] += 1
    elif tmp[0] == 'R' :
        march[2] += 1
    elif tmp[0] == 'C' :
        march[3] += 1
    elif tmp[0] == 'H' :
        march[4] += 1

total = 0
for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            total += march[i] * march[j] * march[k]
print(total)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a = 0, b = 0, c = 0, d = 0, E;
  cin >> N;
  string x;
  
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x == "P" && a == 0) {
      a++;
    }
    else if (x == "W" && b == 0) {
      b++;
    }
    else if (x == "G" && c == 0) {
      c ++;
    }
    else if (x == "Y" && d == 0) {
      d++;
    }
  }
  
  E = a + b + c + d;
    
  if (E == 3) {
    cout << "Three" << endl;
  }
  else if ( E == 4) {
    cout << "Four" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N;
  cin >> N;
  int ans = N * (N + 1);
  ans /= 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# from https://atcoder.jp/contests/abc108/submissions/4342595
import math


def main():
    l = int(input())
    n = math.floor(math.log2(l)) + 1
    e = []
    for v in range(n-1):
        v2 = 2 ** v
        e.append([v + 1, v + 2, 0])
        e.append([v + 1, v + 2, v2])
        if (l >> v) & 1:
            e.append([v + 1, n, l - v2])
            l -= v2
    print(n, len(e))
    for x in e:
        print(*x)


main()


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

int main() {
  int L,R,d;
  cin >> L >> R >> d;
  if (L%d==0) {
    cout << R/d-L/d+1 << endl;
  }
  if (L%d!=0) {
    cout << R/d-L/d << endl;
  }
}

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

main() {
    int N; cin >> N; bool can=false;
    for(int i=0;i<=N/4;i++){
        if(i*4==N || (N-i*4)%7==0)
        {can = true; break;}
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl; 

    return 0;
}


Measured memory_bytes: 256
e = [[int(i) for i in input().split()] for i in range(2)]
max_count = 999999

for i in range(e[0][0]):
    tmp = e[1][i]
    count = 0

    while True:
        tmp, m = divmod(tmp, 2)
        if m == 1:
            break

        count += 1

    if count < max_count:
        max_count = count

print(max_count)


Measured memory_bytes: 3060
import sys
S = input()
T = input()
S_list = list(S)
T_list = list(T)
S_lengh = len(S)
for i in range(S_lengh):
  if S_list[i] == T_list[i]:
    pass
  else:
    print("No")
    sys.exit()
print("Yes")

Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
int N,A,B,m[2222],ans;
int ABS(int a){return a>0?a:-a;}
int main(){
    cin>>N>>A>>B;
    for(int i=0;i<N;i++){
        cin>>m[i];
    }
    ans=ABS(m[N-1]-B);
    for(int i=0;i<N-1;i++){
        int tmp=ABS(m[N-1]-m[i]);
        for(int j=i+1;j<N-1;j++){
            tmp=min(tmp,ABS(m[N-1]-m[j]));
        }
        ans=max(ans,tmp);
    }
    cout<<ans<<'\n';
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  if(S == "Sunny"){
    cout << "Cloudy" << endl;
  }else if(S == "Cloudy"){
    cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,ans=0;
  cin >> n >> m;
  long long a[n],b[n];
  pair<long long, long long> p[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    p[i] = make_pair(a[i], b[i]);
  }
  sort(p,p+n);
  for(int i=0;i<n;i++){
    ans+=p[i].first*min(p[i].second, m);
    m-=p[i].second;
    if(m<=0) break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
#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.at(i);
    }
    
    bool can = true;
    int count = 1;
    int x = a.at(0);
    
    while(can){
        if (count == N){
            cout << "-1" << endl;
            break;
        }
        else{
            if (x == 2){
                cout << count << endl;
                break;
            }
            else{
                count ++;
                x = a.at(x-1);
            }
        }
    }
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

vector<int> visited;
void dfs(int i, const vector<vector<int>> &g, vector<int> &order){
  if(visited[i]) return;
  visited[i]=true;
  for(int j: g[i])if(visited[j]==false) dfs(j, g, order);
  order.push_back(i);
}

void dfs2(int i, const vector<vector<int>> &rev_g, vector<int> &par, int itr){
  if(par[i]>=0) return;
  par[i]=itr;
  for(int j: rev_g[i]){
    if(par[j]<0) dfs2(j, rev_g, par, itr);
  }
}

int main(){

  int n, m; cin>> n>> m;
  vector<vector<int>> g(n);
  vector<vector<int>> rev_g(n);
  rep(_, m){
    int a, b; cin>> a>> b;
    g[a].push_back(b);
    rev_g[b].push_back(a);
  }

  vector<int> order;
  visited.resize(n, 0);
  rep(i, n)if(visited[i]==false) dfs(i, g, order);
  reverse(order.begin(), order.end());
  vector<int> par(n, -1);
  int _itr=0;
  for(int i: order){
    if(par[i]<0){
      dfs2(i, rev_g, par, _itr++);
    }
  }


  int q; cin>> q;
  while(q--){
    int a, b; cin>> a>> b;
    // cout<< par[a]<< " "<< par[b]<< endl;
    if(par[a]==par[b]) cout<< 1<< endl;
    else cout<< 0<< endl;
  }

  return 0;
}


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

int main() {
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N;
    cin >> N;
    vector<unsigned long> weight(N);
    {
        vector<unsigned long> hoge(N), fuga(N, 1), piyo(N, 1);
        iota(hoge.begin(), hoge.end(), 1UL);
        partial_sum(hoge.rbegin(), hoge.rend() - 1, fuga.rbegin() + 1, [&MOD](auto a, auto b){return a * b % MOD;});
        partial_sum(hoge.begin(), hoge.end() - 1, piyo.begin() + 1, [&MOD](auto a, auto b){return a * b % MOD;});
        for(unsigned long i = 0; i < N; ++i)weight[i] = fuga[i] * piyo[i] % MOD;
    }
    vector<unsigned long> A(N);
    for(auto& i : A)cin >> i;
    partial_sum(weight.begin(), weight.end(), weight.begin(), [&MOD](auto a, auto b){return (a + b) % MOD;});
    unsigned long ans{0};
    for(unsigned long i = 0; i < N; ++i)ans += A[i] * (weight[i] + weight[N - i - 1] + MOD - weight[0]) % MOD;
    cout << ans % MOD << endl;
    return 0;
}

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

int md(int x1, int y1, int x2, int y2){
    int d = 0;
    d = max(x1-x2, x2-x1) + max(y1-y2, y2-y1);
    return d; 
}

int main () {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int> > S(N);

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

    vector<pair<int, int> > P(M);
    for(int i=0; i<M; i++){
        cin >> P.at(i).first >> P.at(i).second;
    }

    vector<vector<int> > A(N);
    vector<int> C(N,0);
    
    for(int i=0; i<N; i++){
        A.at(i).resize(M);
        for(int j=0; j<M; j++) A.at(i).at(j) = md(S.at(i).first, S.at(i).second, P.at(j).first, P.at(j).second);
        for(int j=0; j<M; j++){
            if(A.at(i).at(C[i]) > A.at(i).at(j)) C[i] = j;
        }
    }

    for(int i=0;i<N; i++){
        cout << C[i]+1 << endl;
    }
    return 0;    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	 cin>>n;
	 vector<int> vi,sor;
	int ma3 = -1;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a
		;vi.push_back(a);
	}
	sor = vi;
	sort(sor.begin(),sor.end());
	for(int i=0;i<vi.size();i++)
	{
		int k = vi[i];
		int ma = n-1;
		if(k == sor[n-1])
		{
			ma--;
		}
		cout<<sor[ma]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


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

    for(int i = 0; i < s.size(); i++){
        cout << 'x';
    }
    cout << endl;

    return 0;

}


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

int main(){
	int n;
	cin>>n;
  	int a,b,c;
  vector<int> dp(n);
  for(int i=0;i<n;i++){
    if(i<=2){
      	if(i==0){
          cin>>a;
          dp[0]=0;
        }
    	if(i==1){
          cin>>b;
          dp[1]=abs(b-a);
        }
      	if(i==2){
        	cin>>c;
          	dp[2]=min(dp[i-1]+abs(c-b), dp[i-2]+abs(c-a));
        }
    }
    else{
      	a=b;
        b=c;
        cin>>c;
        dp[i]=min(dp[i-1]+abs(c-b), dp[i-2]+abs(c-a));
     }    
    
  }
  cout << dp[n-1]<<endl;
}


Measured memory_bytes: 640
s = gets.chomp
s = s.split(//).map(&:to_s)

i = 0
j = s.length - 1
h = 0
while j >= i
    #puts "si:#{s[i]}"
    #puts "sj:#{s[j]}"
    h = h + 1 if s[i] != s[j]
    i = i + 1
    j = j - 1
end

puts h

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
void solve() {
	int  a, b;
	cin >> a >> b;
	cout << (a>b?"safe":"unsafe");
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}






Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll a,b;
  cin>>a>>b;
  if(a>0 && b>0){
    cout << "Positive" << endl;
    return 0;
  }
  if(a < 0 && b < 0){
    if(((b-a)+1) % 2== 0){
      cout << "Positive" << endl;
      return 0;
    }
    else{
      cout << "Negative" << endl;
      return 0;
    }
  }
  if(a <= 0 && 0 <= b){
    cout << "Zero" << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n;

    scanf("%d ",&n);
    // o n%10 eh pq o valor maximo eh 999

    if(n%10==3){
        printf("bon");
    }else if((n%10==2) || (n%10==4) || (n%10==5) || (n%10==7) || (n%10==9)){
        printf("hon");
    }else if((n%10==0) || (n%10==1) || (n%10==6) || (n%10==8)){
        printf("pon");
    }



    return 0;
}


Measured memory_bytes: 1736
module Main where

import Data.Functor ((<$>))

main = do
  [a, b] <- map read . words <$> getLine
  let typer :: Int
      typer = a
  let op = case compare a b of
        LT -> "<"
        GT -> ">"
        _  -> "=="
  putStrLn $ "a " ++ op ++ " b"



Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(void)
{
  int c;
  cin >> c;
  
  if(c%2 == 1){
    cout << (c/2) * (c/2+1) << endl;
  }
  else{
    cout << (c/2) * (c/2) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert
#define aer(v) (v).erase((v).begin(),(v).end()) 

//{
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...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int dp[3333][3333];
pint table[3333][3333];

main(){
	string s,t;cin>>s>>t;
	rep(i,s.size()){
		rep(j,t.size()){
			if(s[i]==t[j]){
				dp[i+1][j+1]=dp[i][j]+1;
				table[i+1][j+1]={i,j};
			}
			else{
				if(dp[i][j+1]>dp[i+1][j]){
					dp[i+1][j+1]=dp[i][j+1];
					table[i+1][j+1]={i,j+1};
				}else{
					dp[i+1][j+1]=dp[i+1][j];
					table[i+1][j+1]={i+1,j};
				}
			}
		}
	}
	/*rep(i,s.size()+2){
		rep(j,t.size()+2){
			cerr<<dp[i][j];
		}
		cerr<<endl;
	}
	rep(i,s.size()+2){
		rep(j,t.size()+2){
			cerr<<'{'<<table[i][j].fi<<','<<table[i][j].se<<'}';
		}
		cerr<<endl;
	}*/
	int p=s.size(),q=t.size();string ans;
	//debug(p,q);
	while(p||q){
		pint x;
		x=table[p][q];
		if(x.fi+1==p&&x.se+1==q)ans+=s[x.fi];
		p=x.fi;q=x.se;
		//debug(p,q);
	}
	//dump(dp[s.size()][t.size()]);
	rev(all(ans));dans;
}






Measured memory_bytes: 237824
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    a = int(input())
    b = int(input())
    c = int(input())
    target = int(input())
    count=0

    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                if (500*i)+(100*j)+(50*k)==target:
                    count+=1
                else:
                    continue
    print(count)

if __name__=="__main__":
    main()

Measured memory_bytes: 9204
N,T = map(int, input().split())
grid = []
ans = 100000
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    if array[1] <= T:
      ans = min(ans,array[0])
if ans == 100000:
  print('TLE')
else:
  print(ans)

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

int main(){
    long long int n,a,b;
    cin >> n >> a >> b;
    if((n==1 && a!=b) || a > b){
        cout << 0 << endl;
    }else{
        cout << a-b +(n-1)*(b-a) +1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int sum = 0;
		int max = 0;
		int[] p = new int[N];
		for (int i = 0; i < N; i++) {
			p[i] = sc.nextInt();
			sum += p[i];
			max = Math.max(max, p[i]);
		}

		sum -= max / 2;

		System.out.println(sum);
	}
}

Measured memory_bytes: 21716
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Russian Flag
 */
public class Main {

	static final int W = 0;
	static final int B = 1;
	static final int R = 2;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		line = br.readLine();

		int N, M;
		N = parseInt(line.substring(0, line.indexOf(' ')));
		M = parseInt(line.substring(line.indexOf(' ') + 1));
		int[][] wbr = new int[N][3];

		for (int i = 0; i < N; i++) {
			line = br.readLine();
			for (char c : line.toCharArray()) {
				switch (c) {
					case 'W':
						wbr[i][B]++;
						wbr[i][R]++;
						break;
					case 'B':
						wbr[i][W]++;
						wbr[i][R]++;
						break;
					case 'R':
						wbr[i][W]++;
						wbr[i][B]++;
						break;
				}
			}
		}

		int min = N * M;
		for (int i = 1; i < N - 1; i++) {
			for (int j = i; j < N - 1; j++) {
				int change = 0;
				for (int k = 1; k < N - 1; k++) {
					if (k < i) {
						change += wbr[k][W];
					} else if (i <= k && k <= j) {
						change += wbr[k][B];
					} else {
						change += wbr[k][R];
					}
				}
				min = Math.min(min, change);
			}
		}

		System.out.println(wbr[0][W] + min + wbr[N - 1][R]);
	}
}

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

int cul(int*);

int N,MAX[2] = {};

int  main(void){
	int i;
	scanf("%d",&N);
	int A[N];
	for(i = 0 ; i < N ; i ++){
		scanf("%d",&A[i]);
	}
	cul(A);
	for(i = 0 ; i < N ; i ++){
		if(A[i] != MAX[0]){
			printf("%d\n",MAX[0]);
		} else {
			printf("%d\n",MAX[1]);
		}
	}
	
	return 0;
}


int cul(int *A){
	int i;
	for(i = 0 ; i < N; i ++){
		if(A[i] >= MAX[0]){
			MAX[1] = MAX[0];
			MAX[0] = A[i];
		} else if(A[i] > MAX[1]){
			MAX[1] = A[i];
			
		}
	}
	return *MAX;
}

Measured memory_bytes: 2432
#include<stdio.h>
int main()
{
  long long n,an,num;
  
  scanf("%lld", &n);
  
 for(long long i=1;i*i<=n;i++){
    if(n%i==0){
      num=n/i-1;
      if(num>i)
        an+=num;
    }
  }

  printf("%lld", an);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const int INF = 1e9;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;

#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define rt return
#define ENDL cout<<endl
#define s second
#define f first

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    string str;cin >> str;
    char c = str.front();
    int ans = 0;
    for(int a = 0;a < str.size();a++){
        if(c != str.at(a)){
            ans++;
            c = str.at(a);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair <int,ii>
#define iil pair<ll,ll>
#define iiil pair<ll,iil>
#define max3(a,b,c) max(a, max(b,c))
#define min3(a,b,c) min(a, min(b,c))
#define s(v) sort(v.begin(),v.end())
#define pf printf
#define sf scanf
#define MIN INT_MIN
#define MAX INT_MAX
#define accepted 0
using namespace std;
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}
//
//bool prime[n];
//vector<int> v;
//void sieve(){
//    prime[0]=prime[1]=1;
//    for(int i=2;i*i<=n;i++){
//        if(prime[i]==0){
//            for(ll j = i*i;j<=n;j+=i){
//                prime[j]=true;
//            }
//        }
//    }
//    for(int i=2;i<=n;i++){
//        if(prime[i]==0)v.push_back(i);
//    }
//}
//
//bool ispalindrome(string s){
//
//    for(int i=0,j=s.size()-1;i<s.size();i++,j--){
//        if(s[i]!=s[j])
//            return false;
//    }
//    return true;
//}


int main(){
    int tst,value;    cin>>tst;
    bool flag = 1;
    string a;
    set<string> v;
    map<string,int> m;
        while(tst--){
            cin>>a;
            m[a]++;
            v.insert(a);
        }
      // sort(v.begin(),v.end());
      int mx = -100;
       for(string x: v){
        if(mx<m[x])mx = m[x];
       }
       // cout<< mx <<endl;
       for(string x:v){
        if(m[x]==mx)cout<< x <<endl;
       }


    return accepted;
}


Measured memory_bytes: 34560
/*
       ()       ()()()()     ()        ()       ()        ()        ()
      ()()      ()     ()    ()()      ()      ()()       ()()      ()
     ()  ()     ()      ()   ()  ()    ()     ()  ()      ()  ()    ()
    ()()()()    ()      ()   ()    ()  ()    ()()()()     ()    ()  ()
   ()      ()   ()     ()    ()      ()()   ()      ()    ()      ()()
  ()        ()  ()()()()     ()        ()  ()        ()   ()        ()

*/
#include <bits/stdc++.h>
#define MOD  (int)(1e9+7)
#define SIZE (int)(1e5+5)
#define all(x) x.begin(),x.end()
#define si(i)  scanf("%d",&i)
#define sf(f)  scanf("%f",&f)
#define pi(i)  printf("%d",i)
#define pd(d)  printf("%lf",d)
#define deb(x) cout<<#x<<" is "<<x<<"\n";
#define lb     lower_bound
#define ub     upper_bound
#define pb     push_back
#define prDouble(x) cout<<fixed<<setprecision(10)<<x;
#define IOfast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

int64_t exponentiation(int64_t base,int exp)
{
    if (exp == 0)
        return 1;

    if (exp == 1)
        return base;

    int64_t t = exponentiation(base, exp / 2);

    t = (t * t);

    if (exp % 2 == 0)
        return t;
    else
        return base * t;
}

double dp[3010][3010];
double prob[3010];
double solve(int n,int heads)
{
  if(heads == 0)
    return 1;
  
  if(n == 0)
    return 0;
 
  if( dp[n][heads]  > -0.9){
    //cout<<"in\n";
    return dp[n][heads];
  }
  
  dp[n][heads] = prob[n-1] * solve(n-1,heads - 1) + (1-prob[n-1])*solve(n-1,heads);  

 return dp[n][heads];
}


int main()
{
  IOfast;
  int q=1;
  //cin>>q;
  memset(dp,-1,sizeof(dp));
  while(q--)
  {
    int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>prob[i];
    
    prDouble( solve(n,(n+2)/2) );
  }
  
  return 0;
}


Measured memory_bytes: 71296
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;

int n,k,ans=0;
int jc[2000005];

int quick_power(int a,int b)
{
	int res=1;
	for (;b;b=b>>1,a=(a*a)%mod)
	{
		if (b&1)  res=(res*a)%mod;
	}
	return res;
}

inline int ny(int k)
{
	return quick_power(k,mod-2);
}

inline int C(int n,int m)
{
	return ((jc[n]*ny(jc[m]))%mod*ny(jc[n-m]))%mod;
}

inline void init()
{
	jc[0]=1;
	for (int i=1;i<=2000000;i++)  jc[i]=(jc[i-1]*i)%mod;
}

signed main()
{
	init();
	string s;
	cin>>k>>s;
	n=s.size();
	
	for (int i=0;i<=k;i++)  ans=(ans+((quick_power(26,i)*quick_power(25,k-i))%mod*C(k-i+n-1,n-1))%mod)%mod;
	cout<<ans<<endl;
	
	return 0;
}

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

#include <iostream>
#define pb push_back
#define sort_incr(v) sort(v.begin(),v.end());
#define sort_decr(v) {sort(v.begin(),v.end()); reverse(v.begin(),v.end());}
#define take_input(v,n) for(ll i=0,temp;i<n;i++){cin>>temp;v.pb(temp);}
#define fastio {ios_base::sync_with_stdio(false);    cin.tie(NULL);}
#define ALL(v) v.begin(),v.end()

typedef long long ll;
using namespace std; 



////*********           REMOVE DUPLICATES FROM VECTOR       **********///////


vector<int>  remove_duplicate_elements(vector<int> v)
{
    vector<int>::iterator ip;
    ip = unique(v.begin(), v.end()); 
    v.resize(std::distance(v.begin(), ip)); 
    return v;
}


//// **************                CONVERT STRING TO UNIQUE CHARACTERS              **************////                  
string make_unique_string(string s)
{
    string s1="";
    for(int i=0;i<s.length();i++)
    {
        bool flag=true;
        for(int j=0;j<s1.length();j++)
        {
            if(s1[j]==s[i])
            {flag=false;break;}
        }
        
        if(flag)
        s1=s1+s[i];
        
    }
    return s1;
}

//////// Three Element Vector 
struct vec_thre
{
    int first ,second,third;
};


/////// Comparing on sorting a vector


bool comp(vec_thre a , vec_thre b)
{
    if (a.first != b.first ) 
        return a.first < b.first; 
    if (a.second != b.second) 
            return a.second < b.second; 
}

/////////Sorting vector on the basis of second Element of vector 

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 


// Driver function to sort the vector elements by  first element of pair in descending order, 
//if first is same than second is consdidered 
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
    
        if(a.first!=b.first)
       return (a.first > b.first);
       
       return (a.second>b.second);

} 


int main() 
{
int n,k;
cin>>n>>k;
vector<int> v;
take_input(v,n);
sort(ALL(v));
ll su=0;
for(int i=0;i<k;i++)
{
    su=su+v[i];
}
cout<<su;
    
    return 0; 
} 
























Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define has_bit(bit_mask, x) ((bit_mask) & (1Uint << (x)))
#define turn_on_bit(bit_mask, x) (bit_mask |= (1Uint << (x)))
#define turn_off_bit(bit_mask, x) (bit_mask &= (~(1Uint << (x))))
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define int ll
#define double ld
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    int ans = 0, x;
    int curMin = LONG_MAX;
    for (int i = 0; i < n; ++i)
    {
        cin >> x;
        if (curMin >= x) ans++;
        curMin = min(curMin, x);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
    //freopen("file.in", "r", stdin);
    int a,b;cin>>a>>b;
    if(a<=12){
    	if(a<6)
			b=0;
		else
			b/=2;		
    }
    cout<<b<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import heapq

N, M = map(int, sys.stdin.readline().strip().split())
G = [[] for _ in range(N)]
for m in range(M):
    a, b = map(int, sys.stdin.readline().strip().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

# print(G)
# みんな大好き　ダイクストラ
d = [] * N
c = [False] * N
heapq.heappush(d, (0, 0))
p = [N] * N  # 親を保存するリスト　親ノードとしてあり得ない N を初期値にした

mindist = [float('inf')] * N
mindist[0] = 0

while d:
    now = heapq.heappop(d)[1]
    c[now] = True

    for i in G[now]:
        if mindist[now] + 1 < mindist[i]:
            mindist[i] = mindist[now] + 1
            p[i] = now
            heapq.heappush(d, (mindist[i], i))

# print(p)
# 答える
if N in set(p[1:]):
    print('No')
else:
    print('Yes')
    for i in p[1:]:
        print(i + 1)




Measured memory_bytes: 40516
def num_combinations_mod2(n, r, mod=10 ** 9 + 7):
    # mod must be a prime.
    # nCr = (n! / (n-r)!) * (r!)^-1
    # a = n! / (n-r)!
    # b = (r!)^-1
    if r > n:
        return 0
    if r < 0 or n < 0:
        return 0
    r = min(r, n - r)
    a = 1
    b = 1
    for i in range(1, r + 1):
        a = a * (n + 1 - i) % mod
        b = b * i % mod
    return a * pow(b, mod - 2, mod) % mod


def main(x, y):
    if (x + y) % 3 != 0:
        return 0

    total = (x + y) // 3
    n = (2 * x - y) // 3
    m = total - n
    answer = num_combinations_mod2(m+n, n, 10**9+7)
    return answer


X, Y = map(int, input().split(" "))
print(main(X, Y))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int h, w;
    cin >> h >> w;

    vector<string> s(h);
    REP(i, h) {
        cin >> s[i];
    }

    vector<vector<int>> l(h+2, vector<int>(w+2, 0));
    vector<vector<int>> r(h+2, vector<int>(w+2, 0));
    vector<vector<int>> u(h+2, vector<int>(w+2, 0));
    vector<vector<int>> d(h+2, vector<int>(w+2, 0));
    REP2(i, 1, h+1) {
        REP2(j, 1, w+1) {
            if (s[i-1][j-1] == '.') {
                l[i][j] = l[i][j-1] + 1;
                u[i][j] = u[i-1][j] + 1;
            }
        }
    }
    RREP(i, h, 1) {
        RREP(j, w, 1) {
            if (s[i-1][j-1] == '.') {
                r[i][j] = r[i][j+1] + 1;
                d[i][j] = d[i+1][j] + 1;
            }
        }
    }
    int mini = 0;
    REP2(i, 1, h+1) {
        REP2(j, 1, w+1) {
            mini = max(mini, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
        }
    }

    cout << mini << endl;
    return 0;
}


Measured memory_bytes: 67200
#include <iostream>
using namespace std;
int main(){
  int n,m,a[100000],r=0;;
  cin>>n>>m;
  for(int i=0;i<m;i++) cin>>a[i];
  r=max(a[0]-1,n-a[m-1]);
  for(int i=1;i<m;i++) r=max(r,(a[i]-a[i-1])/2);
  cout<<r<<endl;
  return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<ll>>;

int main(){
  ll N,K; cin>>N>>K;
  vector<ll> H(N+1);
  rep1(i,N)cin>>H.at(i);
  set<ll> res;
  rep1(i,N)res.insert(i);
  rep(i,K){
    ll a,b; cin>>a>>b;
    if(H.at(a)<H.at(b))res.erase(a);
    else if(H.at(b)<H.at(a))res.erase(b);
    else{
      res.erase(a);
      res.erase(b);
    }
  }
  cout<<res.size()<<endl;
}


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

int main() {
	int a,b,c;
	cin>>a>>b>>c;

	if(b+c<=a)
	   cout<<"0";
	else{
		while(a!=b){
	      b=b+1;
	      c=c-1;

		 }
         cout<<c;
	}
	return 0;
}


Measured memory_bytes: 3600
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from collections import deque
    input = sys.stdin.readline

    H, W = map(int, input().split())
    grid = []
    for _ in range(H):
        grid.append(input().rstrip('\n'))

    ans = 0
    seen = [[0] * W for _ in range(H)]
    d = [(0, 1), (0, -1), (1, 0), (-1, 0)]
    for h0 in range(H):
        for w0 in range(W):
            if seen[h0][w0] == 0:
                que = deque([(h0, w0)])
                seen[h0][w0] = 1
                black = white = 0
                while que:
                    h, w = que.popleft()
                    if grid[h][w] == "#":
                        black += 1
                    else:
                        white += 1
                    for dh, dw in d:
                        h_new, w_new = h+dh, w+dw
                        if 0 <= h_new < H and 0 <= w_new < W:
                            if seen[h_new][w_new] == 0:
                                if grid[h][w] != grid[h_new][w_new]:
                                    que.append((h_new, w_new))
                                    seen[h_new][w_new] = 1
                ans += black * white
    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
	ll n, l, r;
	ll ans = 1001001001001;
	cin >> n;
	for(ll i = 1; i <= sqrt(n); i++){
		if(n % i == 0){
			r = n/i;
			ans = min(ans, i+r-2);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
std::string S;

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

    std::cin >> N >> S;

    int mx = 0;

    for(int i=0;i+1<N;++i){
        int x = 0, y = 0;
        
        for(int j=0;j<=i;++j){
            x |= 1 << (S[j] - 'a');
        }

        for(int j=i+1;j<N;++j){
            y |= 1 << (S[j] - 'a');
        }

        mx = std::max(mx, __builtin_popcount(x & y));
    }

    std::cout << mx << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  int n, i, j;
  int C[VMAX+1];
 unsigned short *A,*B;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

for(i=0;i<=VMAX;i++) {
  C[i]=0;
}
  for (i = 0; i < n; i++) {
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=VMAX;i++) C[i]=C[i]+C[i-1];

  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i==n)  printf("%d\n",B[i]);
    else printf("%d ",B[i]);
  }
  return 0;
}


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

class UnionFind {
public:
    vector<int> uni;
    UnionFind(int s) : uni(s, -1) {}
    int root(int a) { return uni[a] < 0 ? a : uni[a] = root(uni[a]);}
    bool connect(int a, int b) {
        a = root(a); b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] = uni[a] + uni[b];
        uni[b] = a;
        return true;
    }
    bool isConnect(int a, int b) { return root(a) == root(b);}
    int size(int a) { return -uni[root(a)];}
};

int main() {
    int N, K; cin >> N >> K;
    vector<int> P(N);
    for(auto &e : P) cin >> e;

    vector<int> C(N, 1);
    for(int i = N - 2; i >= 0; --i)
        if(P[i] < P[i + 1]) C[i] = C[i + 1] + 1;

    int M = N - K + 1;
    UnionFind uf(M);

    set<int> st;
    for(int i = 0; i < K; ++i)
        st.insert(P[i]);

    for(int i = 0; i < M - 1; ++i) {
        st.insert(P[i + K]);
        auto mx = st.end(); mx--;
        auto mn = st.begin();
        if(P[i] == *mn and P[i + K] == *mx) uf.connect(i, i + 1);
        st.erase(P[i]);
    }

    vector<int> sorted;
    for(int i = 0; i < M; ++i)
        if(C[i] >= K) sorted.push_back(i);

    for(int i = 1; i < sorted.size(); ++i)
        uf.connect(sorted[i - 1], sorted[i]);

    st.clear();
    for(int i = 0; i < M; ++i)
        st.insert(uf.root(i));

    cout << st.size() << '\n';
    return 0;
}


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

long long N, A[1 << 18];
long long dp[1 << 18][2][20];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j < 20; j++) {
			dp[i][0][j] = -(1LL << 60);
			dp[i][1][j] = -(1LL << 60);
		}
	}
	dp[0][0][10] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 6; j <= 14; j++) {
			if (dp[i - 1][0][j] != (1LL << 60)) {
				dp[i][1][j + 1] = max(dp[i][1][j + 1], dp[i - 1][0][j] + A[i]);
				dp[i][0][j - 1] = max(dp[i][0][j - 1], dp[i - 1][0][j]);
			}
			if (dp[i - 1][1][j] != (1LL << 60)) {
				dp[i][0][j - 1] = max(dp[i][0][j - 1], dp[i - 1][1][j]);
			}
		}
	}

	long long V = 10LL + (N / 2) - (N - (N / 2));
	long long T1 = dp[N][0][V];
	long long T2 = dp[N][1][V];
	cout << max(T1, T2) << endl;
	return 0;
}

Measured memory_bytes: 67604
n, m = map(int, input().split())
aa = [0] * m
for _ in range(n):
    tmp = list(map(int , input().split()))
    for ai in tmp[1:]:
        aa[ai-1] += 1

ans = 0
for i in aa:
    if i == n:
        ans += 1
print(ans)

Measured memory_bytes: 38384
#include <algorithm>
#include <array>
#include <deque>
#include <functional>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main() {
    ll n, k;
    cin >> n >> k;
    // ll ans = n;
    // if (n == 1 || k == 1 || n == k || n % k == 0) {
    //     cout << 0 << endl;
    // } else {
    //     if (n > 2 * k) {
    //         n = n / k;
    //     }
    //     cout << min(abs(n - k), abs(abs(n - k) - k)) << endl;
    // }
    n = n % k;
    cout << min(abs(n - k), abs(abs(n - k) - k)) << endl;
    return 0;
}


Measured memory_bytes: 256