akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstdlib>
#include<algorithm>
#include<map>
using namespace std;
char s[510][510];
int dp[510][510];
int gcd(int a,int b) {
    return a%b?gcd(b,a%b):b;
}
int f[1010];
int main(){
    int n,m;
    int t,k;
    char x[10];
    while (scanf("%d %d",&n,&k)!=EOF) {
        int sum = 0;
        for (int i=0;i<n;i++)
            scanf("%d",&f[i]);
        sort(f,f+n);
        for (int i=0;i<k;i++)
            sum+=f[i];
        printf("%d\n",sum);

    }

    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int b[105];
int main(){
	int n;
	cin >> n;
	int sum = 0;
	for(int i = 1;i < n;i++){
		cin >> b[i];
	}
	b[n] = b[n-1];
	int cnt = b[1];
	for(int i = 1;i < n;i++){
		cnt += min(b[i],b[i+1]);
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	while(true){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0) break;
		if(a > b) printf("%d %d\n",b,a);
		else{
			printf("%d %d\n",a,b);
		}
	}
}



Measured memory_bytes: 2716
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;



int main(){
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int n , m;
    cin >> n >> m;
    vector<int> a(n);
    for(int &x : a)
        cin >> x;
    sort(all(a));

    vector<pair<int , int> > op(m);
    for(auto &x : op){
        cin >> x.second >> x.first;
    }

    sort(all(op) , greater<pair<int , int>>());

    int j = 0;
    for(int i = 0 ; i < m ; ++i){
        int sz = op[i].second;
        while(sz-- && j < n && a[j] < op[i].first){
            a[j] = op[i].first;
            ++j;
        }
    }

    long long ans = 0;
    for(int x : a)
        ans += x;

    cout << ans << endl;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define pb push_back
#define mp make_pair

int main() {
	
	int N,M;
	cin >> N >> M;
	int n = 1 << N;
	int dp[1 << 12];
	rep(i, n) dp[i] = 1e9;
	dp[0] = 0;

	rep(i, M) {
		int A,b;
		cin >> A >> b;
		int C = 0;
		rep(j, b) {
			int c;
			cin >> c;
			C += 1 << (c - 1);
		}
		for (int j = 0; j <= n-1; j++) {
					
			int k = j | C;
					
			dp[k] = min(dp[k], dp[j] + A);
			
		}
	}

	if (dp[(1 << N) - 1] >= 1e9) printf("-1");
	else printf("%d", dp[(1 << N) - 1]);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
long long mmin(long long &a,long long b) {
	a = min(a, b);
	return a;
}
long long mmax(long long &a,long long b) {
	a = max(a, b);
	return a;
}
int nibu(vector<int> &v, int tan) {
	int up = v.size()-1;
	int lo = 0;
	if (tan <= v[0]) {
		return 0;
	}
	while (up - lo > 1) {
		int mi = (up + lo) / 2;
		if (tan <= v[mi]) {
			up = mi;
		}
		if (v[mi] < tan) {
			lo = mi;
		}
	}
	return up;
}
int main() {
	string he = "JOI";
	int n; cin >> n;
	string s; cin >> s;
	vector<int> ss(n);
	for (int i = 0; i < n; i++) {
		for (int k = 0; k < 3; k++) {
			if (s[i] == he[k]) {
				ss[i] = k;
			}
		}
	}
	vector<long long> j(n,0);
	vector<long long> jo(n,0);
	vector<long long> joi(n,0);
	if (ss[0] == 0) {
		j[0] = 1;
	}
	for (int i = 1; i < n; i++) {
		j[i] = j[i - 1];
		jo[i] = jo[i - 1];
		joi[i] = joi[i - 1];
		int x = ss[i];
		if (x == 0) {
			j[i]++;
		}
		else if(x==1){
			jo[i] += j[i - 1];
		}
		else {
			joi[i] += jo[i - 1];
		}
	}
	vector<long long> oi(n,0);
	vector<long long> si(n,0);
	if (ss[n - 1] == 2) {
		si[n - 1] = 1;
	}
	for (int i = n - 2; i >= 0; i--) {
		oi[i] = oi[i + 1];
		si[i] = si[i + 1];
		int x = ss[i];
		if (x == 2) {
			si[i]++;
		}
		else if (x == 1) {
			oi[i] += si[i + 1];
		}
	}
	long long mo = joi[n - 1];
	long long ch = 0;
	for (int i = 0; i + 1 < n - 1; i++) {
		mmax(ch, j[i] * si[i + 1]);
	}
	long long ans = mo+max(ch, max(jo[n - 1], oi[0]));
	cout << ans << endl;
}


Measured memory_bytes: 7452
#include<bits/stdc++.h>
#define ll long long int
#define N (ll)(1e9+7)
#define T int
#define P pair<T,T>
#define umap unordered_map<T,T>
#define uset unordered_set<T>
#define rep(i,n) for(i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define print(v) for(auto x:v) cout<<x<< " "
#define pb push_back
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)
        cout<<"bust"<<endl;
    else
        cout<<"win"<<endl;


    return 0;
}



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

const int MAXN = 1e5;
struct edge{int to,color,length;};
vector<vector<edge>> to(MAXN);
vector<vector<ll>> to2(MAXN);
vector<int> G[MAXN];
// 前処理 O(VlogV) クエリ処理 O(logV)
struct LCA{
	vector<vector<ll>> toTree;
	vector<ll> d;
	ll LOGV;
	vector<vector<ll>> par;

	// "to" must be tree
	LCA(vector<vector<ll>> to){
		this->toTree = to;
		this->d = vector<ll>(to.size(),-1);
		this->LOGV = log2l(to.size()) + 1;
		this->par = vector<vector<ll>>(LOGV, vector<ll>(to.size(),-1)); // 遡った結果rootを通り過ぎたら-1
		makeDepth(); 
		makePar();
	}

	void makeDepth(){
		queue<ll> q;
		q.push(0);
		d[0] = 0;
		while(!q.empty()){
			ll now = q.front();
			q.pop();
			for(ll child : toTree[now]){
				if(d[child] != -1) continue;
				d[child] = d[now] + 1;
				par[0][child] = now;
				q.push(child);
			}
		}
	}

	void makePar(){
		rep(i,LOGV-1) rep(j,par[0].size()){
			// par[i][j]: jから2^i上に遡った頂点
			if(par[i][j] >= 0) par[i+1][j] = par[i][par[i][j]];
		}
	}

	// return LCA of u and v
	ll get(ll u, ll v){
		if(max(u,v) >= toTree.size()){
			printf("LCA error: too large num of vartex. u=%ll, v=%ll \n", u, v);
			return -1;
		}

		// 深い方の頂点を浅い方の深さに合わせる
		if(d[u] > d[v]) swap(u,v);
		rep(i,LOGV){
			if((d[v] - d[u]) & (1ll<<i)) v = par[i][v];
		}
		if(u==v) return u;

		// LCAが見つかるまで二分探索で上に遡る
		for(ll i = LOGV-1; i >= 0; i--){
			if(par[i][u] != par[i][v]){
				u = par[i][u];
				v = par[i][v];
			}
		}

		return par[0][u];
	}
};

vector<int> dist(MAXN); // 頂点iへの距離
vector<vector<int>> needcol(MAXN); // 頂点iに必要な色
vector<int> colcnt(MAXN); // 現在通った辺のうち色iの総和
vector<int> colsum(MAXN); // 現在通った辺のうち色iの総和
vector<map<int,int>> cnt(MAXN), sum(MAXN);
void dfs2(int v, int p){
	
	// 現在の総和を（必要がある場合だけ）memo
	for(auto col : needcol[v]){
		cnt[v][col] = colcnt[col];
		sum[v][col] = colsum[col];
	}
	
	for(auto e : to[v]){
		if(e.to == p) continue;
		dist[e.to] = dist[v] + e.length;
		
		// 進んだ分足す
		colcnt[e.color]++;
		colsum[e.color] += e.length;
		
		dfs2(e.to,v);
		
		// 戻るので引く
		colcnt[e.color]--;
		colsum[e.color] -= e.length;
	}
	return;
}

int main(){
	
	int n,q;
	cin >> n >> q;
	
	rep(i,n-1){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		--a; --b; --c;
		to[a].push_back(edge{b,c,d});
		to[b].push_back(edge{a,c,d});
		G[a].push_back(b);
		G[b].push_back(a);
		to2[a].push_back(b);
		to2[b].push_back(a);
	}
	
	LCA lca(to2);
	
	vector<vector<int>> queries(q,vector<int>(5));
	rep(i,q){
		int x,y,u,v;
		cin >> x >> y >> u >> v;
		--x; --u; --v;
		
		int lcauv = lca.get(u,v);
		needcol[u].push_back(x);
		needcol[v].push_back(x);
		needcol[lcauv].push_back(x);
		queries[i] = {x,y,u,v,lcauv};
	}

	dfs2(0,-1);
	
	
	rep(i,q){
		int x,y,u,v,lcauv;
		x = queries[i][0];
		y = queries[i][1];
		u = queries[i][2];
		v = queries[i][3];
		lcauv = queries[i][4];
		
		int nowd = dist[u] + dist[v] - 2*dist[lcauv];
		int nowsum = sum[u][x] + sum[v][x] - 2*sum[lcauv][x];
		int nowcnt = cnt[u][x] + cnt[v][x] - 2*cnt[lcauv][x];
		cout << nowd - nowsum + nowcnt*y << endl;
	}
	return 0;
}


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

// マクロ //
#define rep(i,N) for(int i = 0; i < (int)(N); i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)
#define db(i) cout << #i << " = " << i;

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

template<class T, class Q> inline bool chmin(T& a, Q b) {
    if (a > b) { 
        a = b;
        return true; 
    }
    return false;
}

template<class T, class Q> inline bool chmax(T& a, Q b) {
    if (a < b) { 
        a = b; 
        return true; 
    }
    return false;
}

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int MOD = 998244353;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);


// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
        
    int N;
    cin >> N;

    for (int i = -500; i < 500; i++) {
        for (int j = -500; j < 500; j++) {
            if (pow(i, 5) - pow(j, 5) == N) {
                cou(i << " " << j);
                goto end;
            }
        }
    }
end: {}{{; }}

}

Measured memory_bytes: 4068
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

vector<vector<int>> g;
vector<int> ans;

int main(){
  int a,b,t; cin >> a >> b >> t;
  int s = t / a;
  int ans = s * b;
  cout << ans << 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;

int main(){
  int n;
  cin >> n;
  int sum=0;
  char s[n];
  rep(i,n){
    cin >> s[i];
    if(s[i] != s[i-1])sum ++;
  }
  cout << sum;
}

Measured memory_bytes: 384
#116c 尺取り法?
N = int(input()) #N <= 10**5
h_list = list(map(int, input().split()))
x_list = [0 for _ in range(N)]

ans = 0

for i in range(N):
    while h_list[i] != x_list[i]:
        #print(x_list)
        for j in range(i,N):
            if h_list[j] == x_list[j]:
                break
            else:
                x_list[j] += 1
                
        ans += 1

#print(x_list)
print(ans)

Measured memory_bytes: 3060
n = int(input())
p = [int(x) for x in input().split()]
ans = 0

def second_smallest(numbers):
    m1, m2 = float('inf'), float('inf')
    for x in numbers:
        if x <= m1:
            m1, m2 = x, m1
        elif x < m2:
            m2 = x
    return m2

for i in range(n-1):
  if i != 0:
    a = p[i-1:i+2]
    if a[0] != a[1] and a[1] != a[2] and a[0] != a[2]:
      if p[i] == second_smallest(a):
        ans += 1
print(ans)


Measured memory_bytes: 3064
let rec f a b c k = 
if k = 0 then a+b+c
else if max (max a b) c = a then f (a*2) b c (k-1)
else if max (max a b) c = b then f a (b*2) c (k-1)
else f a b (c*2) (k-1)
let () =
let a, b, c = Scanf.scanf "%d %d %d\n" (fun a b c -> a, b, c) in
let k = Scanf.scanf "%d\n" (fun x -> x) in
Printf.printf "%d\n" (f a b c k)

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func isPalindromic(a int) bool {
	var digits []int
	for a != 0 {
		digits = append(digits, a%10)
		a /= 10
	}

	for i, j := 0, len(digits)-1; i < j; i, j = i+1, j-1 {
		if digits[i] != digits[j] {
			return false
		}
	}

	return true
}

func main() {
	a, b := nextInt(), nextInt()

	c := 0
	for i := a; i <= b; i++ {
		if isPalindromic(i) {
			c++
		}
	}

	fmt.Println(c)
}


Measured memory_bytes: 5504
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a[3];
	for(int i=0;i<3;i++) cin >> a[i];
	sort(a, a+3);
	if(a[0]+a[1]==a[2]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
A, B, C, D, E, F = map(int, input().split())

INF = 100
ans = 0
ans2 = [100 * A, 0]
for i in range(INF):
    if A * 100 * i > F:
        break

    for j in range(INF):
        if A * 100 * i + B * 100 * j > F:
            break

        for k in range(INF):
            if A * 100 * i + B * 100 * j + C * k > F:
                break

            for l in range(INF):
                if A * 100 * i + B * 100 * j + C * k + D * l > F:
                    break

                if i == 0 and j == 0 and k == 0 and l == 0:
                    continue
                tmp = (C * k + D * l) / (A * 100 * i + B * 100 * j + C * k + D * l) 
                if tmp <= E / (E + 100) and tmp > ans:
                    ans = tmp
                    ans2[0] = A * 100 * i + B * 100 * j + C * k + D * l
                    ans2[1] = C * k + D * l
print("%d %d" % (ans2[0], ans2[1]))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
        int N, M, k, ss;
        cin >> N >> M;
        vector<vector<int>> s(10, vector<int>());
        vector<int> p(M);
        vector<int> sw(N);
        for (int i=0; i<M; i++) {
                cin >>k;
                for (int j=0; j<k; j++) {
                        cin >> ss;
                        s.at(i).push_back(ss);
                }
        }
        for (int i=0; i<M; i++) {
                cin >>p.at(i);
        }
        int sss=0;
        int a;
        for (int i=0; i<pow(2, N); i++) {
                int ii=i;
                for (int j=0; j<N; j++) {
                        sw.at(j)=ii%2;
                        ii /=2;
                }
                a=1;
                for (int j=0; j<M; j++) {
                        int jjj=0;
                        for (int k=0; k<s.at(j).size(); k++) {
                                if (sw.at(s.at(j).at(k)-1)==1) jjj++;
                        }
                        if (jjj % 2 == p.at(j)) a *= 1;
                        else a=0;
                }
                if (a==1) sss++;
        }
        cout <<sss <<endl;
        return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define llin(a) cin >> a
#define llpr(a) cout << a << " "
#define llout(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define M 1000000007
#define N 100005  //check the limits, man
// read the constraint properly (ll vs int)
typedef long long int ll;
int main()
{
    ll k;
    int i,j,f,n,m;
    string str;
    llin(str);
    llin(k);
    n=str.size();
    f=1;
    rep(i,n)
        if(str[i]!=str[0])f=0;
    ll ans;
    if(f)
    {
        ans=n,ans*=k,ans/=2;
        llout(ans);
    }
    else
    {
        vi v;
        i=0;
        while(i<n)
        {
            j=i;
            while(j<n && str[j]==str[i])
                j++;
            v.pb(j-i);
            i=j;
        }
        ll temp;
        m=v.size();
        ans=0;
        rep(i,m)
            temp=v[i],temp/=2,temp*=k,ans+=temp;
        if(str[0]==str[n-1])
        {
            temp=(v[0]/2)+(v[m-1]/2);
            temp*=(k-1);
            ans-=temp;
            temp=(v[0]+v[m-1])/2;
            temp*=(k-1);
            ans+=temp;
        }
        llout(ans);
    }
}


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

using ll = long long;

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	vector<int> pos(n);
	for(int i = 0; i < n; i++){
		pos[a[i]-1] = i;
	}

	set<int> idx;
	idx.insert(-1); idx.insert(n);
	ll ans = 0;
	for(int i = 0; i < n; i++){
		idx.insert(pos[i]);
		int a = *prev(idx.find(pos[i]));
		int b = *next(idx.find(pos[i]));
		ans += 1ll * (i+1) * (pos[i] - a) * (b - pos[i]);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define what_is(x) cerr << #x <<" is " << x << endl;
typedef long long ll;
const int MOD = 998244353;
const double PI = 3.14159265358979;
const int INF =  1e9 + 7;
const int nax = 100005;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tc = 1;
	// cin >> tc;
	while (tc--) {
		int n, m, x, y;
		cin >> n >> m;
		vector<int> adj[n + 10];
		for (int i = 1; i <= m; i++) {
			cin >> x >> y;
			adj[x].emplace_back(y);
			adj[y].emplace_back(x);
		}
		cout << "Yes" << endl;
		vector<int> par(n + 10, -1);
		vector<int> vis(n + 10, 0);
		queue<int> q;
		q.push(1); vis[1] = 1;
		while (!q.empty()) {
			int u = q.front();
			q.pop();
			for (int v : adj[u]) {
				if (!vis[v]) {
					vis[v] = 1;
					par[v] = u;
					q.push(v);
				}
			}
		}
		for (int i = 2; i <= n; i++) {
			cout << par[i] << endl;
		}
	}
	return 0;
}




















Measured memory_bytes: 10780
#include <stdio.h>

int main(void) {
	int i,j,n,num;
	int card[4][13]={{0,0,0,0,0,0,0,0,0,0,0,0,0},
	                 {0,0,0,0,0,0,0,0,0,0,0,0,0},
	                 {0,0,0,0,0,0,0,0,0,0,0,0,0},
	                 {0,0,0,0,0,0,0,0,0,0,0,0,0}};
	char mark;
	
	scanf("%d",&n);
	for(i=0;i<n*2;i++){
	    scanf("%c %d",&mark,&num);
	    if(mark=='S') card[0][num-1]=1;
	    else if(mark=='H') card[1][num-1]=1;
	    else if(mark=='C') card[2][num-1]=1;
	    else if(mark=='D') card[3][num-1]=1;
	}
	
	for(i=0;i<4;i++) {
	    for(j=0;j<13;j++){
	        if(card[i][j]==0){
	            if(i==0) printf("S ");
	            else if(i==1) printf("H ");
	            else if(i==2) printf("C ");
	            else if(i==3) printf("D ");
                printf("%d\n",j+1);
	        }
	    }
	}
        return 0;
}



Measured memory_bytes: 2044
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <stack>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;

const int MaxN = 2e5;
int n, m;
vector <int> a[MaxN + 5];
bool vis[MaxN + 5];

int main()
{
	while(~scanf("%d%d", &n, &m)) {
		for(int i = 1; i <= n; i++) a[i].clear();
		for(int i = 1; i <= m; i++) {
			int u, v;
			scanf("%d%d", &u, &v);
			a[u].push_back(v);
			a[v].push_back(u);
		}
		memset(vis, 0, sizeof(vis));
		for(int i = 0; i < a[1].size(); i++) vis[a[1][i]] = 1;
		bool ok = 0;
		for(int i = 0; i < a[n].size(); i++)
			if(vis[a[n][i]]) ok = 1;
		if(ok) printf("POSSIBLE\n");
		else printf("IMPOSSIBLE\n");
	}
}

Measured memory_bytes: 12144
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 long long int i,n,s;
 s=0;
 cin >> n;
 int a[n];
 map<long long int,long long int> m,x;
 for(i=0;i<n;i++)
 {
  cin >> a[i];
  m[a[i]]++;
 }
 for(auto itr=m.begin();itr!=m.end();itr++)
 {
  x[itr->first]=((itr->second-1)*(itr->second-2))/2;
  m[itr->first]=(itr->second*(itr->second-1))/2;
  s+=m[itr->first];
 }
 //cout << s;
 for(i=0;i<n;i++)
 cout << s-m[a[i]]+x[a[i]] << "\n";
 return 0;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, j, n) for (int i = (j); i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

signed main() {
  int n, l;
  cin >> n >> l;
  int ret = (l + (l + n - 1)) * n / 2;
  if (l * (l + n - 1) > 0) {
    if (l > 0)
      ret -= l;
    else
      ret -= l + n - 1;
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
# A 
s = input()

for i in range(0, len(s), 2):
    if len(s)%2 == 1:
        bool = False
        break
    elif s[i] == 'h' and s[i+1] == 'i':
        bool = True
    else:
        bool = False
        break
        
print('Yes' if bool else 'No')

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

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

	if (a == 0) a = w;
	if (b == 0) b = h;

    int t = 0;
    int p = 0;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            if(j >= t && j < t+ a && i >= p && i < p+b){
                cout << 1;
            }else{
                cout << 0;
            }
        }
        cout << "\n";
        if(i == b-1){
            t += a;
            p += b;
			a = w;
			b = h;
        }
    }

    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mn=1e6+10;

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    printf("%lld",b-a+1+((a-1)/c+(a-1)/d-(a-1)/(c*d/__gcd(c,d)))-(b/c+b/d-b/(c*d/__gcd(c,d))));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
// #define int long long    // %d=>%lld
#define pb push_back
#define INF 100000000
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;

const int MAX_n = 100;
int n,a;
bool f[9];



signed main(){

    scanf("%d", &n);

    int num_8=0;
    for(int i = 0;i < n;i++){
        scanf("%d", &a);
        if(a<400){
            f[0]=1;
        }else if(a<800){
            f[1]=1;
        }else if(a<1200){
            f[2]=1;
        }else if(a<1600){
            f[3]=1;
        }else if(a<2000){
            f[4]=1;
        }else if(a<2400){
            f[5]=1;
        }else if(a<2800){
            f[6]=1;
        }else if(a<3200){
            f[7]=1;
        }else if(a>=3200){
            f[8]=1;
            num_8++;
        }
    }

    int ans=0;
    for(int i = 0;i < 8;i++){
        if(f[i] == true) ans++;
    }

    int ama,ami;
    ami=ans;
    ama=ans;

    if(ami == 0){
        ami=1;
    }
    ama+=num_8;

    printf("%d %d\n", ami, ama);

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

string a;
int n;

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

  cin>>n>>a;
  rep(i,a.size()){
    a[i]=((a[i]-'A'+n)%26)+'A';
  }
  cout<<a<<endl;

  return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


int main(){
  ll n;
  cin >> n;
  vector<ll> a(n+1);
  rep(i, n+1) cin >> a[i];
  vector<ll> b(n);
  rep(i, n) cin >> b[i];


  ll sum = 0;
  rep(i, n){
    ll k = min(a[i], b[i]);
    a[i] -= k;
    b[i] -= k;
    sum += k;

    k = min(a[i+1], b[i]);
    a[i+1] -= k;
    b[i] -= k;
    sum += k;
  }

  cout << sum << endl;


  return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
  vector<int> h(n);
  int score = 0;
  int res = 0;
  for(auto &i :h)
  {
    cin >> i;
    if(score < i)
      score = i;
    if(score > i)
    {
      res += score - i;
      score = i;
    }
  }
  res += score;
  cout << res << "\n";
}

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

int main(){
    int a, b; cin >> a >> b;
    if (a + b < 10){
        cout << a + b << endl;
    }
    else{
        cout << "error" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  Long h;cin>>h;
  Long ans = 1;
  while(h){
	  ans*=2;
	  h/=2;
  }
  cout<<ans-1<<endl;

  return 0;
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main(){
    string s;
    cin >> s;
    set<char> v;
    for(char c : s) v.insert(c);
    cout << (v.size() == s.length() ? "yes" : "no") << endl;
}

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

using namespace std;

using ll = long long;

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

    int cnt=0;
    for (int i=0;i<S.length()/2;i++) {
        if (S[i] != S[S.length()-1-i]) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,a[3];
	cin>>n>>a[0]>>a[1]>>a[2];
	vector<char> ans;
	string s[100001];
	for (int i=0;i<n;i++) cin>>s[i];
	for (int i=0;i<n;i++){
		if (!a[s[i][0]-'A'] && !a[s[i][1]-'A']){
			cout<<"No"<<endl;
			return 0;
		}
		else if (a[s[i][0]-'A']>a[s[i][1]-'A']){
			a[s[i][0]-'A']--,a[s[i][1]-'A']++;
			ans.push_back(s[i][1]);
		}
		else if (a[s[i][0]-'A']<a[s[i][1]-'A']){
			a[s[i][0]-'A']++,a[s[i][1]-'A']--;
			ans.push_back(s[i][0]);
		}
		else if (a[s[i][0]-'A']==a[s[i][1]-'A']){
			if (i==n-1 || s[i][0]==s[i+1][0] || s[i][0]==s[i+1][1]){
				a[s[i][0]-'A']++,a[s[i][1]-'A']--;
				ans.push_back(s[i][0]);
			}
			else{
				a[s[i][0]-'A']--,a[s[i][1]-'A']++;
				ans.push_back(s[i][1]);
			}
		}
	}
	cout<<"Yes"<<endl;
	for (int i=0;i<n;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 6888
#include <queue>
#include <cstdio>
#include <vector>
using namespace std;
int H, W, s[30][30], c[4], d[30][30][4];
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
int main() {
	while (~scanf("%d%d", &W, &H)) {
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) scanf("%d", &s[i][j]);
		}
		for (int i = 0; i < 4; i++) scanf("%d", &c[i]);
		for (int i = 0; i < 30; i++) {
			for (int j = 0; j < 30; j++) {
				for (int k = 0; k < 4; k++) d[i][j][k] = 999999999;
			}
		}
		d[0][0][0] = 0;
		priority_queue<vector<int> > que; que.push({ 0, 0, 0, 0 }); // (cost, x, y, dir)
		while (!que.empty()) {
			vector<int> v1 = que.top(); que.pop();
			if (v1[1] + 1 == W && v1[2] + 1 == H) continue;
			for (int i = 0; i < 4; i++) {
				int sx = v1[1] + dx[(v1[3] + i) % 4];
				int sy = v1[2] + dy[(v1[3] + i) % 4];
				if (0 <= sx && sx < W && 0 <= sy && sy < H) {
					int cost = -v1[0] + (s[v1[2]][v1[1]] != i ? c[i] : 0);
					if (cost < d[sy][sx][(v1[3] + i) % 4]) {
						d[sy][sx][(v1[3] + i) % 4] = cost;
						que.push({ -cost, sx, sy, (v1[3] + i) % 4 });
					}
				}
			}
		}
		int ret = 999999999;
		for (int i = 0; i < 4; i++) ret = min(ret, d[H - 1][W - 1][i]);
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 2772
n = int(input())
arr = list(map(int, input().split()))
res = 0
for ii, i in enumerate(arr):
    for jj, j in enumerate(arr):
        for kk, k in enumerate(arr):
            if ii < jj < kk and i != j and j != k and k != i:
                if i + j > k and j + k > i and k + i > j:
                    res += 1
print(res)                    

Measured memory_bytes: 9192
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main{
	public static void main(String[]args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while((str=br.readLine())!=null){
			String[] arr=str.split(" ");
			int a=Integer.parseInt(arr[0]);
			int b=Integer.parseInt(arr[2]);
			String op=arr[1];
			if(op.equals("+")){
				System.out.println(a+b);
			}else if(op.equals("-")){
				System.out.println(a-b);
			}else if(op.equals("*")){
				System.out.println(a*b);
			}else if(op.equals("/")){
				System.out.println(a/b);
			}else{
				break;
			}
		}		
		br.close();
	}
}

Measured memory_bytes: 16924
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
P = LIST()
P.sort()
print(sum(P[:K]))

Measured memory_bytes: 10652
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

#define int ll


const int N = 1e3 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
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; }


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


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll h;
main() {
    file("threesum");
    ios;
    cin >> h;
    int cnt = 1, ans = 0;
    while (h) {
        ans += cnt;
        h >>= 1ll;
        cnt <<= 1ll;
    }
    cout << ans;
    cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
    return 0;
}
/**

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ld, ld> pii;

inline ld dis(pii a, pii b) {
  return sqrt((a.F - b.F) * (a.F - b.F) + (a.S - b.S) * (a.S - b.S));
}

int main() {
  int n; cin >> n;
  vector<pii> v(n);
  for(int i = 0 ; i < n ; ++i) cin >> v[i].F >> v[i].S;
  sort(v.begin(), v.end());
  ld ans = 0;
  int cnt = 0;
  do {
    cnt++;
    for(int i = 0 ; i < n - 1 ; ++i) ans += dis(v[i], v[i + 1]);
  } while(next_permutation(v.begin(), v.end()));
  cout << fixed << setprecision(15) << ans / cnt << '\n';
}


Measured memory_bytes: 256
n=gets.chomp.to_i
s=[]
n.times do
  s.push(gets.chomp)
end
ed_a=0
ft_b=0
ryouhou=0
count=0
for i in 0..n-1 do
  slen=s[i].length
  ft=s[i][0]
  ed=s[i][slen-1]
  if ed=="A" && ft=="B"
    ryouhou+=1
  elsif ed=="A"
    ed_a+=1
  elsif ft=="B"
    ft_b+=1
  end
  for cha in 0..slen-2
    count+=1 if s[i][cha]=="A" && s[i][cha+1]=="B"
  end
end
sa=(ed_a-ft_b).abs
tasu=0
if ryouhou==0
  tasu=ed_a>ft_b ? ft_b : ed_a
else
  if ed_a>0 || ft_b>0
    tasu=ryouhou+(ed_a>ft_b ? ft_b : ed_a)
  else
    tasu=ryouhou-1
  end
end

puts count+tasu


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

int main(){
  int n,i;
  cin >> n;
  vector<ll> a(n);
  cin >> a.at(0);
  ll ans=a.at(0);
  for(i=1;i<n;i++){
    cin >> a.at(i);
    ans=__gcd(ans,a.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3968
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace ConsoleApp
{
    class Program
    {
        
        static void Main(string[] args)
        {
            var a = ReadLine().Split();
            WriteLine(a[1] + a[0]);


        }

       

    }

}


Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
 
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef long double dd;
 
 
 
int main() {
	int K, X;
	cin >> K >> X;
    int num=K*2-1;
    K--;
  if(-1000000<=(X-K)){
    int ans=X-K;
    rep(i,num-1){
      cout <<ans<<' ';
      ans++;
    }
    cout<<ans;
  }
  else{
    int ans=(-1000000);
      rep(i,num-1){
      cout <<ans<<' ';
      ans++;
    }
    cout<<ans;
  }
  
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include<random>
#include<iostream>
#include <iomanip>
using namespace std;

int main() {
    int N;
    int x[8], y[8];
    cin >> N;
    for(int i=0; i<N; i++){
    	cin >> x[i] >> y[i];
    }
    
    double dist[8][8];
    for(int i=0;i<N;i++){
    	for(int j=0;j<N;j++){
    		dist[i][j] = sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
    	}
    }
    
    int num_all = 1;
    for(int i=1;i<N+1;i++){
    	num_all *= i;	
    }
    
    double ans = 0;
    
    for(int i=0;i<num_all;i++){
    	/*順列を得る*/
    	vector <int> v;
    	for(int j=0;j<N;j++){
    		v.push_back(j);
    	}
    	int a[8];
    	int q = num_all;
    	int p = i;
    	for(int j=0;j<N;j++){
    		q = q/(N-j);
    		a[j] = v[p/q];
    		v.erase(v.begin() + p/q);
    		p = p%q;
    	}
    	for(int j=0;j<N-1;j++){
    		ans += dist[a[j]][a[j+1]];
    	}
    }
    ans /= num_all;
    cout << fixed;
    cout << setprecision(10) <<ans << "\n";
    
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a[100],i;
    float x=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
       x=x+(float)1/a[i];
    }
    x=(float)1/x;
    printf("%f",x);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  string s;
  ll k;
  cin >> s >> k;
  vector<int> cnts;
  int cnt = 1;
  char c = s[0];
  int n = s.size();
  rep(i, n - 1) {
    if(c == s[i + 1]) {
      ++cnt;
    } else {
      c = s[i + 1];
      cnts.push_back(cnt);
      cnt = 1;
    }
  }
  cnts.push_back(cnt);

  int m = cnts.size();
  if(m == 1) {
    cout << k * cnts[0] / 2 << endl;
    return 0;
  }

  ll ans = 0;
  rep(i, m) { ans += k * (cnts[i] / 2); }
  if(s[0] == s[n - 1] && cnts[0] % 2 == 1
     && cnts[m - 1] % 2 == 1) {
    ans += k - 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int H = int.Parse(str[0]);
        int W = int.Parse(str[1]);
        bool[,] Map = new bool[H,W];
        for(int i=0;i<H;i++){
            string s = Console.ReadLine();
            for(int j=0;j<W;j++){
                Map[i,j] = s[j] == '#';
            }
        }
        int[,] DPR = new int[H-1,W];
        int[,] DPS = new int[H-1,W];
        for(int i=0;i<H-1;i++){
            for(int j=W-1;j>=0;j--){
                if(j == W-1){
                    if(Map[i,j] == Map[i+1,j]){
                        DPS[i,j] = 1;
                        DPR[i,j] = 0;
                    }
                    else{
                        DPS[i,j] = 0;
                        DPR[i,j] = 1;
                    }
                }
                else{
                    if(Map[i,j] == Map[i+1,j]){
                        DPS[i,j] = 1+DPS[i,j+1];
                        DPR[i,j] = 0;
                    }
                    else{
                        DPS[i,j] = 0;
                        DPR[i,j] = 1+DPR[i,j+1];
                    }
                }
            }
        }
        long count = W;
        for(int i=0;i<W;i++){
            int p = 0;
            int[] stack = new int[H+1];
            int[] point = new int[H+1];
            for(int j=0;j<H-1;j++){
                int h = Math.Max(DPS[j,i],DPR[j,i]);
                while(p > 0 && stack[p-1] > h){
                    int l = p == 1 ? 0 : point[p-2] + 1;
                    count = Math.Max(count,stack[p-1]*(j+1-l));
                    p--;
                }
                stack[p] = h;
                point[p] = j;
                p++;
            }
            while(p > 0 && stack[p-1] > 0){
                int l = p == 1 ? 0 : point[p-2] + 1;
                count = Math.Max(count,stack[p-1]*(H-l));
                p--;
            }
        }
        sb.Append(count+"\n");
    }
}

Measured memory_bytes: 67008
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAX_N 1000

int sp = 0;
int value[MAX_N];

void push(int x)
{
  if(sp < MAX_N) value[sp++] = x;
  else printf("error: stuck full, can't push%d\n",x);      
}

int pop()
{
  if(sp > 0) return value[--sp];
  else
    {
      return 0;
    }
}

int main(){
  int x, tmp;
  char s[100];

  while(scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      push(pop() + pop());
    } else if ( s[0] == '-' ){
      tmp = pop();
      push(pop() - tmp);
    } else if ( s[0] == '*' ){
      push(pop()*pop());
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",pop());
  return 0;
}

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

using ll = long long;

class union_find {
public:
    union_find(int n)
        : par_(n, -1)
    {}
    void init(int n) {
        par_.assign(n, -1);
    }

    int root(int x) {
        return par_[x] < 0 ? x : par_[x] = root(par_[x]);
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) {
            return false;
        } else {
            if(par_[x] < par_[y]) {
                par_[x] += par_[y];
                par_[y] = x;
            } else {
                par_[y] += par_[x];
                par_[x] = y;
            }
            return true;
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par_[root(x)];
    }

private:
    std::vector<int> par_;
};

int main() {
    string s; cin >> s;
    const int n = s.size();
    ll k; cin >> k;
    union_find uf(n);
    for(int i = 0; i < n - 1; ++i) {
        if(s[i] == s[(i + 1) % n]) {
            uf.unite(i, (i + 1) % n);
        }
    }
    const ll fr = uf.size(0), bk = uf.size(n - 1);
    if(s[0] == s.back()) uf.unite(0, n - 1);
    ll ans = 0;
    if(uf.size(0) == n) {
        ans = n * k / 2;
    } else {
        vector<bool> ok(n);
        ll cross = 0;
        for(int i = 0; i < n; ++i) {
            if(ok[uf.root(i)]) continue;
            ok[uf.root(i)] = true;
            if(uf.root(i) == uf.root(0) || uf.root(i) == uf.root(n - 1)) {
                cross += uf.size(i) / 2;
            } else {
                ans += uf.size(i) / 2;
            }
        }
        ans *= k;
        ans += (k - 1) * cross;
        ans += fr / 2 + bk / 2;
    }

    cout << ans << endl;
}


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

int main(){
	ll n,m;
	string s;
	cin>>s;
	ll len = s.length();
	ll sum = 0;
	string tmp = "";
	string now = "";
	for(int i = 0;i < len;i++){
		now += s[i];
		if(now != tmp){
			sum++;
			tmp = now;
			now = "";
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 640
N, M = list(map(int, input().split()))
ps = [list(input().split()) for _ in range(M)]

D = [0] * N
W = [0] * N
for p, S in ps:
  p = int(p) - 1
  if D[p] == 0:
    if S == "WA":
      W[p] += 1
    else:
      D[p] = 1

cnt = 0
for i in range(N):
  if D[i] == 1:
    cnt += W[i]

print(sum(D), cnt)


Measured memory_bytes: 67160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define endl "\n"
using Edge = pair<int,ll>;
using Graph = vector<vector<Edge>>;
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

const int mod = 1000000007;

int modpow(int a, int n, int mod) {
    int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(void){
  int n,a,b; cin >> n >> a >> b;
  int nnum = n;
  mint ans = 2;
  ans = ans.pow(n);
  // cout << ans.x << endl;
  mint anum = 1;
  mint bnum = 1;
  FORD(i,n,n-a+1){
    anum *= i;
    anum /= (n-i) + 1;
  }
  // FORD(i,a,1){
  //   anum /= i;
  // }
  // FORD(i,n,n-b+1){
  //   bnum *= i;
  // }
  // FORD(i,b,1){
  //   bnum /= i;
  // }
  FORD(i,n,n-b+1){
    bnum *= i;
    bnum /= (n-i) + 1;
    // cout << bnum.x << endl;
  }

  // cout << ans.x << endl;

  ans -= anum + bnum;
  ans -= 1;
  cout << ans.x << endl;


  
}




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

int main() {
    int A, B;
    string S;
    cin >> A >> B >> S;
    std::smatch smatch;
    string reg = "(\\d{" + to_string(A) + "})-(\\d{" + to_string(B) + "})";
    bool match_flg = std::regex_search(S, smatch, std::regex(reg));
    if (match_flg) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

using namespace std;

int value[107], weight[107];

const int INF = 1e9 + 7;

int memo[107][(int)1e6+5];
int n, w;


long long dp(int i, long long val)
{
	if (val <= 0)
		return 0;
	if (i >= n)
		return INF;

	if (memo[i][val] != -1)
		return memo[i][val];

	return memo[i][val] = min(dp(i+1, val), weight[i] + dp(i+1, val - value[i]));
}

int main()
{

	long long mxValue = 0;
	memset(memo, -1, sizeof(memo));

	cin >> n >> w;
	for (int i = 0; i < n; ++i)
	{
		cin >> weight[i] >> value[i];
		mxValue += value[i];
	}

	for (long long j = mxValue; j >= 0; j--)
	{

		if (dp(0, j) <= w)
		{
			cout << j << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 418304
#include<stdio.h>
int main(void)
{
	int a,b,c,s;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	s=3;
	if(a==b)	{
		s=s-1;
	}
	if(b==c)	{
     s=s-1;
	}
	if(a==c)	{
		s=s-1;
	}
	if(s==0)	{
		s=s+1;
	}
	
	printf("%d\n",s);
	return 0;
}

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

int main()
{
    string str1, str2;
    int flat;
    cin >> str1 >> str2;
    for (int i = 0; i != str1.size(); ++i)
    {
        flat = 0;
        for (int j = 0; j != str2.size(); ++j)
        {
            if (str1[(i+j) % str1.size()] != str2[j])
            {
                break;
            }
            else
            {
                ++flat;
            }
        }
        if (flat == str2.size())
        {
            break;
        }
    }
    if (flat == str2.size())
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3200