akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    int N;cin>>N;
    vector<int> S(N);
    for(int i=0;i<N;i++){
        int x;cin>>x;
        x--;
        S[x]=i;
    }
    for(int i=0;i<N;i++){
        if(i) printf(" ");
        int a=(i+1)*30000+S[i];
        printf("%d",a);
    }
    cout<<endl;
    for(int i=0;i<N;i++){
        if(i) printf(" ");
        int b=1000000000-i*30000;
        printf("%d",b);
    }
    cout<<endl;
}


Measured memory_bytes: 768
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int N;
   cin>>N;
   while(N--)
   {
     string com;
     int arr[3]={0};
     int score=0;
     int out=0;
     while(cin>>com)
     {
       if(com=="OUT") out++;
       if(out==3) break;
       if(com=="HIT")
       {
         if(arr[0]==0) arr[0]++;
         else if(arr[1]==0) arr[1]++;
         else if(arr[2]==0) arr[2]++;
         else score++;              
       }
       if(com=="HOMERUN")
       {
         score+=(arr[0]+arr[1]+arr[2]+1);
         arr[0]=0;
         arr[1]=0;
         arr[2]=0;                  
       }
     }          
     cout<<score<<endl;
   }
   //while(1);
   return 0;
 }

 

Measured memory_bytes: 3192
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    string a,b;
    int sum = 0;
    rep(i,n){
        sum+=s[i]=='(' ? 1:-1;
        if(sum<0){
            a+='(';
            sum++;
        }
    }
    b = string(sum,')');
    cout << a+s+b<<endl;
}

Measured memory_bytes: 256
#ABC092C
N=int(input())
A=list(map(int, input().split()))
base=0
Now=0
Next=0
for i in range(N):
    Now=Next
    Next=A[i]
    base+=abs(Next-Now)
base+=abs(A[N-1]-0)
for i in range(N):
    if i==0:
        ans = base - abs(A[i] - 0) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - 0)
    elif i==N-1:
        ans = base - abs(A[i] - A[i - 1]) - abs(0 - A[i]) + abs(0 - A[i - 1])
    else:
        ans = base - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1])
    print(ans)

Measured memory_bytes: 14172
#include <cstdio>
#include <cstring>

char s[100005];

int main()
{
  scanf("%s", s);
  int len = strlen(s);
  
  for (int i = 0; i < len; ++i)
  {
    if (s[i] == s[i + 1])
    {
      printf("%d %d\n", i + 1, i + 2);
      return 0;
    }
    if (s[i] == s[i + 2])
    {
      printf("%d %d\n", i + 1, i + 3);
      return 0;
    }
  }
  puts("-1 -1");
  return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
const int INF = 1 << 30;
using namespace std;
#define pp pair<int,int>
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
int main() {
	int a, b, c, d, e,ans=0;
	string s, ss, sss;
	cin >>a ;
	cout<< 24-a+24 <<endl;
	return 0;
}

Measured memory_bytes: 256
def solve():
  K = int(input())
  if K%2==0 or K%5==0:
    return -1
  ans = 1
  cnt = 7%K
  i = 1
  while cnt!=0:
    cnt += 7*pow(10,i,K)
    cnt %= K
    i += 1
    ans += 1
  return ans
print(solve())

Measured memory_bytes: 63096
#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 h,w,k;
    cin >> h >> w >> k;
    string s;
    vector <vector <int>> m(h,vector <int> (w,0)),ans(h,vector <int> (w,0));

    string ss;
    int ha=0;
    int fh;
    rep(i,h){
        cin >> s;
        rep(j,w){
            ss=s[j];
            if(ss=="#"){
                m[i][j]=1;
                if(ha==0){
                    ha=1;
                    fh=i;
                }
            }
        }
    }
    int ki=0;
    int c=1;
    rep(i,w){
        
        if(m[fh][i]==1){
            if(ki==1){
                ++c;
            }
            else{
                ki=1;
            }
        }
        ans[fh][i]=c;
    }

    rep(i,fh){
        rep(j,w){
            ans[i][j]=ans[fh][j];
        }
    }

    rep(i,h-fh-1){
        ha=0;
        rep(j,w){
            if(m[i+1+fh][j]==1){
                ha=1;
                ++c;
                ki=0;
                break;
            }
        }

        if(ha==0){
            rep(j,w){
                ans[i+1+fh][j]=ans[i+fh][j];
            }
        }
        else{
            rep(j,w){
                
                if(m[i+1+fh][j]==1){
                    if(ki==1){
                    ++c;
                }
                else{
                    ki=1;
                }
        }
        ans[i+1+fh][j]=c;
            }
        }
    }


    rep(i,h){
        rep(j,w){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    

    return 0;
}

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

using namespace std;

int dp[2666][2666];

int main() {
    int k, s;
    cin>>k>>s;
    int cnt = 0;
    for(int i = 0; i <= k; i++) {
        for(int j = 0; j <= k; j++) {
            if(s - i - j >= 0 && s - i - j <= k && !dp[i][j])
                dp[i][j] = 1, cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 25728
N = int(input())
xy = [input().split() for i in range(N)]


calculate_yen = lambda xyi: int(xyi[0]) if xyi[1] == 'JPY' else float(xyi[0]) * 380000.0
calculate_total_yen = lambda xy : sum(map(calculate_yen, xy))

total = calculate_total_yen(xy)

print(total)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l.at(i);

    sort(l.begin(), l.end());

    int answer = 0;
    for (int i = 0; i < n; i++)
    {
        for (int ii = i + 1; ii < n; ii++)
        {
            int iii_max = lower_bound(l.begin(), l.end(), l.at(i) + l.at(ii)) - l.begin();
            answer += max(0, iii_max - (ii + 1));
        }
    }

    cout << answer << endl;
}

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

int main(){
    int r, g, b;
    cin >> r >> g >> b;
    int c = g * 10 + b;
    if (c % 4 == 0){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}
       

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

int main(){
	string surface[8];
	while(cin >> surface[0]){
		for(int i = 1; i < 8; i++)cin >> surface[i];
		for(int i = 0; i < 8; i++){
			for(int j = 0; j < 8; j++){
				if(surface[i][j] == '1'){
					if(surface[i][j + 1] == '1'){
						if(surface[i][j + 2] == '1'){
							cout << "C" << endl;
							goto fin;
						}else{
							if(surface[i + 1][j] == '1'){
								if(surface[i + 1][j + 1] == '1'){
									cout << "A" << endl;
									goto fin;
								}else{
									cout << "G" << endl;
									goto fin;
								}
							}else{
								cout << "E" << endl;
								goto fin;
							}
						}
					}else{
						if(surface[i + 2][j] == '1'){
							cout << "B" << endl;
							goto fin;
						}else{
							if(surface[i + 1][j + 1] == '1'){
								cout << "F" << endl;
								goto fin;
							}else{
								cout << "D" << endl;
								goto fin;
							}
						}
					}
				}
			}
		}
		fin:;
	}
}


Measured memory_bytes: 3132
#include<iostream>
#include<vector>
using namespace std;
const int INF = 1e9+5;
int main()
{
    int n,k; cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    vector<int> dp(n,INF);
    dp[0] = 0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n)
                dp[j] = min(dp[i]+abs(arr[i]-arr[j]),dp[j]);
        }
    }
    cout<<dp[n-1];
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    double sum_a = 0;
    rep(i,N){
        double a;
        cin >> a;
        sum_a += 1.0/a;
    }
    double ans = 1.0/sum_a;
    cout << setprecision(10) << ans << endl;
    return 0;
}

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

int main() {
    long long n, ans=0;
    cin >> n;
    long long dp[10][10];
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            dp[i][j]=0;
        }
    }
    for(int i=1; i<=n; i++) {
        int a, f, l;
        a=i;
        l=a%10;
        while(a/10>0){
            a/=10;
        }
        f=a;
        dp[f][l]++;
    }
    for(int i=1; i<10; i++){
        for(int j=1; j<10; j++){
            if(i==j){
                ans+=dp[i][j]*dp[i][j];
            }
            else ans+=dp[i][j]*dp[j][i];
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


ll n, m, a = 1;

ll gcd(ll a, ll b) {
	return (b == 0 ? a : gcd(b, a % b));
}
ll lcm(ll a, ll b) {
	if (a / gcd(a, b) * b >= MOD) return -1;
	return a / gcd(a, b) * b;	
}
ll solve(ll a) {
	ll res = 0;
	while (a % 2 == 0) {
		res++;
		a /= 2;
	}
	return res;
}
int main() {
	cin >> n >> m;
	vector<ll> s(n);
	REP(i, n) {
		cin >> s[i];
		s[i] /= 2;
	}
	ll ck = solve(s[0]);
	REP(i, n) {
		if (ck != solve(s[i])) {
			cout << 0 << endl;
			return 0;
		}
	}
	REP(i, n) a = gcd(a, s[i]);
	REP(i, n) {
		a = lcm(a, s[i]);
		if (a == -1) {
			cout << 0 << endl;
			return 0;
		}
	}
	ll ans = m / (2 * a);
	if (m >= 2 * a * ans + a)ans++;
	cout <<ans << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll dp[200005][5];

ll solve(int L, const vector<ll>& v){

  rep(i,200005) rep(j,5) dp[i][j] = 1e18;
  rep(i,5) dp[0][i] = 0;
  
  rep(i,v.size()){
    // 0
    dp[i+1][0] = min(dp[i+1][0], dp[i][0] + v[i]);
    // 1
    rep(j,2){
      if(v[i] == 0) dp[i+1][1] = min(dp[i+1][1], dp[i][j] + 2);
      else dp[i+1][1] = min(dp[i+1][1], dp[i][j] + ((v[i]%2==0)?0:1));
    }
    // 2
    rep(j,3){
      if(v[i] == 0) dp[i+1][2] = min(dp[i+1][2], dp[i][j] + 1);
      else dp[i+1][2] = min(dp[i+1][2], dp[i][j] + ((v[i]%2==0)?1:0));
    }
    // 3
    rep(j,4){
      if(v[i] == 0) dp[i+1][3] = min(dp[i+1][3], dp[i][j] + 2);
      else dp[i+1][3] = min(dp[i+1][3], dp[i][j] + ((v[i]%2==0)?0:1));
    }
    // 4
    rep(j,5){
      dp[i+1][4] = min(dp[i+1][4], dp[i][j] + v[i]);
    }
  }

  //rep(i,L+1){
  //  cout << i << "\t" << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << " " << dp[i][3] << " " << dp[i][4] << endl;
  //}
  
  ll ret = 1e18;
  rep(i,5){
    ret = min(ret, dp[L][i]);
  }
  
  return ret;
}

int main(){
  int L;
  cin >> L;
  vector<ll> v;
  rep(i,L){
    ll a;
    cin >> a;
    v.push_back(a);
  }

  cout << solve(L, v) << endl;
  
  return 0;
}


Measured memory_bytes: 9712
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef unsigned long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

struct R{
    ll a, b;
    R(ll _a=1, ll _b=1){
        a = _a;
        b = _b;
    }
    bool operator>=(R x){
        return a*x.b >= x.a*b;
    }
};

ll digit_sum(ll n){
    ll ret = 0;
    while(n > 0){
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

ll K;
vector<R> r;
vector<pair<ll, int>> v;
unordered_set<ll> st;
vector<ll> ans;

signed main(){
    cin >> K;
    for(ll i=1; i<=1000LL; i++){
        for(ll j=1; j<=1000000000000000LL; j*=10){
            ll tmp = i*j+j-1;
            if(tmp > 1e15L) continue;
            if(st.count(tmp)) continue;
            st.insert(tmp);
            v.pb({ tmp, r.size() });
            r.pb(R(tmp, digit_sum(tmp)));
        }
    }
    sort(all(v));
    reverse(all(v));
    
    R M = R((ll)1e18L, 1);
    rep(i, v.size()){
        if(M >= r[v[i].second]){
            M = r[v[i].second];
            ans.pb(v[i].first);
        }
    }
    sort(all(ans));
    rep(i, K) cout << ans[i] << endl;
}

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

int main(void){
   char s[101];
   int n, h;
   scanf("%d", &n);
   scanf("%s", s);
   h = strlen(s);

   if(h <= n){
      printf("%s", s);
   }else{
      for(int i = 0; i < n; i++){
         printf("%c", s[i]);
      }
      printf("...");
   }
   printf("\n");
   return 0;
}


Measured memory_bytes: 1724
import java.util.Scanner;

public class Main {
	public static void main(String[] args){



		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String[] ss = s.split("");
		int counter =0;
		for(int i =0;i<(double)(ss.length)/2;i++) {
			if(!ss[i].equals(ss[ss.length-i-1])) counter++;
		}
		System.out.println(counter);

	}
	public static long calc(int n,int c) {
		long ans = 1;
		for(int i =1;i<n+1;i++) {
			ans = (ans * i)%1000000007;
		}
		ans = ans * reverse(c)%1000000007;

		return ans*reverse(n-c)%1000000007;
	}
	public static long reverse(int c) {
		long divider =1;
		for(int i =1;i<c+1;i++) {
			divider = (divider * i)%1000000007;
		}
		long dividerholder=divider;
		for(int i=1;i<10000;i++) {
			divider = divider*dividerholder%1000000007;
		}
		long dividerholder2 = divider;
		for(int i=1;i<100000;i++) {
			divider = divider*dividerholder2%1000000007;
		}
		for(int i=0;i<5;i++) {
			divider = divider*dividerholder%1000000007;
		}
		return divider;
	}
}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 22612
#include <iostream>
#include <algorithm>

using namespace std;

int arr[1000000];
int G[30] = { 536870912,268435456,134217728,67108864,33554432,16777216,8388608,4194304,2097152,
1048576,524288,262144,131072,65536,32768,16384,8192,4096,2048,1024,512,256,128,64,32,16,8,4,2,1 };
int cnt, m;


void show(int n) {
	cout << m << endl;
	for (int i = 30 - m; i < 30; i++) {
		cout << G[i];
		if (i < 30 - 1)
			cout << " ";
	}
	cout << endl;
	cout << cnt << endl;
	for (int i = 0; i < n; i++)
		cout << arr[i] << endl;
}

void insertionSort(int n,int g) {
	int j, v;
	for (int i = g; i < n; i++) {
		v = arr[i];
		j = i - g;
		while (j >= 0 && arr[j] > v) {
			arr[j + g] = arr[j];
			j -= g;
			cnt++;
		}
		arr[j + g] = v;
	}
}

void shellSort(int n) {
	cnt = 0;
	int i = 0;
	while (G[i] > n)i++;
	m = 30-i;
	for (; i < 30; i++)
		insertionSort(n, G[i]);
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> arr[i];

	shellSort(n);

	show(n);

	return 0;
}

Measured memory_bytes: 5064
#include<stdio.h>

int n;

int main(void)
{
	int ans;
	int c[6] = {1,5,10,50,100,500};
	int i;
	
	ans = 0;
	for( i=0; i<6; i++ ) {
		scanf( "%d", &n );
		ans += c[i] * n;
	}
	
	if ( ans / 1000 > 0 ) {
		printf( "1\n" );
	}
	else {
		printf( "0\n" );
	}
	return 0;
}

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

int main()
{
    int n, a, b, sum=0, total=0;

    cin >> n >> a >> b;

    for (int i=1; i<=n; i++)
    {
        int p = i;
        sum = 0;
        while (p!=0)
        {
            sum += p % 10;
            p /= 10;
        }
        if (sum >= a && sum <= b) total+=i;
	}

    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader br =
				new BufferedReader( new InputStreamReader(System.in) );

		int m = Integer.parseInt(br.readLine());

		Node t = new Node(0);
		for (int i=0; i < m; i++) {
			String[] command = br.readLine().split(" ");

			switch (command[0]) {
			case "insert":
				int k = Integer.parseInt(command[1]);
				insert(t,k);
				break;

			case "find":
				int kk = Integer.parseInt(command[1]);
				if ( find(t,kk) ) System.out.println("yes");
				else System.out.println("no");
				break;

			case "print":
				inorder(t.left);
				System.out.println();
				preorder(t.left);
				System.out.println();
			}
		}
	}

	public static class Node {
		int key;
		Node parent;
		Node left;
		Node right;

		public Node(int key) {
			this.key = key;
		}
	}

	public static void preorder(Node x) {
		System.out.print(" " + x.key);

		if (x.left != null) preorder(x.left);

		if (x.right != null) preorder(x.right);
	}

	public static void inorder(Node x) {
		if (x.left != null) inorder(x.left);

		System.out.print(" " + x.key);

		if (x.right != null) inorder(x.right);
	}

	// t.left = t.right = Tree???root ??¨?????????????????????
	public static void insert(Node t, int k) {
		//Tree t??????????????°x???null
		//Tree t???node????????¨??????????????°x???t???root
		Node x = t.left;

		// Tree t???node??????????????´???
		if (x == null) {
			Node root = new Node(k);
			t.left = t.right = root;
			return;
		}

		// Tree t???root??\???????????¨????????´???
		while (true) {
			if (k < x.key) {
				if (x.left != null) {
					x = x.left;
				} else {
					x.left = new Node(k);
					x.left.parent = x;
					break;
				}
			} else { // x.key <= k
				if (x.right != null) {
					x = x.right;
				} else {
					x.right = new Node(k);
					x.right.parent = x;
					break;
				}
			}
		}
	}

	public static boolean find(Node t, int k) {
		if (t.left == null) return false;

		Node x = t.left; // Tree t???root
		while (x != null) {
			if (k == x.key) {
				return true;
			} else if (k < x.key) {
				x = x.left;
			} else {
				x = x.right;
			}
		}
		return false;
	}
}

Measured memory_bytes: 138660
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
  int H,W; cin >> H >> W;
  vector<vector<char>> F(H,vector<char>(W));
  rep(i,H)rep(j,W) cin >> F[i][j];

  vector<vector<int>> suml(H,vector<int>(W+1)),sumr(H,vector<int>(W+1)),sumu(H+1,vector<int>(W)),sumd(H+1,vector<int>(W));

  rep(i,H)rep(j,W){
      if(F[i][j] == '.') suml[i][j+1] = suml[i][j] + 1;
      else suml[i][j+1] = 0;
  }
  rep(i,H)for(int j = W; j >= 1; j--){
      if(F[i][j-1] == '.') sumr[i][j-1] = sumr[i][j] + 1;
      else sumr[i][j-1] = 0;
  } 
  rep(i,W)rep(j,H){
      if(F[j][i] == '.') sumu[j+1][i] = sumu[j][i] + 1;
      else sumu[j+1][i] = 0;
  }
  rep(i,W)for(int j = H; j >= 1; j--){
      if(F[j-1][i] == '.') sumd[j-1][i] = sumd[j][i] + 1;
      else sumd[j-1][i] = 0;
  }

  int ans = 0;
  rep(i,H)rep(j,W){
      if(F[i][j] == '.'){
        int now = 0;
        now = suml[i][j] + sumr[i][j+1] + sumu[i][j] + sumd[i+1][j] + 1;
        ans = max(ans,now);
      }
  }
  cout << ans << endl;
}


Measured memory_bytes: 67072
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	in(string, S, T);
	char st[28] = {};	//S->T
	for (int i = 0; i < 27; ++i)
		st[i] = 'a' + i;
	/*auto swap_c = [&](char c1, char c2) {
		loop(i, S.size()) {
			if (S[i] == c1) S[i] = c2;
			else if (S[i] == c2) S[i] = c1;
		}
	};*/
	auto swap_c = [&](char c1, char c2) {
		char tmp = st[c1 - 'a'];
		st[c1 - 'a'] = st[c2 - 'a'];
		st[c2 - 'a'] = tmp;
	};
	auto show = [&] {
		std::cerr << "\t-------" << std::endl;
		for (int i = 0; i < 26; ++i) {
			if ('a' + i != st[i]) {
				std::cerr << "\t" << (char)('a' + i) << " -> " << st[i] << std::endl;
			}
		}
		std::cerr << "\t-------" << std::endl;
	};
	loop(i, S.size()) {
		if (st[S[i]-'a'] != T[i]) {
			char to_sw = T[i];
			for (int n = 0; n < 26; ++n) {
				if (st[n] == T[i])
					to_sw = 'a' + n;
			}
			//std::cerr << T[i]<< ", " << to_sw << std::endl;
			//std::cerr << "SWAP: " << S[i] << " <=> " << to_sw << std::endl;
			//for (auto c : S) std::cerr << st[c - 'a']; std::cerr << std::endl;
			//std::cerr << T << std::endl;
			//std::cerr << S;
			swap_c(S[i], to_sw);
			//for (auto c : S) std::cerr << st[c - 'a']; std::cerr << std::endl;
			//show();
			//std::cerr << " -> " << S << std::endl;
		}
	}
	loop(i, S.size()) {
		S[i] = st[S[i] - 'a'];
	}
	//std::cerr << S << std::endl;
	YesNo(S == T);
}

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


int main () {
    int x;
    while (scanf("%d", &x) == 1) {
        int res;
        if (x < 600) res = 8;
        else if (x < 800) res = 7;
        else if (x < 1000) res = 6;
        else if (x < 1200) res = 5;
        else if (x < 1400) res = 4;
        else if (x < 1600) res = 3;
        else if (x < 1800) res = 2;
        else if (x < 2000) res = 1;
        printf("%d\n", res);
    }
}




Measured memory_bytes: 3824
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    string s;
    cin>>s;
    vector <vector <int> >  v;
    vector <int> r2;
    r2.resize(3,0);
    v.resize(n,r2);
    for(int i=n-1;i>=0;i--)
    {
        if(i<n-1)
            v[i]=v[i+1];
        if(s[i]=='R')
            v[i][0]++;
        else if(s[i]=='G')
            v[i][1]++;
        else
            v[i][2]++;
    }
    ll test=0;
    for(int i=0;i<n-2;i++)
        for(int j=i+1;j<n-1;j++)
        {
            if(s[i]==s[j])
                continue;
            int x=j+(j-i);
            int y=0;
            set <char> temp;
            temp.insert('R');
            temp.insert('G');
            temp.insert('B');
            temp.erase(s[i]);
            temp.erase(s[j]);
            bool f=0;
            if(x<n&&s[x]==*temp.begin())
            {
                f=1;
            }
            if(*temp.begin()=='G')
                y=1;
            else if(*temp.begin()=='B')
                y=2;
            test+=v[j+1][y];
            if(f)
                test--;
        }
    cout<<test<<endl;
    
    
    return 0;   
}




 
 


Measured memory_bytes: 3844
#include<bits/stdc++.h>
#define ll long long int
#define INF 0x3f3f3f3f
#define pb push_back
#define se second
#define fi first
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
    ll n,a,b; cin>>n>>a>>b;
    cout<<max((b-a)*(n-2)+1,0LL);
	return 0;
}

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

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    //int t=1; cin>>t; while(t--)
    {
        int n;
        cin >> n;
        
        int ans = 1e18;
        for(int i=1;i*i<=n;i++)
        {
            if(n % i == 0)
                ans = min(ans,i+n/i-2);
        }
        cout << ans << endl; 
    }

    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}


Measured memory_bytes: 256
s = input()

def solve(s):
    length = len(s)
    for i in range(length-1):
        if s[i] == s[i+1]:
            print(i+1, i+2)
            return

    for i in range(length-2):
        if s[i] == s[i+2]:
            print(i+1, i+3)
            return

    print(-1, -1)

solve(s)
        


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int n,k;

int main() {
  cin >>k >>n;
  vector<int> A(n); rep(i, n) cin >>A[i];
  sort(all(A));
  int ans = k;
  int dekai = 0;
  rep(i, n){
    if (i == n-1) chmax(dekai, A[0] + k - A[n-1]);
    else chmax(dekai, A[i+1] - A[i]);
  }
  ans -= dekai;
  cout <<ans <<endl;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	ret := make([]int, 3)
	ret[0] = a + b
	ret[1] = a - b
	ret[2] = a * b
	sort.Sort(sort.IntSlice(ret))
	fmt.Println(ret[2])
}


Measured memory_bytes: 1840
N = int(input())
A_ = list(map(int, input().split()))
ma = -float("inf")
ama = -1
for i, a in enumerate(A_):
    if a>0:
        break
    if ma < a:
        ma = a
        ama = i
else:
    print(ma)
    print(N-1)
    Ans = []
    for i in range(N, ama+1, -1):
        Ans.append(i)
    for i in range(ama):
        Ans.append(1)
    print("\n".join(map(str, Ans)))
    exit()

A = A_[:]

R1 = []
an1 = 0
for i in range(0, N, 2):
    a = A[i]
    if a>=0:
        an1 += a
    else:
        R1.append(i)
idx_r1 = i
R2 = []
an2 = 0
for i in range(1, N, 2):
    a = A[i]
    if a>=0:
        an2 += a
    else:
        R2.append(i)
idx_r2 = i
ans, R, idx_r = (an1, R1, idx_r1) if an1 > an2 else (an2, R2, idx_r2)
idx_r += 1
print(ans)
Ans = []

for idx in R[::-1]:
    del A[idx]
    if 1<=idx<len(A):
        A[idx-1] += A.pop(idx)
    elif idx==0:
        idx_r -= 1
    Ans.append(idx+1)
for idx in range(idx_r, -1, -2):
    if 0<=idx<len(A):
        del A[idx]
        if 1<=idx<len(A):
            A[idx-1] += A.pop(idx)
        Ans.append(idx+1)

for idx in Ans:
    del A_[idx-1]
    if 1<idx<=len(A):
        A[idx-2] += A.pop(idx-1)
# print(Ans)
assert len(A)==1 and A[0]==ans

print(len(Ans))
print("\n".join(map(str, Ans)))


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1000000000

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

	int ans=0;
	for(int i=0;i<n-2;i++){
		if((p[i]<p[i+1] && p[i+1]<=p[i+2])||(p[i]>=p[i+1] && p[i+1]>p[i+2])){
			ans++;
		}
	}

	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N =  100010;  
const int mod = 1e9 + 7;
#define FI first
#define SE second
typedef pair<int, int>pii;

int hs[N];
int num[N];
ll mul[N];
ll Pow(ll a, int x)
{
	ll ret = 1;
	if (a == 1)
		return 1;
	while (x)
	{
		if (x&1)
			ret = ret*a%mod;
		a *= a;
		a %= mod;
		x >>= 1;
	}
	return ret;
}
ll C(int n, int m)
{
	return mul[n]*Pow(mul[m], mod - 2)%mod * Pow(mul[n-m], mod - 2)%mod;
}
int main()  
{  
  // freopen("in.txt","r",stdin);
   int n;

   while (~scanf("%d", &n))
   {
   		mul[1] = mul[0] = 1;
   		for (int i = 2; i <= n + 1; i++)
   		{
   			mul[i] = mul[i-1]*i%mod;
   		}
   		memset(hs, 0, sizeof(hs));
   		int re = 0, fs = 0;
   		for (int i = 0; i <= n; i++)
   		{
   			scanf("%d", num + i);
   			if (hs[num[i]])
   			{
   				// printf("%d>\n", i);
   				re = i + 1;
   				fs = hs[num[i]];
   			}

   			hs[num[i]] = i + 1;
   		}
   		printf("%d\n", n);

   		re = n + 1 - re;
   		int all = fs - 1 + re;
   		for (int i = 2; i <= n; i++)
   		{
   			ll ret = C(n + 1, i);
   			/*if (i - 1 <= re)
   			{
   				// printf("pre :%lld\n", ret);
   				ret -= C(re, i - 1);
   				ret += mod;   				
   				ret %= mod;
   			}*/
   			if (all >= i - 1)
   			{	
   				ret -= C(all, i - 1);
   				ret += mod;
   				ret %= mod;
   			}

   			
   			printf("%lld\n", ret);
   		}
   		puts("1");

   }
   return 0;  
}  

Measured memory_bytes: 2816
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

const int INF = 2e9;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N, K;
    cin >> N >> K;
    int h[100000];
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    int dp[100000];
    dp[0] = 0;
    for(int i = 1; i < N; i++){
        dp[i] = INF;
        for(int j = 1; i-j >= 0 && j <= K; j++) dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
/*
जिन खोजा तिन पाइया, गहरे पानी पैठ,
मैं बपुरा बूडन डरा, रहा किनारे बैठ।
*/
#include<bits/stdc++.h>
#include<iostream>

using namespace std;

#define boost ios::sync_with_stdio(0);cin.tie(0);
#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)a.size()
#define lb lower_bound
#define ub upper_bound
#define vi vector<int >
#define pii pair<int, int>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SQ(a) (a)*(a)
#define ll long long
#define lli long long int
#define ull unsigned long long
#define endl '\n'
#define Pi(a) printf("%d\n",a);
#define debug2(a,b) printf("%d\t%d\n",a,b);
#define debug1(a) printf("%d\n",a);
#define Si(a) scanf("%d",&a);
#define mod 1000000007
#define w(n) while(n--)



int main()
{
	//freopen ("f.in","r",stdin);
 	//freopen ("f.out","w",stdout);
	boost
	//code
	string s,t;
	cin >> s >> t;
	int n = s.length();
	int a[30],b[30];
	memset(a,-1,sizeof(a));
	memset(b,-1,sizeof(b));
	bool ans=true;
	forn(i,n){
		int source = s[i]-'a';
		int target = t[i]-'a';
		if(a[source]!=-1&&a[source]!=target) ans=false;
		if(b[target]!=-1&&b[target]!=source) ans=false;
		a[source]=target;
		b[target]=source;
	}
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;

}
/*
-> check for array out of bounds & array declaired before size input(runtime error)
-> check for int overflow, use ll
-> check for corner cases like 0
-> check for j++ in while loop for every case
-> use boost except for interactive problems
*/

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	int ans = 0;
	for(int i = a; i <= b; i++){
		string s,t;
		int cp = i;
		while(cp){
			s.push_back(cp%10);
			cp /= 10;
		}
		t = s;
		reverse(BE(s));
		if(s == t)
			ans++;
	}

	cout << ans << endl;

	return 0;
}

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

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

  int n = s;
  int backets[1000001];
  backets[s] = s;
  int i = 2;
  while (true) {
    if (n % 2 == 0) {
      n = n / 2;
    } else {
      n = 3 * n + 1;
    }

    if (backets[n] == n) {
      cout << i << endl;
      break;
    }

    backets[n] = n;
    i++;
  }
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).ok();

    let mut iter = line.split_whitespace().map(|x| x.parse::<f64>().unwrap());
    let x1 = iter.next().unwrap();
    let y1 = iter.next().unwrap();
    let x2 = iter.next().unwrap();
    let y2 = iter.next().unwrap();

    let distance = ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)).sqrt();
    println!("{}", distance);
}



Measured memory_bytes: 5060
#include<iostream>
using namespace std;
long long a,b,sum;
int main(){
	cin>>a>>b;
	if(a==1 || b==1){
		cout<<1<<endl;
		return 0;
	}
	sum=a*b;
	if(sum%2==0){
		cout<<sum/2<<endl;
	}else{
		cout<<sum/2+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a,b,c,i,j,x,y,z;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d%d%d",&a,&b,&c);
        x=a*a;
        y=b*b;
        z=c*c;
        if(x+y==z || x+z==y || y+z==x)
        printf("YES\n");
        else
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 576
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
double pi=3.1415926535898;
//double pi=acos(-1.0);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define pii        pair<int,int>
#define pis        pair<int,string>
#define vi         vector<int>
#define F          first
#define S          second
//#define max(a,b) a<b?b:a  __builtin_popcount;
//#define min(a,b) a<b?a:b
//freopen("output.txt","w",stdout),freopen("input.txt","r",stdin);
const ll M  = 1e9+7 ;
const int N = 50500;
const int inf = INT_MAX;
const double eps = 1e-6;
//////////////////////    Hi    ^_^  hack me if you can :P
int n,x,mx;
int f[100100];
int main()
{
    cin>>n;
    lop(i,n)
    {
        cin>>x;mx+=++f[x]==1;
    }

    cout << mx - !(mx&1) ;

    r0;
}

/*



https://ideone.com/goT6Vy//http:
codeforces.com/problemset/problem/466/D

, vector < pair <int,int > >, greater <pair <int, int> >
http://codeforces.com/contest/295/submission/17929453
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);

ll pwmod(ll a, ll n, ll mod)
{
    ll ret = 1;
    while (n)
    {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

for (int i=0; i<n; i++)            Hi    ^_^  hack me if you can :P

int mx[]= {0,0,1,-1, 1,1,-1,-1};
int my[]= {1,-1,0,0, 1,-1,1,-1};
bool inside (int i,int j){return (i>=0 && i<n && j>=0 && j<m);}

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void gcd(LL n,LL m,LL &d,LL &xx,LL &yy)
{
    if(!m)
    {
        d=n;
        xx=1;
        yy=0;
    }
    else
    {
        gcd(m,n%m,d,yy,xx);
        yy-=xx*(n/m);
    }
}

int getm(int l,int r)
{
    if(l>r)
        return N;
    if(l==r)
        return 0;
    if(l==r-1)
        return s[l] != s[r];
    if(s[l]==s[r])
        return getm(l+1,r-1);
    else
        return 1+min(getm(l+1,r),getm(l,r-1));
}

int BIT[si], a[si], n;
void update(int x, int delta)
{
    for(; x <= N; x += x&-x)
        BIT[x] += delta;
}
int query(int x)
{
    int sum = 0;
    for(; x > 0; x -= x&-x)
        sum += BIT[x];
    return sum;
}

#define sc(x)      scanf("%d",&x)
#define scl(x)     scanf("%lld",&x)
#define pr(x)      printf("%d ",x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define prlln(x)   printf("%lld\n",x)
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x)


*/


Measured memory_bytes: 640
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
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(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

template<class Integer>
class BinaryIndexedTree
{
private:
	ull maxSize_;
	vector<Integer> values_;
public:
	BinaryIndexedTree(ull maxSize) : maxSize_(maxSize), values_(maxSize_, 0) {}

	void update(ll index, Integer increment)
	{
		if (maxSize_ <= index)
		{
			throw invalid_argument("Index should be less than maxSize.");
		}
		++index;

		while (index <= maxSize_)
		{
			values_[index - 1] += increment;
			index += index & -index;
		}
	}

	Integer query(ll index)
	{
		if (maxSize_ <= index)
		{
			throw invalid_argument("Index should be less than maxSize.");
		}
		++index;

		Integer res = 0;
		while (index > 0)
		{
			res += values_[index - 1];
			index -= index & -index;
		}
		return res;
	}
};
using bit = BinaryIndexedTree<ll>;

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

	ll N, D, A;
	cin >> N >> D >> A;

	ll x, h;
	vector<pair<ll, ll>> xhs;
	xhs.reserve(N);
	for (ll i = 0; i < N; ++i) {
		cin >> x >> h;
		xhs.emplace_back(x, h / A + (h % A == 0 ? 0LL : 1LL));
	}
	sort(xhs.begin(), xhs.end());

	vector<ll> range_indices(N);
	for (ll i = 0; i < N; ++i) {
		range_indices[i] = distance(
			xhs.begin(),
			upper_bound(
				xhs.begin(), xhs.end(),
				make_pair(xhs[i].first + D * 2LL, 10000000000000000LL)
			)
		);
	}

	ll res = 0LL;
	ll incr = 0LL;
	bit bit(N);
	for (ll i = 0; i < N; ++i) {
		incr = xhs[i].second - bit.query(i);
		if (incr < 0LL) continue;
		res += incr;
		bit.update(i, incr);
		if (range_indices[i] < N) {
			bit.update(range_indices[i], -incr);
		}
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 6528
from collections import deque

if __name__ == '__main__':
    n, k = list(map(int, input().split(" ")))
    p = list(map(int, input().split(" ")))

    d = deque([0])
    for i in range(n):
        d.append(d[i] + p[i])

    # print(d)

    max_sum = 0
    rangeN = n - k + 1

    for i in range(rangeN):
        max_sum = max(max_sum, d[i + k] - d[i])
    # print(max_sum)

    # r_array = [sum(p[i:i + k]) for i in range(rangeN)]
    print((max_sum / 2) + (k * 0.5))

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    
    int mod = 1000000007;
    vector<int> B(N + 1);
    for (int i = 0; i < N; ++i) ++B[A[i]];
    if (N % 2 == 0) {
        bool judge = true;
        for (int i = 0; i < N + 1; ++i) {
            if (B[i] > 0) {
                if (i % 2 == 0) judge = false;
                if (B[i] != 2) judge = false;
            }
        }
        if (!judge) {
            cout << 0 << endl;
            return 0;
        }
        int ans = 1;
        for (int i = 0; i < N + 1; ++i) {
            if (B[i] > 0) {
                ans *= 2;
                ans %= mod;
            }
        }
        cout << ans << endl;
        return 0;
    } else {
        bool judge = true;
        for (int i = 0; i < N + 1; ++i) {
            if (B[i] > 0) {
                if (i % 2 == 1) judge = false;
                if (i == 0 && B[i] != 1) judge = false;
            }
        }
        if (!judge) {
            cout << 0 << endl;
            return 0;
        }
        int ans = 1;
        for (int i = 0; i < N + 1; ++i) {
            if (B[i] > 0) {
                ans *= B[i];
                ans %= mod;
            }
        }
        cout << ans << endl;
        return 0;
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;

int main() {
  int N;
  cin >> N;
  vector<P> A(N);
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    A[i] = make_pair(a, i + 1);
  }
  
  sort(A.begin(), A.end());
  for (int i = 0; i < N - 1; ++i) cout << A[i].second << " ";
  cout << A[N - 1].second << endl;
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < n; i++)
    {
        cout << s[i] << t[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256