akhauriyash/Code-Regression huggingface dataset:
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <numeric>

using namespace std;

typedef pair<long long, long long> pl;

long long N, M, k, a, b, c, d, e, H, W;
long long A[200000] = {};
long long B[2][10000] = {};
bool f;
bool ff;
string S;
set <long long>sll;
pl buf;
vector <long long>vl;

struct ST
{
	long long total;
	long long aki;
	long long itta;
};

vector <ST> vst;
ST st;


int main() {

	cin >> N;
	f = false;
	ff = false;
	a = N / 100;
	b = N % 100;

	while (true) {

		if (a == 0 && b >= 13) {
			cout << "NA" << endl;
			break;
		}

		if (b == 0 && a >= 13) {
			cout << "NA" << endl;
			break;
		}

		if (b == 0 && a ==0) {
			cout << "NA" << endl;
			break;
		}

		if (a >= 13 && b >= 13) {
			cout << "NA" << endl;
			break;
		}

		if (a >=1 && a <= 12 && b>=1 && b<=12) {
			cout << "AMBIGUOUS" << endl;
			break;
		}

		if (a >= 1 && a <= 12) {
			if (b == 0 || b >= 13) {
				cout << "MMYY" << endl;
				break;
			}
		}

		cout << "YYMM" << endl;
		break;
	}
	

	return 0;

}


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

#define ll long long
#define ar array
 
using namespace std;


int main() {
	
	int n;
	
	int a, b;

	cin >> a >> b;
	
	n = max(max(a,b)-1+max(a,b),a+b);
	
	cout << n <<endl;
	
	
   	return 0;
}
   

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

// nCk の組み合わせを列挙する
pub fn combination(n: usize, k: usize) -> Vec<Vec<usize>> {
    let mut ans = Vec::new();
    if k == 1 {
        for i in 1..n+1 {
            let mut tmp = Vec::new();
            tmp.push(i);
            ans.push(tmp);
        }
    }
    else {
        for iter in combination(n-1, k-1) {
            let max = iter.iter().max().unwrap();
            for j in *max+1..n+1 {
                let mut tmp = iter.clone();
                tmp.push(j);
                ans.push(tmp);
            }
        }
    }
    ans
}


fn main() {
    input!{
        k: usize,
        v: chars,
    }
    let s: String = v.iter().collect();
    if s.len() <= k {
        println!("{}", s);
    }
    else {
        println!("{}...", &s[0..k])
    }
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

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

	vv(int) A(15, vector<int>(15, -1));
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		for (int j = 0; j < a; j++)
		{
			int x, y;
			cin >> x >> y;
			x--;
			A[i][x] = y;
		}
	}
	int ans = 0;
	for (int i = 0; i < (1 << n); i++)
	{
		bitset<15> man(i);
		vector<int> check(n, -1);
		bool f = true;
		for (int j = 0; j < n; j++)
		{
			if (man[j])
			{
				for (int k = 0; k < n; k++)
				{
					if (A[j][k] == -1)
						continue ;
					else if (check[k] == -1)
						check[k] = A[j][k];
					else if (check[k] != A[j][k])
						f = false;
				}
			}
		}
		for (int j = 0; j < n; j++)
		{
			if (man[j] != check[j] && check[j] != -1)
				f = false;
		}
		if (f)
			ans = max(ans, (int)man.count());
	}
	cout << ans << endl;
}



Measured memory_bytes: 3596
#include <stdio.h>
#include<string.h>

int main(void)
{
	char s[10],t[10],u[10];
	int a,b;
	//入力
	scanf("%s %s",s,t);
	scanf("%d %d",&a,&b);
	scanf("%s",u);
	
	//デバック
	//printf("%d %d %s %s %s",a,b,s,t,u);
	//判別
	if(strcmp(s,t)==0){
		a--;
	}else{
		if(strcmp(s,u)==0){
		a--;
		}if(strcmp(t,u)==0){
		b--;
		}
	}
	
	//出力
	printf("%d %d",a,b);
	return 0;
}

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

int main() {
	int a[5];
	int min = 0;
	for(int i = 0; i < 5; i++) {
		scanf("%d", &a[i]);
		if((a[i] % 10 > 0) && (a[i] % 10 < a[min] % 10)) min = i;
	}
	int sum = 0;
	for(int i = 0; i < 5; i++) {
		if(i != min) sum += ((a[i] + 9)/10)*10;
		else sum += a[i];
	}
	cout << sum;
	return 0;
};

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0
 ll gcd(ll a,ll b){
 	ll r,tmp;
 	if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 return b;
 }
 int main()
 {
 	ll n,m,a;
 	cin >> n >>m;
 	cin >> a;
 	bool ss=false;
 	if(a>=m){
 		ss=true;
 	}
 	for (int i = 1; i < n; i++){
 		ll b;
 		cin >> b;
 		if(!ss){
 			if(b>=m){
 				ss=true;
 			}
 		}
 		a=gcd(a,b);
 	}
 	if(m%a==0&&ss){
 		cout << "POSSIBLE" <<endl;
 	}else{
 		cout << "IMPOSSIBLE" << endl;
 	}
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
}


Measured memory_bytes: 256
N = int(input())

restaurant_data = [[i+1]+(list(input().split())) for i in range(N)]
restaurant_data = list(map(lambda x:[x[0],x[1],int(x[2])],restaurant_data))
restaurant_data = sorted(restaurant_data, key=lambda x: -1*x[2])
restaurant_data = sorted(restaurant_data,key=lambda x:x[1])
# print(restaurant_data)
for ans in list(map(lambda x:x[0],restaurant_data)):
  print(ans)

Measured memory_bytes: 3064
import java.io.BufferedInputStream;
        import java.util.Scanner;

/**
 *
 */
public class Main {

    public static void solve(){
        Scanner sc = new Scanner(new BufferedInputStream(System.in));
        String[] str = sc.nextLine().split(" ");
        if (str[0].charAt(str[0].length()-1) == str[1].charAt(0) &&
                str[1].charAt(str[1].length()-1) ==
                        str[2].charAt(0)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }
    public static int gcd(int a, int b){
        return b==0 ? a : gcd(b, a % b);
    }

    public static void solve2(){
        Scanner sc = new Scanner(new BufferedInputStream(System.in));
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (c % gcd(a,b)==0){

            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }
    public static void solve3(){
        Scanner sc = new Scanner(new BufferedInputStream(System.in));
        int n = sc.nextInt();
        int a[][] = new int[n+1][28];

        for(int i =0 ; i < n ;i ++) {
            String str = sc.next();
            int b[] = new int[28];
            for (int j =0 ;j<str.length(); j++) {
                b[str.charAt(j)-'a']++;
            }
            a[i] = b;
        }
        StringBuffer str = new StringBuffer();
        for(int i = 0 ; i < 26 ; i ++ ){
            int mx=Integer.MAX_VALUE;
            for(int j = 0; j < n ; j++) {
                mx = Math.min(mx, a[j][i]);
            }
            if (mx!=0) {
                for (int k = 0; k < mx; k++)
                    str.append((char)(i + 'a'));
            }
        }
        System.out.println(str.toString());

    }
    public static void main(String[] argc) {
        solve3();
    }
}


Measured memory_bytes: 21844
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let s = read_vec::<String>();
    let ans:String = s.iter().flat_map(|x| x.chars().nth(0)).collect();
    println!("{}",ans );
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i > (b); --i)
#define SZ(a) a.size()
#define ll long long
using namespace std;


int main() {
	int N = 0;
	int remove = 0;
	vector<int> stock(pow(10, 5) + 1, 0);
	cin >> N;
	
	vector<int> a(N, 0);
	FOR(i, 0, N)
		cin >> a[i];

	FOR(i, 0, N) {
		if (a[i] > 100000)
			++remove;
		else
			++stock[a[i]];
	}

	FOR(i, 1, 100001) {
		if (i < stock[i])
			remove += stock[i] - i;
		else if (i > stock[i])
			remove += stock[i];
	}

	cout << remove;

	return 0;
}

Measured memory_bytes: 1024
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>

using namespace std;


int main(int argc, const char * argv[]) {
    
    long long n, k, ans;
    cin >> n >> k;
    
    ans = n;
    
    while(1)
    {
//        n = abs(n-k);
//
//        if(k == 1){
//            ans = 0;
//            break;
//        }
//
//        if(ans > n){
//        ans = n;
//        } else if (ans == n)
//        {
//            break;
//        } else if (ans < n)
//        {
//            break;
//        }
        
        if(n % k == 0)
        {
            ans = 0;
            break;
        } else if (n / k == 0)
        {
            n = abs(n - k);
                    if(ans > n){
                    ans = n;
                    } else if (ans == n)
                    {
                        break;
                    } else if (ans < n)
                    {
                        break;
                    }
        } else {
            n = n % k;
            //ans = n;
        }
        
        
        
        //cout << ans << " " << n << endl;
    }
    cout << ans << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

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

  cin >> a >> b >> c;

  cout << min( a + b, min( b + c, c + a)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

#define MAX_W 10000

using namespace std;

int main() {
    int N,W,v,w,i,j;
    int dp[MAX_W+1] = {0};
    scanf("%d %d",&N,&W);
    for (i=0; i<N; i++) {
        scanf("%d %d",&v,&w);
        for (j=0; j<=W; j++) dp[j] = max(dp[j], (j>=w) ? dp[j-w] + v : 0);
    }
    printf("%d\n",dp[W]);
    return 0;
}


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

ll gcd(ll a, ll b) { //最大公約数
    if (a%b == 0) {
        return b;
    } else {
        return gcd(b,a%b);
    }
}

ll lcm(ll a, ll b) { //最小公倍数
    return a*b / gcd(a,b);
}

int main() {
    ll a,b;
    cin>>a>>b;
    ll ans=lcm(a,b);
    cout<<ans<<endl;
}


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

bool solve(const int n)
{
  int t = n;
  int sum = 0;
  while (true) {
    sum += t % 10;
    t /= 10;
    if (t == 0)
      break;
  }
  return (n % sum) == 0;
}

int main()
{
  int n;
  cin >> n;
  solve(n) ? cout << "Yes\n" : cout << "No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 200010;
const int INF = INT_MAX/2;


int n;
int A[maxn];

multiset <int> ms;

int32_t main(){
	//FAST
	cin >> n;
	for (int i =0;i<n;i++) cin >> A[i];
	
	sort(A,A+n,greater<int>());
	int ans = 0;
	
	ans += A[0];	
	ms.insert(A[1]);
	ms.insert(A[1]);
	//cout << "HELLO\n";
	
	for (int i =2;i<n;i++) {
		ans += *ms.rbegin();
		ms.erase(ms.find(*ms.rbegin()));
		ms.insert(A[i]);
		ms.insert(A[i]);
		//cout << A[i] << " " << ans << "\n";
	}
	
	cout << ans;
	
}









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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 100005;

int see[104];

void solve(){
	int n,x;
	cin >> x >> n;
	for(int i = 0; i < n; i++){
		int t; cin >> t;
		see[t] = 1;
	}
	int diff = mod, ans;
	for(int i = -1; i <= 105; i++){
		if(!see[i] and abs(i-x) < diff){
			ans = i, diff = abs(i-x);
		}
	}
	cout << ans << endl;
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    long long s = 0;
    vector<long long> sums(N);
    for (int i = 0; i < N; i++) {
        long long a, b;
        cin >> a >> b;
        sums[i] = a + b;
        s += b;
    }

    sort(sums.begin(), sums.end(), greater<long long>());
    long long res = -s;
    for (int i = 0; i < N; i += 2) {
        res += sums[i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
/*****************************
 Filename: dfdkljfd.cpp
 Author: hbb
 Create: 2020-04-04 20:11:33
*****************************/
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const int inf = INT_MAX >> 1;
typedef long long int LL;

int main(){
	int x, y, z;
	scanf("%d %d %d", &x, &y, &z);
	printf("%d %d %d\n", z, x, y);
}

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

int N, X[100005], Y[100005], p[100005];

vector<int> V;
vector< pair< int, pair<int, int> > > edges;

bool cmp1(int x, int y) {
	return make_pair(X[x], Y[x]) < make_pair(X[y], Y[y]);
}

bool cmp2(int x, int y) {
	return make_pair(Y[x], X[x]) < make_pair(Y[y], X[y]);
}

int fp(int x) {
	if (p[x] == x) return x;
	else return p[x] = fp(p[x]);
}

void merge(int x, int y) {
	x = fp(x);
	y = fp(y);
	p[x]=y;
}

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d%d", &X[i], &Y[i]);
	for (int i = 0; i < N; i++) V.push_back(i);
	sort(V.begin(), V.end(), cmp1);
	for (int i = 0; i < N - 1; i++) edges.push_back(make_pair(min(abs(X[V[i]] - X[V[i + 1]]), abs(Y[V[i]] - Y[V[i + 1]])), make_pair(V[i], V[i + 1])));
	sort(V.begin(), V.end(), cmp2);
	for (int i = 0; i < N - 1; i++) edges.push_back(make_pair(min(abs(X[V[i]] - X[V[i + 1]]), abs(Y[V[i]] - Y[V[i + 1]])), make_pair(V[i], V[i + 1])));
	for (int i = 0; i < N; i++) p[i] = i;
	sort(edges.begin(), edges.end());
	long long ans = 0;
	for (int i = 0; i < edges.size(); i++) {
		int x = edges[i].second.first, y = edges[i].second.second;
		if (fp(x) == fp(y)) continue;
		ans += edges[i].first;
		merge(x, y);
		//printf("%d %d: %d\n", x, y, edges[i].first);
	}
	printf("%lld\n", ans);
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N,X;
  cin>>N>>X;
  vector<int>L(N);
  for(int i=0;i<N;i++)cin>>L[i];
  ll now=0;
  int ans=0;
  for(int i=0;i<N;i++){
    now+=L[i];
    if(now>X)break;
    ans++;
  }
  cout<<ans+1<<endl;

  return 0;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n;
  string s1;
  string s2;

  cin >> n;
  cin >>s1 >> s2;

  LL ans;
  int yoko = -1;
  if (s1[0] == s2[0]) {
    ans = 3;
  } else {
    ans = 6;
    yoko = 1;
  }

  LL x = pow(10, 9) + 7;
  FOR (i, 1, n) {
    if (yoko == i) continue;
    if (s1[i] == s2[i] && yoko != i - 1) {
      ans = ans * 2 % x;
    } else if (s1[i] != s2[i] && yoko == i - 1) {
      ans = ans * 3 % x;
      yoko = i + 1;
    } else if (s1[i] != s2[i] && yoko != i - 1) {
      ans = ans * 2 % x;
      yoko = i + 1;
    }
  }

  cout << ans << endl;
}


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

int main(){
  int n;
  cin >> n;
  int a[n];
  int ans = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  int saishou = a[0];
  for(int i = 0; i < n; i++){
    saishou = min(a[i], saishou);
    if(a[i] == saishou){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4360
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

ll ans = 0;
ll n;

void cnt(ll x) {
  bool a = false, b = false, c = false;
  while(x > 0) {
    if (x % 10 == 3) {
      a = true;
    }
    if (x % 10 == 5) {
      b = true;
    }
    if (x % 10 == 7) {
      c = true;
    }
    x /= 10;
  }
  if (a && b && c) {
    ans++;
  }
}

void dfs(ll x) {
  if (x <= n) {
    cnt(x);
    dfs(x * 10 + 3);
    dfs(x * 10 + 5);
    dfs(x * 10 + 7);
  }
}

int main() {
  cin >> n;
  dfs(0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
class UnionFind:
    """素集合を木構造として管理する"""
    def __init__(self, n):
        self.parent = [-1] * n
        self.cnt = n

    def root(self, x):
        """要素xの根を求める"""
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]

    def merge(self, x, y):
        """要素xを含む集合と要素yを含む集合を統合する"""
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.parent[x] > self.parent[y]:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        self.cnt -= 1

    def is_same(self, x, y):
        """要素x, yが同じ集合に属するかどうかを求める"""
        return self.root(x) == self.root(y)

    def get_size(self, x):
        """要素xを含む集合の要素数を求める"""
        return -self.parent[self.root(x)]

    def get_cnt(self):
        """集合の個数を求める"""
        return self.cnt


n, m = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(m)]


uf = UnionFind(n)
for u, v in edges:
    u -= 1
    v -= 1
    uf.merge(u, v)

ans = 0
for i in range(n):
    ans = max(uf.get_size(i), ans)
print(ans)

Measured memory_bytes: 111548
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define mod 1000000007;
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    cout<<a*b;
    

    return 0;
}

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

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

    string MIN = "";
    rep(i, s.size()){
        MIN += 'z';
    }

    bool match=true;
    bool exist = false;
    rep(i, s.size()-t.size()+1){
        string si = s.substr(i, t.size());
        // cout << si << endl;
        match = true;
        string s_ = s;
        rep(j, t.size()){
            if(si[j]!='?' && si[j]!=t[j]){
                match = false;
                break;
            }
            s_[i+j] = t[j];
        }
        // cout << i  << match << endl;
        if(match){
            rep(j, s_.size()){
                if(s_[j]=='?') s_[j] = 'a';
            }
            // if(MIN > s_) MIN = s_;
            MIN = min(MIN, s_);
            exist = true;
        }
    }
    if(exist) cout << MIN << endl;
    else cout << "UNRESTORABLE" << endl;

    return 0;
}

Measured memory_bytes: 256
// Crt. 2020-01-11  08:12:47
#include <algorithm>
#include <iostream>
#include <cstring>
#include <bitset>
#include <cstdio>
#include <vector>
#define N 1004
using namespace std;

int n, fa[N], x[N], g[N];
int tot, fir[N], nxt[N], to[N];
bitset<5010> f;

inline void addE(int u, int v) {
    nxt[++tot] = fir[u], fir[u] = tot, to[tot] = v;
}

void dfs(int u) {
    int sum = 0, all = 0;
    for (int i = fir[u]; i; i = nxt[i])
        dfs(to[i]), sum += min(x[to[i]], g[to[i]]), all += x[to[i]] + g[to[i]];
    if (sum > x[u]) puts("IMPOSSIBLE"), exit(0);
    f.reset(); f[sum] = 1;
    for (int i = fir[u]; i; i = nxt[i])
        f = f | (f << abs(x[to[i]] - g[to[i]]));
    for (int i = x[u]; i >= sum; --i)
        if (f[i]) { g[u] = all - i; break;}
}

int main(){
#ifdef LOCAL_JUDGE
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n;
    for (int i = 2; i <= n; ++i)
        scanf("%d", fa + i), addE(fa[i], i);

    for (int i = 1; i <= n; ++i)
        scanf("%d", x + i);

    dfs(1);

    puts("POSSIBLE");

	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, M;
        cin >> N >> M;
        map<ll, vector<string>> mp;
        rep(i, 0, M) {
                ll p;
                string s;
                cin >> p >> s;
                mp[p].push_back(s);
        }
        ll ac = 0;
        ll pen = 0;
        for (auto el : mp) {
                // ll p = el.first;
                auto vec = el.second;
                ll tmp = 0;
                rep(i, 0, len(vec)) {
                        if (vec[i] == "WA") {
                                ++tmp;
                        } else {
                                ++ac;
                                pen += tmp;
                                break;
                        }
                }
        }
        cout << ac << ' ' << pen << endl;
}

Measured memory_bytes: 15872
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int64 N;
  cin >> N;
  vector<vector<int64>> vv(N, vector<int64>(3));
  for (int64 i = 0; i < N; i++) {
    cin >> vv[i];
  }
  int t;
  for (int i = 0; i < N; i++) {
    if (vv[i][2] > 0) {
      t = i;
      break;
    }
  }
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      int64 h = abs(vv[t][0] - i) + abs(vv[t][1] - j) + vv[t][2];
      bool break_flag = false;
      for (int k = 0; k < N; k++) {
        int64 tmp = max(h - abs(vv[k][0] - i) - abs(vv[k][1] - j), 0LL);
        // debug(i, j, vv[k][2], tmp);
        if (vv[k][2] != tmp) {
          break_flag = true;
          break;
        }
      }
      if (!break_flag) {
        if (h == 0) continue;
        cout << i << ' ' << j << ' ' << h << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if((a==5 && b==5 && c==7)||(a==5 && b==7 && c==5)||(a==7 && b==5 && c==5)){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int a, b;
	cin >> a >> b;
	
	cout << max(0, a - 2 * b) << endl;
	
	return 0;
}


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

int main()
{
  int n, cnt = 0;
  cin >> n;
  for(int i=0; i<n; i++)
  {
    int p;
    cin >> p;
    if(p != i + 1)
      cnt++;
  }
  cout << (cnt == 2 || cnt == 0 ? "YES" : "NO") << endl;
  return 0;
}

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

int main(){
    char C;
    cin >> C;
    if(C == 'A'){
        cout << "T";
    }else if(C == 'T'){
        cout << "A";
    }else if(C == 'C'){
        cout << "G";
    }else if(C == 'G'){
        cout << "C";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  int k;
  string s;
  cin >> k >> s;
  if(k >= s.size())cout << s << endl;
  else{
    cout << s.substr(0,k) << "..." << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int INF = 100000000;

class P{
public:
  int x, y, c;
  P(int y = 0, int x = 0, int c = 0) : y(y), x(x), c(c) {}
};

int w, h;
vector<P> data[5];
P s, g;

int dist(P a, P b){
  return abs(a.y - b.y) + abs(a.x - b.x);
}

void solve(){
  int ans1, ans2 = INF;
  P dp[5][1000];

  for(int i=0;i<5;i++){
    /*for(int j=0;j<5;j++){
      for(int k=0;k<1000;k++){
        dp[j][k].c = INF;
      }
      }*/
    fill(dp[0], dp[5], P(0, 0, INF));
    int next = (i+1)%5;
    for(int j=0;j<data[next].size();j++){
      dp[next][j] = data[next][j];
      dp[next][j].c = dist(data[next][j], s);
    }
    for(int j=0;j<3;j++){
      next = (i+j+2)%5;
      int now = (next+4)%5;
      for(int k=0;k<data[now].size();k++){
        for(int l=0;l<data[next].size();l++){
          int tmp = dp[now][k].c + dist(dp[now][k], data[next][l]);
          if(dp[next][l].c > tmp){
            dp[next][l] = data[next][l];
            dp[next][l].c = tmp;
          }
        }
      }
    }
    next = (i+4)%5;
    for(int j=0;j<data[next].size();j++){
      int tmp = dp[next][j].c + dist(dp[next][j], g);
      if(ans2 > tmp){
        ans2 = tmp;
        ans1 = i+1;
      }
    }
  }
  if(ans2 == INF) cout << "NA" << endl;
  else cout << ans1 << ' ' << ans2 << endl;
}

main(){
  while(cin >> w >> h && (w|h)){
    for(int i=0;i<5;i++) data[i].clear();
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        char c;
        cin >> c;
        if(c == 'S'){
          s.y = i;
          s.x = j;
          s.c = 0;
        }else if(c == 'G'){
          g.y = i;
          g.x = j;
          g.c = 0;
        }else if(c != '.'){
          data[c-'1'].push_back(P(i, j, 0));
        }
      }
    }
    solve();
  }
}

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

int main() {
  int N, M, buf;
  while (cin >> N >> M) {
    multiset<int> A;
    for (int i=0; i<N; i++) {
      cin >> buf;
      A.insert(buf);
    }
    while (M > 0) {
      buf = *(--A.end());
      A.erase(--A.end());
      A.insert(buf / 2);
      M--;
    }
    long long sum=0;
    multiset<int>::iterator it;
    for (it=A.begin(); it!=A.end(); it++) {
      sum += *it;
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 4992
import java.util.*;
import java.io.*;

public class Main {
    public static int digitSum(int N){
    	return (N%10)+((N/10)%10)+((N/100)%10)+((N/1000)%10)+((N/10000)%10);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        int ans = 0;
        for(int n=1;n<=N;n++){
        	if(A<=digitSum(n) && digitSum(n)<=B) ans+=n;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			long x = sc.nextLong();
			String twobit = Long.toBinaryString(x);
			String left = Long.toBinaryString(x<<1);  //左シフト
			String right = Long.toBinaryString(x>>1);  //右シフト
			twobit = to32(twobit);
			left = to32(left);
			right = to32(right);
			System.out.println(twobit);
			for (int i=0; i<32; i++) {
				if (twobit.substring(i, i+1).equals("0")) System.out.print('1');
				else System.out.print('0');
			}
			System.out.print('\n');
			System.out.println(left + '\n' + right);
		}
	}


	//桁数を32にする
	static String to32(String s) {
		int a = 32-s.length();
		if (a != 0)	for (int i=0; i<a; i++)	s = '0' + s;
		if (a < 0) s = s.substring(s.length()-32);
		return s;
	}
}


Measured memory_bytes: 26244
import java.util.*;
class Main{
    Scanner sc=new Scanner(System.in);
    void main(){
	while(true){
	    int m=sc.nextInt();
	    int f=sc.nextInt();
	    int r=sc.nextInt();
	    if(m==-1&&f==-1&&r==-1)break;
	    String ans="A";
	    if(m+f<80)ans="B";
	    if(m+f<65)ans="C";
	    if(m+f<50){
		if(r>=50)ans="C";
		else ans="D";
	    }
	    if(m+f<30)ans="F";
	    if(m==-1||f==-1)ans="F";
	    System.out.println(ans);
	}
    }
    public static void main(String[]ag){
	new Main().main();
    }
}

Measured memory_bytes: 26448
import java.io.*;
import java.lang.*;
import java.math.*;
import java.util.*;

class Main{public static void main(String[] args){new Solver();}}

class Solver{
	ScanReader reader=new ScanReader(System.in);
	PrintWriter writer=new PrintWriter(System.out);
	Solver(){main(); writer.flush();}
	
	void main(){
		BigInteger m=BigInteger.ONE;
		for(int i=0;i<1500;i++)
			m=m.multiply(BigInteger.valueOf(i+2));
		m=m.add(BigInteger.valueOf(2));
		
		while(reader.hasNext()){
			int n=Integer.parseInt(reader.next());
			System.out.println(m);
			for(int i=0;i<n;i++)
				System.out.println(i+2);
		}
	}
}

class ScanReader{
	BufferedReader br;
	StringTokenizer st;
	public ScanReader(InputStream in){
		br=new BufferedReader(new InputStreamReader(in));
		st=null;
	}
	public boolean hasNext(){
		while(st==null || !st.hasMoreTokens()){
			try{
				if(!br.ready())
					return false;
				st=new StringTokenizer(br.readLine());
			}
			catch(IOException e){
				throw new RuntimeException(e);
			}
		}
		return true;
	}
	public String nextLine(){
		hasNext();
		return st.nextToken("");
	}
	public String next(){
		hasNext();
		return st.nextToken();
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int dp[200][200];
    for (auto &&i : dp) for (auto &&j : i) j = INF<int>;
    for (int i = 0; i < 200; ++i) dp[i][i] = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a, b; string s;
        cin >> a >> s >> b;
        a--; b--;
        if(s == "lock") dp[a][b+100] = -1;
        else dp[b+100][a] = -1;
    }
    for (int k = 0; k < 200; ++k) {
        for (int i = 0; i < 200; ++i) {
            for (int j = 0; j < 200; ++j) {
                chmin(dp[i][j], dp[i][k]+dp[k][j]);
            }
        }
    }
    for (int i = 0; i < 200; ++i) {
        if(dp[i][i] < 0){
            puts("1");
            return 0;
        }
    }
    puts("0");
    return 0;
}


Measured memory_bytes: 3364
#include <iostream>
#include <iomanip>
#include <cstdio>

using namespace std;

int main(){
  int a, b, c, d, e, f;
  while(true){
	if(!(cin >> a >> b >> c >> d >> e >> f)) return 0;
	double det = a*e - b*d;
	double x = (e*c-b*f)/det;
	double y = (-d*c+a*f)/det;
	printf("%.3f %.3f\n", (int)(x*1000)/1000.0, (int)(y*1000)/1000.0 );
  }
}

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

int main() {
  int n;
  cin >> n;
  long long ans = 1;
  vector<long long> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++)
  {
    if (a[i] == 0)
    {
      ans = 0;
      break;
    }
    
    if (ans > (1000000000000000000/a[i]))
    {
      ans = -1;
      break;
    }
    ans = ans * a[i];
    
    
    
    
  }
  cout << ans << endl;

  
  return 0;
  

}


Measured memory_bytes: 4012
package main

import(
    "fmt"
)



func main() {
    var a,b,x int
    fmt.Scan(&x,&a,&b)
    ans := "dangerous"
    switch{
        case a >= b:
            ans = "delicious"
        case b-a <= x:
            ans = "safe"
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}


Measured memory_bytes: 512
#include <iostream>
#include<set>
#include<vector>
#include<string>
using namespace std;
const int mod=1000000007;
int add(int a, int b)
{
	int c=a+b;
	if(c>=mod)c-=mod;
	return c;
}
int dif(int a, int b)
{
	int c=a-b;
	if(c<0)c+=mod;
	return c;
}
int mlt(int a, int b)
{
	long long c=a*1LL*b;
	return c%mod;
}
int bp(int a, int b)
{
	if(b==0)return 1;
	if(b%2==0)
	{
		int val=bp(a, b/2);
		return mlt(val, val);
	}
	if(b%2==1)
	{
		int val=bp(a, b-1);
		return mlt(val, a);
	}
}
int inv(int a)
{
	return bp(a, mod-2);
}
void outp(vector<vector<int>>&v)
{
	for(int i=0; i<v.size(); i++)
	{
		for(int j=0; j<v[i].size(); j++)cout<<v[i][j]<<' ';
		cout<<endl;
	}
	cout<<endl;
}
int maxn=1e7+7;
vector<int>fact(maxn), ofact(maxn);
int C(int a, int b)
{
	if(b<0)return 0;
	if(a<0)return 0;
	if(a>b)return 0;
	int val=fact[b];
	val=mlt(val, ofact[a]);
	val=mlt(val, ofact[b-a]);
	return val;
}
int main()
{
	fact[0]=1;
	ofact[0]=1;
	for(int i=1; i<maxn; i++)
	{
		fact[i]=mlt(fact[i-1], i);
	}
	ofact[maxn-1]=inv(fact[maxn-1]);
	for(int j=maxn-2; j>=1; j--)
	{
		ofact[j]=mlt(ofact[j+1], j+1);
	}
	int n, a;
	cin>>n>>a;
	int all=0;
	int d=n-a;
	vector<int>fat(a+2), us(a+2);
	us[0]=1;
	int ans=fact[a];
	for(int i=a-1; i>=1; i--)
	{
		vector<int>newfat(a+2), newus(a+2);
		for(int j=0; j<=a; j++)
		{
			newfat[j]= mlt(i,us[j]);
			newus[j+1]=us[j];
		}
		for(int j=0; j<=a; j++)
		{
			newfat[j]= add(newfat[j],mlt(i,fat[j]));
			newus[j]=add(newus[j], fat[j]);
		}
		fat=newfat;
		us=newus;
		for(int j=0; j<=a; j++)
		{
			int val=add(fat[j], us[j]);
			val=mlt(val, C(a-i, a-i+d-1-j));
			val=mlt(val, fact[i]);
			ans=add(ans, val);
		}
	}
	cout<<mlt(ans, fact[d])<<endl;
}

Measured memory_bytes: 81604
H,W = map(int,input().split())

S = [[] for _ in range(H)]
for i in range(H):
    S[i] = list(input())

HL = [[] for _ in range(H)]
WL = [[] for _ in range(W)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            HL[i].append(j)

for j in range(W):
    for i in range(H):
        if S[i][j] == '#':
            WL[j].append(i)
ma = 0
import bisect
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            ind = bisect.bisect_left(HL[i],j)
            if ind == 0:
                left = -1
            else:
                left = HL[i][ind-1]
            if ind == len(HL[i]):
                right = W
            else:
                right = HL[i][ind]
            wid_num = right-left-1

            ind_2 = bisect.bisect_left(WL[j],i)
            if ind_2 == 0:
                up = -1
            else:
                up = WL[j][ind_2-1]
            if ind_2 == len(WL[j]):
                down = H
            else:
                down = WL[j][ind_2]
            len_num = down-up-1

            ma = max(ma,wid_num+len_num-1)
print(ma)








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

const int Max=8010;
const int mod=1e9+7;
int n,m,k,ans;
int f[Max][Max],inv[Max],mul[Max],a[200010],b[200010];

inline int get_int()
{
	int x=0,f=1;
	char c;
	for(c=getchar();(!isdigit(c))&&(c!='-');c=getchar());
	if(c=='-') c=-1,c=getchar();
	for(;isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+c-'0';
	return x*f;
}

inline int ksm(int a,int b)
{
	int ans=1;
	while(b)
	{
	  if(b&1) ans=(1ll*ans*a)%mod;
	  b>>=1;
	  a=(1ll*a*a)%mod;
	}
	return ans;
}

inline void pre()
{
	mul[0]=mul[1]=1;
	for(int i=2;i<=8000;i++) mul[i]=(1ll*mul[i-1]*i)%mod;
	inv[0]=inv[1]=1;
	for(int i=2;i<=8000;i++) inv[i]=ksm(mul[i],mod-2);
}

inline int C(int n,int m)
{
	if(n>=0 && m>=0 && n>=m) return (1ll*mul[n]*inv[m]%mod*inv[n-m]%mod)%mod;
	return 0;
}

int main()
{
	pre();
	n=get_int();
	for(int i=1;i<=n;i++) a[i]=get_int(),b[i]=get_int(),f[2001-a[i]][2001-b[i]]++;
	for(int i=1;i<=4001;i++)
	  for(int j=1;j<=4001;j++)
	    f[i][j]=(f[i][j]%mod+(f[i][j-1]+f[i-1][j])%mod)%mod;

	for(int i=1;i<=n;i++) ans=(ans+f[2001+a[i]][2001+b[i]])%mod;
	for(int i=1;i<=n;i++) ans=((ans-C((a[i]<<1)+(b[i]<<1),a[i]<<1))%mod+mod)%mod;
	ans=1ll*ans*(mod+1)/2%mod;
	cout<<(ans%mod+mod)%mod<<"\n";

	return 0;
}

Measured memory_bytes: 116224
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
int main(){
  i64 L,R;
  cin >> L >> R;
  i64 ans = 2020;
  const i64 Mod = 2019;
  const i64 R_max = i64(2*1e9);
  for(i64 l = L; l < min({R,L+2019,R_max}); l++){
    for(i64 r = L+1; r <= min({R,L+2019,R_max}); r++){
      ans = min(ans, (l*r)%Mod);
    }
  }
  cout << ans << endl;
}

  


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

int main()
{
    int n;
    cin >> n;
    vi v(n);
    REP(i, n) {
        cin >> v[i];
    }
    int mini = 1e9;
    int ans = 0;
    REP(i, n) {
        mini = min(mini,v[i]);
        if(mini >= v[i]) ans++;
    }
    cout << ans << endl;


}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int n;
    scanf("%d",&n);
  		
  		if(n % 10 == 3){
          printf("bon");
        }
    
        if(n % 10 == 0||n % 10 == 1||n % 10 == 6||n % 10 == 8){
          printf("pon");
        }
  
		
        if(n % 10 == 2 || n % 10 == 4||n % 10 == 5||n % 10 == 7||n % 10 == 9){
          printf("hon");
        }
  
  return 0;
}
 


Measured memory_bytes: 1724
#include<iostream>
using namespace std;
int main(){
int h,w;
while(1){
cin>>h>>w;
if(h==0&&w==0)break;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if((i+j)%2==0)cout<<"#";
else cout<<".";
}
cout<<endl;
}
cout<<endl;
}
return 0;
}


Measured memory_bytes: 3048
#include <bits/stdc++.h>
#define fr first
#define sc second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pi>
#define vpl vector<pl>
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005
using namespace std;
int n, m;
int a[105];
vector <int> op;
int v[105];
int pos[105];
int main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i = 1 ; i <= n; i++){
        cin >> a[i];
        pos[i] = i;
    }
    for(int i = 1 ; i <= n; i++){
        int p = 1;
        for(int j = n ; j > 0 ; j--){
            if(pos[j] < a[j] && v[j]==0){cout << -1 ;  return 0;}
            if(pos[j] == a[j] && v[j]==0 && p){
                for(int k = j + 1 ; k <= n; k++){
                    pos[k]--;
                }
                v[j] = 1;
                op.pb(a[j]);
                p = 0;
            }
        }
    }
    for(int i = n-1 ; i >= 0 ; i--){
        cout << op[i] << '\n';
    }
}

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t K;

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);
    int arr[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    in >> K;
    out << arr[K-1] << endl;


    return 0;
}
#endif


Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n),b(n);
	long long ptn=1,aa=0,bb=0;
	
    for(int i=0;i<n;i++){
    	cin >> a[i];
    	aa*=10;
    	aa+=a[i];
    	ptn*=(i+1);
    }
    
    sort(a.begin(),a.end());
    
    vector<long long> c(ptn,0);
    int x=0;
    
    do{
    	for(int i:a){
    		c[x]*=10;
    		c[x]+=i;
    	}
    	x++;
    }while(next_permutation(a.begin(), a.end()));
    
   for(int i=0;i<n;i++){
    	cin >> b[i];
    	bb*=10;
    	bb+=b[i];
    }
   
	sort(c.begin(),c.end(),greater<long long>());	
    
    long long ans=0;
    bool f=false;
    for(long long i=0;i<c.size();i++){
    	if(f==true)ans++;
    	if(max(aa,bb)==c[i])f=true;
    	if(min(aa,bb)==c[i]){
    		cout << ans << endl;
    		return 0;
    	}
    }
    
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int b1=0,b2;
    string yn = "Yes";
    rep(i,N){
        b1 = max(b1,b2);
        cin >> b2;
        if( b2 - b1 < -1 ) yn = "No";
    }
    cout << yn << endl;
    return 0;
}

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

int main(void){
  int A,B,C,D,E;
  cin>>A>>B>>C>>D>>E;
  int t;
  if(A>0){
    t=(B-A)*E;
  }
  else{
    t=(-A*C)+D+E*B;
  }
  cout<<t<<endl;
  return 0;
}



Measured memory_bytes: 3096
def calc(l)
    return 0 if l<=2
    return calc((l-1)/2)+1
end

x = gets.to_i

l=2
h=10000000000000

while l<h
    c=(l+h+1)/2
    y=calc(c)
    if y<=x
        l=c
    else
        h=c-1
    end
end

p l
    

Measured memory_bytes: 1916