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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define PI         2*acos(0.0)
#define lb         lower_bound
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define btpc       __builtin_popcountll
#define spc(x)     cout<<fixed<<setprecision(x)

const   long long  cs=2e5+5;
const   long long  inf=1e18;
const   long long  mod=1e9+7;
void solve()
{
    int64_t t,n,m,a,b,c,d,e,i,j,k,x,y,cnt=0,cnt1=0;
    bool flag = false;   
    
    cin>>n;
    lve v(n);
    for(auto &ss:v) cin>>ss;
    for(i=1;i<n-1;i++)
    {
        if((v[i]>v[i-1] && v[i]<v[i+1]) || (v[i]<v[i-1] && v[i]>v[i+1]))
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3532
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;

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

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

	double sum = (double)v[0];
	for (int i = 1; i < n; ++i) {
		sum += v[i];
		sum /= 2.0;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>?): Unit {
    val n = readLine()!!.trim().toInt()
    val state = readLine()!!.trim()
    val countWhite = IntArray(n + 1){if (it > 0 && state[it - 1] == '.') 1 else 0}
    for (i in 1 .. n) countWhite[i] += countWhite[i - 1]
    println(
            (0 .. n).map{i ->
                val leftBlack = i - countWhite[i]
                val rightWhite = countWhite.last() - countWhite[i]
                leftBlack + rightWhite
            }.min()!!
    )
}

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

ll ceil(ll a, ll b) {
    if (b < 0) {
        a *= -1;
        b *= -1;
    }
    if (a >= 0) {
        return (a + b - 1) / b;
    } else {
        return a / b;
    }
}

int main() {
    int N;
    cin >> N;
    vector<ll> T(N), A(N);
    for (int i = 0; i < N; i++) {
        cin >> T[i] >> A[i];
    }

    ll t = T[0], a = A[0];
    for (int i = 1; i < N; i++) {
        if (T[i] >= t && A[i] >= a) {
            t = T[i];
            a = A[i];
        } else {
            ll n = max(ceil(t, T[i]), ceil(a, A[i]));
            t = T[i] * n;
            a = A[i] * n;
        }
    }
    cout << t + a << endl;
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<int, int> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
/*#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("pyramid.in", "r", stdin);
#endif*/
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 5e3 + 15;
int dx[8] = { -1, 0, 0, 1, 1, -1, 1, -1 };
int dy[8] = { 0, -1, 1, 0, 1, -1, -1, 1 };


int main()
{
	fast();
	string s;
	cin >> s;
	ll sum = 0;
	ll n = sz(s);
	map<vector<string>, int> vis;
	for (ll i = 0; i < (1ll << n); i++)
	{
		vector<string> vec;
		string tmp = "";
		bool f = 0;
		for (int j = 0; j < n; j++)
		{
			if (i&(1 << j))
			{
				if (f)
				{
					if (sz(tmp))
					{
						vec.push_back(tmp);
						tmp = "";
					}
				}
				tmp += s[j];
				f = 0;
			}
			else
			{
				if (!f)
				{
					if (sz(tmp))
					{
						vec.push_back(tmp);
						tmp = "";
					}
				}
				tmp += s[j];
				f = 1;
			}
		}
		if (sz(tmp))
			vec.push_back(tmp);
		if (!vis[vec])
		{
			vis[vec]++;
			ll x = 0;
			for (int i = 0; i < sz(vec); i++)
			{
				x += stoll(vec[i]);
			}
			sum += x;
		}
	}
	cout << sum << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

void prime_factorization(ll N, map<ll, int>& res) {
  if(N == 1 || N == 0) return;
  ll n = N;
  ll i = 2;
  while(n >= i * i) {
    while(n % i == 0) {
      if(res.count(i)) res[i]++;
      else res[i] = 1;
      n /= i;
    }
    if(i == 2) i++;
    else i += 2;
  }
  if(n != 1) res[n]++;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  map<ll, int> primes;
  for(int i=1; i<=n; i++) {
    prime_factorization(i, primes);
  }
  vector<ll> cnt(100);
  for(auto ele: primes) {
    cnt[ele.second]++;
  }
  rrep(i, 99) cnt[i] += cnt[i+1];
  ll ans = 0;
  ans += cnt[4] * (cnt[4]-1) / 2 * (cnt[2]-2);
  ans += cnt[24] * (cnt[2]-1);
  ans += cnt[14] * (cnt[4]-1);
  ans += cnt[74];
  cout << ans << endk;
  return 0;
}


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

#define int long long 
#define dou double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	int n,k;
	cin >> n >> k;
	int p[n+1];
	for(int i=0;i<n;i++)
		cin >> p[i];
	sort(p,p+n);
	int count=0;
	for(int i=0;i<k;i++)
		count+=p[i];
	cout << count << endl;
}

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	return 0;
}


Measured memory_bytes: 3636
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
    int a[1000000];
    int b[1000000];
int main()
{
    int n;
    cin>>n;
    for (int i=1;i<=n;i++)
        cin>>a[i];
    int cnt=0;
    for (int i=1;i<=n;i++)
        if (a[i]==i) {b[i]++;cnt++;}
    for (int i=1;i<=n;i++)
        if (b[i]>0 && b[i+1]>0) {cnt--;i++;}
    cout<<cnt<<endl;
    return 0;
} 

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,j,n) for (int i = n; j<=i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

int main(){
  ll N;cin>>N;
  vector<ll> wt_time(5);
  REP(i,0,5){cin>>wt_time[i];}
  ll time=ceill(1.*N/(*min_element(wt_time.begin(),wt_time.end())))+4;
  print(time)
}


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

using namespace std;

int a[100010];

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n;scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	long long ans=a[1]-1;int ma=1;
	for (int i=2;i<=n;i++)
	{
		if (a[i]==ma+1)
			ma++;
		else
			ans+=(a[i]-1)/(ma+1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
int n,x[N],y[N];
string ans;
vector<int>v;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&x[i],&y[i]);
    for(int i=2;i<=n;i++)
        if((abs(x[i])+abs(y[i]))%2!=(abs(x[i-1])+abs(y[i-1]))%2)
    {
        printf("-1\n");return 0;
    }
    if((abs(x[1])+abs(y[1]))%2==0) v.push_back(1);
    for(int i=0;i<=30;i++) v.push_back(1<<i);
    printf("%d\n",v.size());
    for(int i=0;i<v.size();i++)
        printf(i==v.size()-1?"%d\n":"%d ",v[i]);
    for(int i=1;i<=n;i++)
    {
        ans="";
        for(int j=v.size()-1;j>=0;j--)
        {
            if(abs(x[i])>abs(y[i]))
            {
                if(x[i]<0) x[i]+=v[j],ans+='L';
                else x[i]-=v[j],ans+='R';
            }
            else
            {
                if(y[i]<0) y[i]+=v[j],ans+='D';
                else y[i]-=v[j],ans+='U';
            }
        }
        //cout<<x[i]<<' '<<y[i]<<endl;
        for(int i=ans.size()-1;i>=0;i--)
            printf("%c",ans[i]);
        putchar('\n');
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

int main(void) {
	int h, w;
	cin >> h >> w;
	vector<string>A(h);
	int step = 0;
	for (int i = 0; i < h; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (A[i][j] == '#') {
				step++;
			}
		}
	}
	if (step == h + w - 1) {
		cout << "Possible";
	}
	else {
		cout << "Impossible";
	}

	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use {
    itertools::Itertools,
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::io::Write,
    std::ops::*,
};

macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

const MOD: usize = 1_000_000_007;

fn prod(a: &Vec<Vec<usize>>, b: &Vec<Vec<usize>>) -> Vec<Vec<usize>> {
    let mut c = vec![vec![0; 3]; 3];
    for i in 0..3 {
        for j in 0..3 {
            for k in 0..3 {
                c[i][j] += a[i][k] * b[k][j];
            }
            c[i][j] %= MOD;
        }
    }
    c
}
fn pow(a: &Vec<Vec<usize>>, n: usize) -> Vec<Vec<usize>> {
    if n == 0 {
        vec![vec![1, 0, 0], vec![0, 1, 0], vec![0, 0, 1]]
    } else {
        let mut x = pow(a, n >> 1);
        x = prod(&x, &x);
        if n & 1 == 1 {
            x = prod(&x, a);
        }
        x
    }
}

#[fastout]
fn main() {
    input! {
        mut s: usize,
    }
    let a = vec![vec![1, 0, 1], vec![1, 0, 0], vec![0, 1, 0]];
    let ans = if s < 3 { 0 } else { pow(&a, s - 2)[0][2] };
    println!("{}", ans);
}


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

int main(){
	long long int i, j, H, count = 0;

	scanf("%lld", &H);
	i = 1;
	while (H >= 1){
		count += i;
		H /= 2;
		i *= 2;

	}



	printf("%lld\n", count);

	return 0;
}

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

int main() {
    int tc = 1;
    while(tc--) {
        int n;
        cin>>n;
        vector<int> vec1, vec2;
        for(int i = 0; i<n; i++) {
            int u, v;
            cin>>u>>v;
            vec1.push_back(u + v);
            vec2.push_back(u - v);
        }

        sort(vec1.begin(), vec1.end());
        sort(vec2.begin(), vec2.end());
        int ans = max( vec1.back() - vec1[0], vec2.back() - vec2[0]);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 5088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
	static final String OPERATOR_PLUS = "+";
	static final String OPERATOR_MINUS = "-";
	static final String OPERATOR_MULTIPLIED = "*";
	static final String OPERATOR_DIVISION = "/";
	static final String OPERATOR_END = "?";

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		String[] inputStr = null;
		int inputA;
		int inputB;
		List<Integer> calcList = new ArrayList<>();
		try {
			while (true) {
				inputStr = (input.readLine()).split(" ");
				inputA = Integer.parseInt(inputStr[0]);
				inputB = Integer.parseInt(inputStr[2]);
				
				if (Arrays.asList(inputStr).contains(OPERATOR_PLUS)) {
					calcList.add((inputA + inputB));
				} else if (Arrays.asList(inputStr).contains(OPERATOR_MINUS)) {
					calcList.add((inputA - inputB));
				} else if (Arrays.asList(inputStr).contains(OPERATOR_MULTIPLIED)) {
					calcList.add((inputA * inputB));
				} else if (Arrays.asList(inputStr).contains(OPERATOR_DIVISION)) {
					calcList.add((int)(inputA / inputB));
				} else if (Arrays.asList(inputStr).contains(OPERATOR_END)) {
					break;
				}
			}
			for (Integer i : calcList) {
				System.out.println(i);
			}
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}

}



Measured memory_bytes: 24228
from heapq import heappush, heappop, heappushpop
N = int(input())
A = [int(a) for a in input().split()]

def calc(L):
    s = sum(L[:N])
    h = []
    X = [s]
    for i in range(N):
        heappush(h, L[i])
    for i in range(N, 2*N):
        s += L[i] - heappushpop(h, L[i])
        X.append(s)
    return X

B = calc(A)
C = calc([-a for a in A][::-1])[::-1]
print(max([B[i] + C[i] for i in range(N+1)]))

Measured memory_bytes: 39260
#include<iostream>
#include<string>

using namespace std;

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

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

    int main(){
        int n;
        int b[200];

        cin >> n;
        for(int i = 1; i <= n-1; i++) cin >> b[i];
        // cout << endl ;

        int ans = 0;
        int tmp = 0;
        for(int i = n-1;; i--){
            if(b[i] <= b[i+1] || i == n-1){
                ans += b[i];
                tmp = b[i];
                // cout << "b[" << i << "] is " << b[i] << " b[" << i+1 << "] is " << b[i+1] << endl;
                // cout << "if " <<tmp << endl;
            } else {
                ans += b[i+1];
                tmp = b[i+1];
                // cout <<"else " << tmp << endl;

        }
        if(i == 1){  
            // cout << "tmp is " << tmp << " b[0] is " << b[1] << endl;
            if(tmp < b[1]){
                ans += b[1];
                // cout << "if " << b[1] << endl;
            } else {
                ans += tmp;  
                // cout << "else " << tmp << endl;
            } 
            // cout << tmp << endl;
            break;
        }
        }
        cout << ans << endl;
    }

Measured memory_bytes: 256
def main():
  N,M,X,Y = map(int, input().split())
  max_x = max(map(int,input().split()))
  min_y = min(map(int,input().split()))
  max_xx = max(max_x,X)
  min_yy = min(min_y,Y)
  #print(max_x)
  #print(min_y)
  #print(max_xx)
  #print(min_yy)
  
  if min_yy - max_xx > 0:
    print("No War")
  else:
    print("War")
    
main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[300010], dp[300010], b[300010];
ll mp[512][100001];
int main(){
    int n;
    while(cin>>n){
        ll ans=0;
        for(int i=1; i<=n; ++i){
            scanf("%d%d",b+i, a+i);
        }
        mp[0][0]=0;
        for(int i=1; i<=n; ++i){
        	dp[i]=dp[i/2]+1;
        	int tmp=a[i], tmp1=b[i];
        	if(dp[i]<=9){
	        	for(int j=0; j<=100000; ++j)
	        		mp[i][j]=mp[i/2][j];
        		for(int it=0; it<=100000-tmp; ++it){
	        		mp[i][it+tmp]=max(mp[i][it+tmp], mp[i/2][it]+tmp1);
        		}
	        	ll tmp2=0, tmp3;
	        	for(int it=0; it<=100000; ++it){
	        		mp[i][it]=max(tmp2, mp[i][it]);
	        		tmp2=mp[i][it];
	        	}
        	}
        }
        int q;
        scanf("%d", &q);
        int x, l;
        vector<pair<int, int> > v;
        for(int i=0; i<q; ++i){
        	scanf("%d%d",&x,&l);
        	v.clear();
        	while(dp[x]>9){
        		v.push_back(mk(a[x], b[x]));
        		x/=2;
        	}
        	ans=0;
        	for(int i=0; i<(1<<v.size()); ++i){
        		int tmp=0; ll tmp1=0, tmp2;
        		for(int j=0; j<v.size(); ++j){
        			if(i&(1<<j)){
        				tmp+=v[j].fs;
        				tmp1+=v[j].sc;
        				if(tmp>l){
        					break;
        				}
        			}
        		}
        		if(tmp>l){
        			continue;
        		}
        		tmp2=mp[x][l-tmp];
        		ans=max(ans, tmp2+tmp1);
        	}
        	printf("%lld\n",ans);
        }
    }
  return 0;
}




Measured memory_bytes: 406084
n,m=[int(i) for i in input().split()]
keta=[-1 for i in range(n)]
flg=True
for i in range(m):
    s,c=[int(j) for j in input().split()]
    if keta[s-1]!=-1 and keta[s-1]!=c:
        flg=False
    keta[s-1]=c
if flg:
    if keta[0]==-1 and n>1:
        keta[0]=1
    if keta[0]==0 and n>1:
        print(-1)
    else:
        for i in range(n):
            if keta[i]==-1:
                keta[i]=0
        print(*keta,sep="")
else:
    print(-1)

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
		
      	string str = (a>b)?b.ToString():a.ToString();
      	int count = (a>b)?a:b;
        string ans = "";
      	for(int i=0;i<count;i++){
          ans += str;
        }
      
      	Console.WriteLine(ans);
 
	}
}

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

int main(){
while(1){
	int n,c,a[100000+2],b[100000+2],k=0,ans=0;
	scanf("%d",&n);
	if(n==0)break;
	scanf("%d",&a[0]);
	b[0]=1;
	for(int i=2;i<=n;i++){
		scanf("%d",&c);
		if(c==a[k])b[k]++;
		else {
			if(i%2!=0){
				a[k+1]=c; b[k+1]=1; k++;
			}
			else {
				if(k==0){a[0]=c; b[0]+=1;}
				else {b[k-1]+=b[k]+1; k--;}
			}
		}
	}
	for(int i=0;i<=k;i++){
		if(a[i]==0)ans+=b[i];
	}
	printf("%d\n",ans);
}
}

Measured memory_bytes: 1200
def solve():
    ans = 0
    A, B = map(int, input().split())
    lower8 = A/0.08
    upper8 = (A+1)/0.08
    lower10 = B/0.1
    upper10 = (B+1)/0.1
    for i in range(1,2001):
        if i>=lower8 and i<upper8 and i>=lower10 and i<upper10:
            return i
    return -1
print(solve())

Measured memory_bytes: 9148
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {

	int N;
	cin >> N;
	if (N%10 == 7 || (N/10)%10 == 7 ||(N/100)%10 == 7 ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long 
signed main()
{
    string a, b;
    cin >> a >> b;

    unordered_map<char, vector<int>> m;
    for (int i = 0; i < a.length(); i++)
        m[a[i]].push_back(i + 1);
    int ans = 0;
    int l;
    if (m.find(b[0]) != m.end())
    {
        l = m[b[0]][0];
        ans += l;
    }
    else
    {
        l = -1;
        ans = -1;
    }

    for (int i = 1; i < b.length() && l <= a.length(); i++)
    {
        if (m.find(b[i]) != m.end())
        {
            // vector<int> m[b[i]] = m[b[i]];
            auto aa = upper_bound(m[b[i]].begin(), m[b[i]].end(), l);
            if (aa != m[b[i]].end())
            {
                ans+=*aa-l;
                l=*aa;
            }
            else
            {
                ans+=a.length()-l;
                l=m[b[i]][0];
                ans+=l;

            }
            
        }
        else
        {
            l = -1;
            ans = -1;
        }
    }
    cout<<ans<<endl;
}

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

int count(int H,int W,int a,int b,vector<string> str);

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> str(H);
  for(int i=0;i<H;i++)cin >> str.at(i);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(str.at(i)[j]=='#')continue;
      else str.at(i)[j]='0' + count(H,W,i,j,str);
    }
  }
  for(int i=0;i<H;i++)cout << str.at(i) << endl;
  return 0;
}

int count(int H,int W,int a,int b,vector<string> str){
  int k=0;
  for(int i=a-1;i<=a+1;i++){
    if(i<0 || i>H-1)continue;
    for(int j=b-1;j<=b+1;j++){
      if(j<0 || j>W-1)continue;
      if(str.at(i)[j]=='#')k++;
    }
  }
  return k;
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

char grid[20][20];
bool used[20][20];

int main() {
  // 入力
  int H, W;
  cin >> H >> W;
  fill(grid[0], grid[19], '.');
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> grid[i][j];
    }
  }

  int x = 1, y = 1;
  bool flag = false;
  while (1) {
    used[y][x] = true;

    if (grid[y+1][x] == '#' && grid[y][x+1] == '.') {
      y++;
    } else if (grid[y+1][x] == '.' && grid[y][x+1] == '#') {
      x++;
    } else {
      break;
    }

    if (y == H && x == W) {
      flag = true;
      used[y][x] = true;
      break;
    }
  }

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (grid[i][j] == '#' && !used[i][j]) flag = false;
    }
  }

  // 解答
  cout << (flag ? "Possible" : "Impossible") << endl;

  return 0;
}


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

ll powmod(ll a, ll b){
    if(b==0) return 1;
    if(b%2==1) return (a*powmod(a,b-1)) % p;
    else{
        ll x = powmod(a,b/2);
        return (x*x) % p;
    }
}

ll combinemod(ll a, ll b){
    ll x=1,y=1;
    for(int i=1;i<=b;i++){
        y = (y*i)%p;
    }
    for(int i=a-b+1;i<=a;i++){
        x = (x*i)%p;
    }

    return (x * powmod(y,p-2)) % p;
}

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(),a.end());
    vector<ll> cnts1(n), cnts2(n);
    vector<ll> x(n+1), y(n+1);
    x.at(0) = 1;
    y.at(0) = 1;
    rep(i,n){
        x.at(i+1) = x.at(i) * (i+1) % p;
        y.at(i+1) = powmod(x.at(i+1),p-2);
    }

    rep(i,n){
        // cnts1.at(i) = combinemod(i,k-1) % p;
        if(i-(k-1) >= 0){
            cnts1.at(i) = x.at(i) * y.at(k-1) % p * y.at(i-(k-1)) % p;
        }
        // cnts2.at(i) = combinemod(n-i-1,k-1) % p;
        if(n-i-1-(k-1) >= 0){
            cnts2.at(i) = x.at(n-i-1) * y.at(k-1) % p * y.at(n-i-1-(k-1)) % p;
        }
    }
    // rep(i,n) cout << cnts1.at(i) << " ";
    // cout << endl;
    // rep(i,n) cout << cnts2.at(i) << " ";
    // cout << endl;


    ll ans=0;
    rep(i,n) ans = (ans + (((a.at(i)+p) * cnts1.at(i)) % p)) % p;
    rep(i,n) ans = (p + ans - ((a.at(i)+p) * cnts2.at(i) % p)) % p;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
 
typedef pair< int, int > ii;
typedef vector< ii > vii;

void solve(){
	ll n; cin>>n;
	vector< ll > v(n);
	for(ll &i : v) cin>>i;
	ll ans = 1;
	for(int i = 0; i<n; i+=2){
		ans = ans ^ v[i] ^ v[i + 1]; 
	}
	ans = ans ^ 1;
	for(int i = 0; i<n; i++){
		cout<<(ans ^ v[i])<<" ";
	}
	cout<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;// cin>>t;
	while(t--){
		solve();
	}
	return 0;
}



Measured memory_bytes: 4772
n,y=map(int, input().split())
ans=False
for i in range(n+1):
  for j in range(n-i+1):
    if 10000*i+5000*j+1000*(n-i-j)==y:
      ans=True
      x=i
      y=j
      z=n-i-j
if ans:
  print(x,y,z)
else:
  print(-1,-1,-1)

Measured memory_bytes: 9148
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define po pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define M  1000000007
#define I 10000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); }

int main()
{
    jaldi
    #ifndef ONLINE_JUDGE 
    //TakeInput
    #endif
        
    ll n,i,j,k,m;
    cin>>n;
    double a[n+1];
    fon(i,1,n+1){
        cin>>a[i];
    }
    double dp[n+1][n+1];
    in0(dp);
    dp[0][0]=1;
    double count=0;
    fon(i,1,n+1){
        dp[i][0]=dp[i-1][0]*(1-a[i]);
        //cout<<dp[0][i]<<" ";
    }
    fon(i,1,n+1){
        fon(j,1,n+1){
            if(j<=i){
                dp[i][j]=a[i]*dp[i-1][j-1]+(1-a[i])*dp[i-1][j];
            }
            //cout<<dp[i][j]<<" ";
            if(i==n && j>n/2){
                count+=dp[i][j];
            }
        }
        //cout<<endl;
    }
    printf("%.10f",count);


}
 
 








 



Measured memory_bytes: 70656
use proconio::{fastout, input};

fn pow(mut x: i64, mut y: i64, z: i64) -> i64 {
    let mut r = 1;
    while y > 0 {
        if y & 1 == 1 {
            r = r * x % z;
        }
        x = x * x % z;
        y >>= 1;
    }
    r
}

fn inv(x: i64, y: i64) -> i64 {
    pow((x % y + y) % y, y - 2, y)
}

#[fastout]
fn main() {
    const M: i64 = 1_000_000_007;
    input! {
        n: usize, mut k: usize,
        mut a: [i64; n],
    }
    let mut pos = 0;
    let mut zero = 0;
    let mut neg = 0;
    for &x in a.iter() {
        if x > 0 {
            pos += 1;
        } else if x < 0 {
            neg += 1;
        } else {
            zero += 1;
        }
    }
    if k > pos + neg {
        println!("0");
        return;
    }
    a.sort();

    if pos == 0 {
        if k % 2 == 0 {
            let mut acc = 1;
            for i in 0..k {
                acc = acc * a[i] % M;
            }
            acc = (acc % M + M) % M;
            if zero > 0 && acc < 0 {
                println!("0");
            } else {
                println!("{}", acc);
            }
        } else {
            let mut acc = 1;
            for i in n - k..n {
                acc = acc * a[i] % M;
            }
            acc = (acc % M + M) % M;
            if zero > 0 && acc < 0 {
                println!("0");
            } else {
                println!("{}", acc);
            }
        }
        return;
    }
    {
        let mut l = 0;
        let mut acc = 1;
        while k > pos {
            acc = acc * a[l] % M * a[l + 1] % M;
            l += 2;
            k -= 2;
        }
        for i in n - k..n {
            acc = acc * a[i] % M;
        }
        for _ in 0..(neg - l) / 2 {
            if n - k + 1 >= n {
                break;
            }
            if a[l] * a[l + 1] > a[n - k] * a[n - k + 1] {
            } else {
                break;
            }
            acc = acc * a[l] % M * a[l + 1] % M;
            acc = acc * inv(a[n - k], M) % M * inv(a[n - k + 1], M) % M;
            l += 2;
            k -= 2;
        }
        acc = (acc % M + M) % M;
        println!("{}", acc);
    }
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename P, typename Q>
istream& operator >> (istream& is, pair<P, Q>& p)
{
  is >> p.first >> p.second;
  return is;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& v)
{
  each (i, v) is >> i;
  return is;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<int> a(n);
    cin >> a;
    int sum = 0;
    each (i, a) {
      for (int j = 1; j < 30; ++j) {
        sum += (i % (1 << j) == 0);
      }
    }
    cout << sum << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
// God put a smile upon your face <3

#include <bits/stdc++.h>

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

string str;

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> n >> str)
    {
		ll cnt = 0;

		for(auto it: str) if(it == 'R') cnt++;

		ans = 0;
		for(ll i = 0; i < cnt; i++) if(str[i] == 'W') ans++;

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


}





Measured memory_bytes: 3748
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>

#define MP std::make_pair
#define rep(i, l, r) for (int i = (l); i <= (r); ++ i)
#define per(i, r, l) for (int i = (r); i >= (l); -- i)
#define PE(x, a) for (int x = head[a]; x;x = edge[x].next)
#define pb push_back
#define CL(a, b) memset(a, b, sizeof a)
#define PII std::pair<int, int>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

typedef long long ll;

const ll HA = 1e9 + 7;

ll f[45][(1 << 17) + 7];
int n, x, y, z;

int main() {
	scanf("%d %d %d %d", &n, &x, &y, &z);
	int st = (1 << (z - 1)) | (1 << (z + y - 1)) | (1 << (z + y + x - 1));
	int lim = (1 << (x + y + z)) - 1;
	f[0][0] = 1;
	rep(i, 1, n) {
		rep(s, 0, lim) {
			if ((s & st) != st && f[i - 1][s])
			rep(c, 1, 10) {
				f[i][lim & ((s << c) | (1 << c - 1))] = (f[i][lim & ((s << c) | (1 << c - 1))] + f[i - 1][s]) % HA;
			}
		}
	}
	ll ans  = 0;
	rep(i, 0, lim) if ((i & st) != st) ans = (ans + f[n][i]) % HA;
	ll tmp = 1;
	rep(i, 1, n) tmp = tmp * 10 % HA;
	ans = (tmp - ans + HA) % HA;
	printf("%lld\n", ans);
	return 0;
}

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

set<int>s;
int main(void)
{
    int n;
    cin>>n;
    int temp;
    for(int i=1;i<=n;i++)
    {
        cin>>temp;
        if(s.count(temp)==0)
        {
            s.insert(temp);
        }
        else
        {
            s.erase(temp);
        }
    }
    cout <<s.size()<<endl;
    return 0;
}


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

int main(){
    int  n;

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

    int count = 0;
    for(int i = 1;i < n-1;++i){
        if(A[i-1] < A[i] && A[i] < A[i+1] || A[i-1] > A[i] && A[i] > A[i+1]){
            count++;

        }
    }
    cout << count <<endl;

}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int num,i,j,k,big=-1,avg,max,total=0,count[50];
    scanf("%d",&max);
    for(i=0;i<max;i++)
    {
        scanf("%d",&count[i]);
    }
    for(i=1;i<max-1;i++)
    {
        if(count[i]>count[i-1] && count[i]<count[i+1])
        {
            total++;
        }
        else if(count[i]<count[i-1] && count[i]>count[i+1])
        {
            total++;
        }
    }
    printf("%d",total);
    return 0;
}


Measured memory_bytes: 1728
#include <string> 
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include <numeric>
#include<cmath>
 
using namespace std;

int main(){
    string s;
    cin >> s;
    //while(s.size%3!=0){
    //    s = "0"+s;
    //}
    //cout << s;
    char q = '?';
    long long res_new[] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    long long res_old[] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    long long answer=0;
    int mul[] = {1,10,9,12,3,4};
    for(int i=0;i<13;i++){
        res_new[i]=0;
        res_old[i]=0;
    }
    if(s[s.size()-1]!=q){
        res_old[int(s[s.size()-1]-'0')]=1;
      //cout << int(s[s.size()-1]-'0');
    }else{
        for(int j=0;j<10;j++){
        res_old[j]=1;
        //res_old[i]=0;
    }
    }
    for(long long i=1;i<s.size();i++){
        for(int j=0;j<13;j++){
        res_new[j]=0;
        //res_old[i]=0;
    }
            if(s[s.size()-1-i]!=q){
                int x = (int(s[s.size()-1-i]-'0')*mul[i%6])%13;
                for(int j=0;j<13;j++){
                    res_new[(j+x)%13] = res_old[j];
                }
            }else{
                for(int j=0;j<10;j++){
                    int y = (j*mul[i%6])%13;
                    for(int k=0;k<13;k++){
                        res_new[(k+y)%13] += res_old[k];
                    }

                }

            }
            for(int i=0;i<13;i++){
        res_old[i] =res_new[i]%1000000007;
        //cout << res_old[i] ;
    }
      //cout << endl;

    }
    cout << (res_old[5]%1000000007) << endl;
}

Measured memory_bytes: 512
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

void myadd(vector<vector<int>> &vec, queue<pair<int, int>> &q, int x, int y) {
	if (vec[x][y] != -2) {
		if (vec[x][y] < vec[x + 1][y] || vec[x + 1][y] == -1) {
			vec[x + 1][y] = vec[x][y];
			q.push(make_pair(x + 1, y));
		}
		if (vec[x][y] < vec[x - 1][y] || vec[x - 1][y] == -1) {
			vec[x - 1][y] = vec[x][y];
			q.push(make_pair(x - 1, y));
		}
		if (vec[x][y] < vec[x][y + 1] || vec[x][y + 1] == -1) {
			vec[x][y + 1] = vec[x][y];
			q.push(make_pair(x, y + 1));
		}
		if (vec[x][y] < vec[x][y - 1] || vec[x][y - 1] == -1) {
			vec[x][y - 1] = vec[x][y];
			q.push(make_pair(x, y - 1));
		}
		for (int i = -2; i < 3; ++i) {
			for (int j = -2; j < 3; ++j) {
				if (vec[x][y] + 1 < vec[x + i][y + j] || vec[x + i][y + j] == -1) {
					vec[x + i][y + j] = vec[x][y] + 1;
					q.push(make_pair(x + i, y + j));
				}
			}
		}
		
	}
}

int main() {
	int H, W;
	int Ch, Cw;
	int Dh, Dw;
	cin >> H >> W;
	cin >> Ch >> Cw;
	cin >> Dh >> Dw;

	Ch += 3;
	Cw += 3;
	Dh += 3;
	Dw += 3;

	int offset = 4;

	vector<vector<int>> vec(H + 10, vector<int>(W + 10, -2));
	map<char, int> mp;
	mp['.'] = -1;
	mp['#'] = -2;
	for (int i = offset; i < H + offset; ++i) {
		for (int j = offset; j < W + offset; ++j) {
			char c;
			cin >> c;
			vec[i][j] = mp[c];
		}
	}

	queue<pair<int, int>> que;
	vec[Ch][Cw] = 0;
	myadd(vec, que, Ch, Cw);

	while (que.empty() != 1) {
		auto a = que.front();
		que.pop();
		myadd(vec, que, a.first, a.second);
	}

	/*
	for (int i = offset; i < H + offset; ++i) {
		for (int j = offset; j < W + offset; ++j) {
			cout << vec[i][j] << "\t";
		}
		cout << endl;
	}
	*/
	cout << vec[Dh][Dw] << endl;;
	return 0;
}

Measured memory_bytes: 7712
N,M = map(int,input().split())
li = [list(map(int,input().split()))+[i+1] for i in range(M)] +[[N+1]] #順番タグ付け
ans = [0]*M
li.sort()
index = cnt = 0
for i in range(1,M+1):
    if li[i-1][0]!=li[i][0]:
        tmp = li[index:i]
        tmp.sort(key=lambda x: x[1])
        index = i
        for j in range(len(tmp)):
            ans[cnt] = [str(tmp[j][0]).zfill(6)+str(j+1).zfill(6),tmp[j][2]]
            cnt+=1
#print(ans)
ans.sort(key=lambda x: x[1])
#print(ans)
for i in range(M):
    print(ans[i][0])

Measured memory_bytes: 42060
#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++)
#define INF 1000000007
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(){
  long double a,b;
  cin >> a >> b;
  cout << fixed <<setprecision(0) << floor(a * b) << endl;
  return 0;
}


Measured memory_bytes: 3764
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class Data
{
public:
    int id;
    int solve;
    int penalty;
    vector<int> wrong;
    Data(int id, int problemNum){
        this->id = id;
        solve = 0;
        penalty = 0;
        wrong.assign(problemNum, 0);
    }
    bool operator<(const Data& d) const{
        return make_pair(-solve, make_pair(penalty, -id)) < make_pair(-d.solve, make_pair(d.penalty, -d.id));
    }
};

int main()
{
    for(;;){
        int endTime, n, problemNum, query;
        cin >> endTime >> n >> problemNum >> query;
        if(endTime == 0)
            return 0;

        vector<Data> d;
        for(int i=0; i<n; ++i)
            d.push_back(Data(i+1, problemNum));

        while(--query >= 0){
            int time, team, problem, judge;
            cin >> time >> team >> problem >> judge;
            -- team;
            -- problem;

            if(judge == 0){
                ++ d[team].solve;
                d[team].penalty += time + d[team].wrong[problem] * 20;
            }
            else{
                ++ d[team].wrong[problem];
            }
        }

        sort(d.begin(), d.end());
        cout << d[0].id;
        for(int i=1; i<n; ++i){
            if(d[i].solve == d[i-1].solve && d[i].penalty == d[i-1].penalty)
                cout << '=';
            else
                cout << ',';
            cout << d[i].id;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1236
#include <stdio.h>
int m, n, a[100];
bool check(int x) {
    int pos = 0, r = 0;
    for(int i = 0; i < m; i++) {
        while(pos != n && r + a[pos] <= x) r += a[pos++];
        if(pos == n) return true; r = 0;
    }
    return false;
}
int main() {
    while(scanf("%d%d", &m, &n), n) {
        for(int i = 0; i < n; i++) scanf("%d", &a[i]);
        int l = 0, r = 1000000000;
        while(r - l > 1) {
            int m = (l + r) / 2;
            if(check(m)) r = m;
            else l = m;
        }
        printf("%d\n", r);
    }
}

Measured memory_bytes: 2572
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


h, w = li()
grid = [lc() for _ in range(h)]


lr = [[0]*w for _ in range(h)]
tb = [[0]*w for _ in range(h)]

for row in range(h):
    for col in range(w):
        if col == 0:
            lr[row][col] = 1 if grid[row][col] == "." else 0

        else:
            if grid[row][col] == "#":
                continue

            else:
                lr[row][col] = lr[row][col-1] + 1

for row in range(h):
    for col in range(w-2, -1, -1):
        if lr[row][col] == 0:
            continue
        else:
            lr[row][col] = max(lr[row][col+1], lr[row][col])

for col in range(w):
    for row in range(h):
        if row == 0:
            tb[row][col] = 1 if grid[row][col] == "." else 0

        else:
            if grid[row][col] == "#":
                continue
            else:
                tb[row][col] = tb[row-1][col] + 1

for col in range(w):
    for row in range(h-2, -1, -1):
        if tb[row][col] == 0:
            continue
        else:
            tb[row][col] = max(tb[row+1][col], tb[row][col])

ans = 0
for row in range(h):
    for col in range(w):
        ans = max(ans, lr[row][col] + tb[row][col])

print(max(0, ans-1))

Measured memory_bytes: 246408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
char str[100009];
int a[100009][2];//0为偶，1为奇
int cnt[100009];
int main()
{
    scanf("%s",str+1);
    int len=strlen(str+1);
    int cntt=0;
    for(int i=2;i<=len;i++)
    {
        cntt++;
        if(str[i]=='L')
        {
          //  cout<<cntt<<" "<<i<<endl;
            a[1][cntt%2]=i;
            a[1][(cntt+1)%2]=i-1;
            break;
        }
    }
    for(int i=2;i<=len;i++)
    {
        if(str[i]=='R'&&str[i-1]=='R')
        {
            a[i][0]=a[i-1][1];
            a[i][1]=a[i-1][0];
        }
        else if(str[i]=='L'&&str[i-1]=='L')
        {
            a[i][0]=a[i-1][1];
            a[i][1]=a[i-1][0];
        }
        else if(str[i]=='R'&&str[i-1]=='L')
        {
            cntt=0;
            for(int j=i+1;j<=len;j++)
            {
                cntt++;
                if(str[j]=='L')
                {
                    a[i][cntt%2]=j;
                    a[i][(cntt+1)%2]=j-1;
                    break;
                }
            }
        }
        else if(str[i]=='L'&&str[i-1]=='R')
        {
            a[i][0]=i;
            a[i][1]=i-1;
        }
    }
    for(int i=1;i<=len;i++)
    {
  //      cout<<a[i][0]<<endl;
        cnt[a[i][0]]++;
    }
    for(int i=1;i<len;i++)
        cout<<cnt[i]<<" ";
    cout<<cnt[len]<<endl;
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>

#define rep(i,m,n) for(int i=(m);i<(n);++i)
#define rem(i,m,n) for(int i=(m);i>(n);--i)
#define MOD 1000000007

using namespace std;

using ll = long long int;
using std::swap;

vector<long long int> v;
vector<long long int> w;

int main() {
	vector <string> S;
	int n,ans = 0;
	string st;

	cin >> n;
	S.resize(n);
	rep(i, 0, n) {
		cin >> S[i];
	}
	sort(S.begin(), S.end());
	rep(i, 0, n-1) {
		if (S[i] == S[i + 1])++ans;
	}
	cout << S.size() - ans << '\n';

	return 0;
}

Measured memory_bytes: 9588
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int W = Integer.parseInt(sc.next());
        int H = Integer.parseInt(sc.next());
        int N = Integer.parseInt(sc.next());
        
        int[][] rect = new int[H][W];
        
        for(int n=0; n<N; n++){
            int x = Integer.parseInt(sc.next());
            int y = Integer.parseInt(sc.next());
            int a = Integer.parseInt(sc.next());
            
            if(a == 1){
                for(int i=0; i<H; i++){
                    for(int j=0; j<x; j++){
                        rect[i][j] = 1;
                    }
                }
            }
            if(a == 2){
                for(int i=0; i<H; i++){
                    for(int j=x; j<W; j++){
                        rect[i][j] = 1;
                    }
                }
            }
            if(a == 3){
                for(int i=0; i<y; i++){
                    for(int j=0; j<W; j++){
                        rect[i][j] = 1;
                    }
                }
            }
            if(a == 4){
                for(int i=y; i<H; i++){
                    for(int j=0; j<W; j++){
                        rect[i][j] = 1;
                    }
                }
            }
        }
        
        int ans = 0;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(rect[i][j] == 0){
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23044
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>

using namespace std;


int main() {
    string s; cin >> s;
    
    int cnt1(0),cnt2(0);
    
    for(int i=0; i < s.size();i++){
        if(i%2==0){
            if(s[i]=='0') cnt1++;
        }
        else{
            if(s[i]=='1') cnt1++;
        }
    }
    for(int i=0; i < s.size();i++){
        if(i%2==0){
            if(s[i]=='1') cnt2++;
        }
        else{
            if(s[i]=='0') cnt2++;
        }
    }
    cout<<min(cnt1,cnt2)<<endl;
}
    


Measured memory_bytes: 512
/*      Abhijith    */
#include<bits/stdc++.h>
#include<iomanip>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
using namespace std;
void gcd_extended(lld a,lld b,lld *x,lld *y)
{
    if(a==0)
    {
        *x=0;
        *y=1;
        return;
    }
    lld x1,y1;
    gcd_extended(b%a,a,&x1,&y1);
    *x=y1-(b/a)*x1;
    *y=x1;
    return;
}
lld ncr(lld n,lld k)
{
    if (k > n) return 0LL;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result = (result*(n-i+1))%mod;
    }
    for(int i=2;i<=k;i++)
    {
        lld x,y;
        gcd_extended(mod,i,&x,&y);
        y=(y%mod+mod)%mod;
        result=(result*y)%mod;
    }
    return result;
}
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);

     lld n,m,k;
     lld inv=500000004;
     cin>>n>>m>>k;
     vector<lld> vsum(n),vssum(n,0),hsum(m,0),hssum(m,0);
     vsum[0]=0;
     rep(i,1,n-1)
     {
         vsum[i]=(vsum[i-1]+1)%mod;
         vssum[i]=(vssum[i-1]+vsum[i])%mod;
     }

     hsum[0]=0;
     rep(i,1,m-1)
     {
         hsum[i]=(hsum[i-1]+1)%mod;
         hssum[i]=(hssum[i-1]+hsum[i])%mod;
     }
     lld haha=0;
     lld vava=0;
     rep(i,0,n-1)
     {
         vava=(vava+(vssum[i]+vssum[n-1-i]))%mod;
     }
     rep(i,0,m-1)
     {
         haha=(haha+(hssum[i]+hssum[m-1-i]))%mod;
     }
     lld yo=((n*(n))*haha+(m*(m))*vava)%mod;
     //cout<<haha<<" "<<vava<<" "<<yo<<endl;
     yo=(yo*inv)%mod;
     lld ans=(ncr(n*m-2,k-2)*yo)%mod;
     cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;

public class Main {
	
    public static void main(String args[] ) throws Exception {
    	Scanner s = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] input;
		int X = s.nextInt(), Y = s.nextInt();
		if(Y % 2 == 1) {
			out.print("No");
		} else {
			Y /= 2;
			int b = (Y - X), a = X - b;
			if(b < 0 || a < 0) {
				out.print("No");
			} else {
				out.print("Yes");
			}
		}
		out.flush();

    }
	

}


Measured memory_bytes: 35908