akhauriyash/Code-Regression huggingface dataset:
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N;
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

signed main() {
    float k=0;
int Bse,Bsyo;
string B;
long A,miniA,inA,Al,p=1;
cin >> A >> B;
Bse = ctoi(B[0]);
Bsyo = ctoi(B[2])*10 +ctoi(B[3]);
Al = A*Bse;
inA = A*Bsyo/100;

answer(Al + inA);
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(void)
{
    int a = 0;
    int b = 0;
    int n = 0;
    int sum_tx = 0;

    scanf("%d %d %d", &n, &a, &b);
    sum_tx = a*n;
    if(sum_tx >= b) printf("%d", b);
    else printf("%d", sum_tx);


    return 0;
}


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

long long H, W;
string ban[60];
set<pair<long long, long long> >visit;

int vx[4] = {1, 0, -1, 0};
int vy[4] = {0, 1, 0, -1};

bool valid(long long h, long long w){
	return (h>=0 && w>=0 && h < H && w < W && ban[h][w]=='.');
}

long long cal(long long y, long long x, long long newy, long long newx) {
	if(!valid(newy, newx))
		return -1;
	return 1;
}

int main(){
	cin >> H >> W;
	long long black = 0;
	for(long long i = 0; i < H; i++){
		cin >> ban[i];
		for(long long j = 0; j < W; j++){
			if(ban[i][j] == '#'){
				black++;
			}
		}
	}
	priority_queue<pair<long long, pair<long long, long long> >, 
		vector<pair<long long, pair<long long, long long> > >,
		greater<pair<long long, pair<long long, long long> > > >que;

	que.push(make_pair(0, make_pair(0, 0)));


	while(!que.empty()){
		long long cost = que.top().first;
		long long y = que.top().second.first;
		long long x = que.top().second.second;
		que.pop();
		if(visit.count(make_pair(y, x)) != 0){
			continue;
		}
		visit.insert(make_pair(y,x));
		if(y == H-1 && x == W -1){
			cout << H * W - cost - 1 - black << endl;
			return 0;
		}
		for(long long i = 0; i < 4; i++){
			long long newy = y + vy[i];
			long long newx = x + vx[i];
			long long newcost = cost + cal(y, x, newy, newx);
			if(visit.count(make_pair(newy, newx)) == 0 && valid(newy, newx)){
				que.push(make_pair(newcost,make_pair(newy, newx)));
			}
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 384
package main

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

const Mod = int(1e9) + 7

func main() {
	N, K := ReadInt(), ReadInt()
	s := 0
	for k := K; k <= N+1; k++ {
		l := (k - 1) * k / 2 % Mod
		r := (N + N - k + 1) * k / 2 % Mod
		s = Mod + (s+r-l+1)%Mod
	}
	fmt.Println(s % Mod)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


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

int main()
{
   int64_t a,b,c,k;
   int64_t sum =0;
   cin>>a>>b>>c>>k;
  
  for(int i=0;i<k;i++)
  {
     if(a!=0)
     {
        a--;
        sum++;
     }
     else if(b!=0)
     {
        b--;
        
     }
     else 
     {
       sum--;
     }
  }
  
  cout<<sum<<endl;


}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    if(n <= k){
        cout << n*x << endl;
    }
    else{
        cout << k*x+(n-k)*y << endl;
    }
    return 0;
}



Measured memory_bytes: 256
from collections import defaultdict 

n = int(input())
dic = defaultdict(int)
s = [""] * n
flag = True
for i in range(n):
    s[i] = input()
    if i != 0:
        if s[i - 1][len(s[i - 1]) - 1] != s[i][0]:
            flag = False
    
    if dic[s[i]] != 0:
        flag = False
    dic[s[i]] += 1
print("Yes" if flag == True else "No")

Measured memory_bytes: 3316
#!/usr/bin/env python3

def main():
    import itertools
    H, W, K = map(int, input().split())
    C = [list(input()) for _ in range(H)]

    ans = 0
    for i in range(H + 1):
        for j in range(W + 1):
            for n in itertools.combinations(list(range(H)), i):
                for m in itertools.combinations(list(range(W)), j):
                    count = 0
                    for a in n:
                        for b in m:
                            if C[a][b] == "#":
                                count += 1
                    if count == K:
                        ans += 1
    print(ans)

if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;

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

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

vector<vector<ll>> dp1;
vector<vector<ll>> dp2;

ll solve(const string S, const int slen, const int K) {
    for (int i = 0; i < slen; i++) {
        int d = S[i + 1] - '0';

        // dp1
        for (int j = 0; j <= K; j++) {
            if (j < K) {
                if (d > 0) {
                    dp1[i + 1][j + 1] += dp1[i][j];
                    dp2[i + 1][j + 1] += (d - 1) * dp1[i][j];
                    dp2[i + 1][j] += dp1[i][j];
                } else {
                    // actually d == 0
                    dp1[i + 1][j] += dp1[i][j];
                }
            } else {
                // actually j == k
                if (d > 0) {
                    dp2[i + 1][j] += dp1[i][j];
                } else {
                    // actually d == 0
                    dp1[i + 1][j] += dp1[i][j];
                }
            }
        }

        // dp2
        for (int j = 0; j <= K; j++) {
            // use numbers other than zero
            if (j < K) {
                dp2[i + 1][j + 1] += 9 * dp2[i][j];
            }

            // use zero
            dp2[i + 1][j] += dp2[i][j];
        }
    }

    return dp1[slen][K] + dp2[slen][K];
}

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

    int len = (int) S.size();
    S = " " + S;

    dp1.resize(len + 1, vector<ll>(4, 0));
    dp2.resize(len + 1, vector<ll>(4, 0));
    dp1[0][0] = 1;

    cout << solve(S, len, K) << endl;

    // printf("dp1: \n");
    // for (int i = 0; i <= len; i++) {
    //     for (int j = 0; j <= K; j++) {
    //         cout << dp1[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;

    // printf("dp2: \n");
    // for (int i = 0; i <= len; i++) {
    //     for (int j = 0; j <= K; j++) {
    //         cout << dp2[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;

    return 0;
}


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

using namespace std;
const double pi=acos(-1.0);
const int N=2e5+10;
typedef long long ll;
const ll m=1e9+7;
int main()
{
   int n,k;
   cin>>n>>k;
   ll ans=0;
   ll x=0;
   ll y=0;
   for(int i=1;i<=k-1;i++) x+=i;
   for(int i=n;n-i<=k-1;i--) y+=i;
   //cout<<x<<""<<y<<endl;
   for(int i=k;i<=n+1;i++){
         ans+=(y-x)+1;
         ans%=m;
         x+=i;
         y+=n-i;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
#include <cstring>

using namespace std;

int w, h;
string b[20];
int step[20][20];

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

void bfs(int x, int y){
	memset(step, -1, sizeof(step));
	queue< pair<int, int> > qu; qu.push(make_pair(x,y));
	step[x][y] = 0;
	while(!qu.empty()){
		pair<int, int> pr = qu.front(); qu.pop();
		int cx = pr.first, cy = pr.second;
		for(int i=0;i<4;i++){
			int nx = cx+dx[i], ny = cy+dy[i];
			if(nx<0||h<=nx||ny<0||w<=ny||b[nx][ny]=='x'||step[nx][ny]!=-1) continue;
			step[nx][ny] = step[cx][cy]+1;
			qu.push(make_pair(nx,ny));
		}
	}
}

int main(){
	int c[11][11];
	while(cin >> w >> h, w){
		for(int i=0;i<h;i++) cin >> b[i];
		vector<int> x(1), y(1);
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(b[i][j]=='o') x[0] = i, y[0] = j;
				if(b[i][j]=='*') x.push_back(i), y.push_back(j);
			}
		}
		int res = 1000000000;
		for(int i=0;i<x.size();i++){
			bfs(x[i], y[i]);
			for(int j=0;j<x.size();j++){
				c[i][j] = step[x[j]][y[j]];
				if(c[i][j]==-1) res = -1;
			}
		}
		if(res != -1){
			vector<int> a(x.size()-1);
			for(int i=0;i<x.size()-1;i++) a[i] = i+1;
			do{
				int cur = c[0][a[0]];
				for(int i=0;i+1<a.size();i++) cur += c[a[i]][a[i+1]];
				res = min(res, cur);
			}while(next_permutation(a.begin(), a.end()));
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 928
/**
*    created: 05.07.2020 17:12:29
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int t = min(b,d) - max(a,c);
    cout << max(0LL,t) << endl; 
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int k, s;
    cin >> k >> s;
    int ans = 0;
    for(int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            if (s - x - y <= k && s-x-y >=0)
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <cstdint>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<uint32_t> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	sort(a.begin(), a.end(), greater<uint32_t>());
	unordered_multiset<uint32_t> keys;
	int answer = 0;
	for(const auto x : a){
		const auto it = keys.find(x);
		if(it != keys.end()){
			keys.erase(it);
			++answer;
		}else{
			const int msb = 31 - __builtin_clz(x);
			const uint32_t y = (x ^ ((2u << msb) - 1u)) + 1u;
			keys.insert(y);
		}
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 9288
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  ll N, K;
  cin >> N >> K;
  ll ans = 0;

  if (K % 2 == 1)
  {
    ll q = floor(N / K);
    ans += pow(q, 3);
  }
  else if (K % 2 == 0)
  {
    ll q = floor(N / K);
    ll q2 = floor(N / (K / 2));
    if (q * 2 == q2)
    {
      ans += pow(q, 3) * 2;
    }
    else
    {
      ans += pow(q, 3) + pow(q2 - q, 3);
    }
  }

  cout << ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <fstream>
#include <cassert>
#include <ctime>
#include <list>
#include <numeric>
#include <iomanip>


using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#ifndef M_PI
const double M_PI=acos(-1);
#endif
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int((a).size()))
#define F first
#define S second
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};

int n,m;
int in[1000];

void solve(){
  int ans = 0;
  rep(i,n){
    cin >> in[i];
    if(in[i] <= m) ans = max(in[i],ans);
  }
  sort(in,in+n);

  vector<int> dbl;
  rep(i,n)rep(j,i+1){
    int su = in[i] + in[j];
    dbl.pb(su);
    if(su <= m) ans = max(su,ans);
  }
  sort(ALL(dbl));

  int idx = SZ(dbl) - 1;
  rep(i,n){
    while(idx > 0 && dbl[idx]+in[i]>m) --idx;
    if(idx>=0 && dbl[idx]+in[i] <= m) ans = max(dbl[idx]+in[i],ans);
  }

  idx = SZ(dbl) - 1;
  rep(i,SZ(dbl)){
    while(idx > 0 && dbl[idx]+dbl[i]>m) --idx;
    if(idx>=0 && dbl[idx]+dbl[i] <= m) ans = max(dbl[idx]+dbl[i],ans);
  }

  cout << ans << endl;
}

main(){
  while(cin>>n>>m,n|m) solve();
}

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

using namespace std;

constexpr int N = 100000;

int a[N + 1];
int b[N + 1];
int sa[N + 1];
int sb[N + 1];
int pa[N + 1];
int pb[N + 1];
bool seen[N + 1];

bool comp_sa(int x, int y) {
	return sa[x] < sa[y];
}

bool comp_b(int x, int y) {
	return b[x] < b[y];
}

int main() {
	int n, i;

	scanf("%d", &n);

	for (i = 1; i <= n; i++) {
		scanf("%d", a + i);
		pa[i] = i;
	}

	for (i = 1; i <= n; i++) {
		scanf("%d", b + i);
		pb[i] = i;
	}

	// Applying permutation to sort b.
	sort(pb + 1, pb + 1 + n, comp_b);

	for (i = 1; i <= n; i++) {
		sb[i] = b[pb[i]];
		sa[i] = a[pb[i]];
	}

	// Getting needed permutation.
	sort(pa + 1, pa + 1 + n, comp_sa);

	for (i = 1; i <= n; i++) {
		if (sa[pa[i]] > sb[i]) {
			break;
		}
	}

	if (i <= n) { // Not even sorting.
		printf("No\n");
		return 0;
	}

	for (i = 2; i <= n; i++) {
		if (sa[pa[i - 1]] <= sb[i] and sa[pa[i]] <= sb[i - 1]) {
			break;
		}
	}

	if (i <= n) { // Has multiple solution permutations.
		printf("Yes\n");
		return 0;
	}

	i = 1;

	while (!seen[i]) {
		seen[i] = true;
		i = pa[i];
	}

	for (i = 1; i <= n; i++) {
		if (!seen[i]) {
			break;
		}
	}

	if (i <= n) {
		printf("Yes\n");
	}
	else { // Permutation is one big cycle of order n.
		printf("No\n");
	}

	return 0;
}

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

#define            read              freopen("in.txt", "r", stdin);
#define            ll                long long
#define            mx                100005

using namespace std;


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

	cin >> a >> b >> c;

	int x = c/a;

	int ans = x * b;

	cout << ans << endl;

	return 0;
}

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

// why am I so weak

int n, k;
int a[5055];
bitset<5000> l[5055], r[5055];

int last[5055];

int main() {
	scanf("%d %d", &n, &k);

	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	l[0].set(0);
	if (a[0] < k) l[0].set(a[0]);

	r[n - 1].set(0);
	if (a[n - 1] < k) r[n - 1].set(a[n - 1]);

	for (int i = 1; i < n; i++) {
		l[i] = l[i - 1];
		l[i] |= l[i - 1] << a[i];
	}

	for (int i = n - 2; i >= 0; i--) {
		r[i] = r[i + 1];
		r[i] |= r[i + 1] << a[i];
	}

	int res = 0;

	for (int i = 0; i < n; i++) if (a[i] < k) {
		memset(last, -1, sizeof(last));

		bool cool = false;

		if (i) {
			for (int j = 0; j < k; j++) {
				if (l[i - 1][j]) last[j] = j;
				else last[j] = last[j - 1];

				if (l[i - 1][j] && j + a[i] >= k) cool = true;
			}
		}

		if (i + 1 < n) {
			for (int j = 0; j < k; j++) if (r[i + 1][j]) {
				// x + j < k
				// x < k - j

				if (j + a[i] >= k) {
					cool = true;
					break;
				}

				int bound = k - j - 1;

				if (bound >= 0) {
					int wow = last[bound];

					if (~wow && wow + j + a[i] >= k) {
						cool = true;
						break;
					}
				}
			}
		}

		if (!cool) res++;
	}

	printf("%d\n", res);

	return 0;
}

Measured memory_bytes: 6528
//098 B - Cut and Count 2018/05/26

#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	string s;cin >> n >> s;
	vector<bool> f(char('z')-char('a')+1,false);
	vector<int> _max(n,0);
	for(int i=0;i<n-1;++i){
		string x1=s.substr(0,i+1);
		string x2=s.substr(i+1,n);
		int prev=0;
		for(int j=0;j<x1.size();++j){
			for(int k=0;k<x2.size();++k){
				if(x1[j]==x2[k] && f[char('z')-char(x1[j])]==false) { ++_max[i]; f[char('z')-char(x1[j])]=true;}
			}
		}
		_max[i]=max(_max[i],prev);
		if(_max[i]>prev) prev=_max[i];
		for(int l=0;l<char('z')-char('a')+1;++l) f[l]=false;
		//cout << i << " " << x1 << " " << x2 << " " << _max[i] << endl;
		
	}
	sort(_max.begin(),_max.end());
	cout << _max[n-1] << endl; 
}
	

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>
// #include <multiset>

#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
	for (T x : s)
		cout << x << " ";
	cout << endl;
}

ll gcd(ll a, ll b){
	return b > 0 ? gcd(b, a % b) : a;
}

ll get(ll r, ll c, ll d){
	return r / c + r / d - r / (c * d / gcd(c, d));
}	

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	// cout << get(b, c, d) << endl;
	cout << b - a + 1 - get(b, c, d) + get(a - 1, c, d) << endl;
	return 0;	
}	

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a,ll b){
  return a*b/gcd(a,b);
}

ll N;
int main(){
    cin>>N;
    cout<<lcm(360,N)/N<<endl;

    return 0;
}

Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int time = 0, i, j, n, m, t[100], p[100], x[100];
	scanf("%d", &n);
	for (i = 1; i < n; i++)
		scanf("%d ", &t[i]);	
	scanf("%d", &t[n]);	
	scanf("%d", &m);

	/*for (i=1; i<=n; i++)
		printf("t%d=%d ", i, t[i]);
	printf("\n");
	*/
	for (i = 1; i <= m; i++)
		scanf("%d %d", &p[i],&x[i]);
	/*
	for (i = 1; i <= n; i++)
		printf("p%d=%d ", i, p[i]);
	printf("\n");
	*/

	//printf("n=%d m=%d\n",n,m);
	for (i = 1; i <= m; i++) {
		time = 0;
	//	printf("%d ", time); 
		for (j = 1; j <= n; j++)
			time += t[j];
	//	printf("%d %d ", j, time);
		time -= t[p[i]];
		time += x[i];
		printf("%d\n", time);
	}





	/*for (i = 0; i < n; i++)
		printf("%d\n", t[i]);
	*/return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define FOR(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;

const int MX = 2005;
int n, k, q, a[MX], res = 2e9;
vii v;
int acu[MX], gr[MX];

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    cin >> n >> k >> q;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    a[n] = -1;

    for (int i = 0; i < n; i++) {
        fill(acu, acu+n, 0);
        fill(gr, gr+n, 0);
        v.clear();

        int act = a[i], ant, mx, cn = 0;
        bool f = 0;

        for (int j = 0; j <= n; j++) {
            if (a[j] >= act) {
                if (f) {
                    acu[ant]++;
                    gr[j] = ant;
                    v.emplace_back(a[j], j);
                } else {
                    ant = j;
                    acu[j]++;
                    gr[j] = j;
                    v.emplace_back(a[j], j);
                    f = 1;
                }
            } else {
                f = 0;
            }
        }

        sort(ALL(v));

        for (ii &u : v) {
            if (acu[gr[u.se]] < k)
                continue;

            mx = u.fi;
            cn++;
            acu[gr[u.se]]--;

            if (cn == q)
                break;
        }

        if (cn == q)
            res = min(res, mx - act);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include<time.h>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Graph=vector<vector<ll> >;//int と P
// g++ -o a a.cpp -Wall -lm -std=c++14
void rec(int d,ll val,VI &all){
    all.push_back(val);
    if(d==11)return;
    for(int j=-1;j<=1;++j){
        int add=(val%10)+j;
        if(add>=0 && add<=9)rec(d+1,val*10+add,all);
    }
}
int main(){
    ll k;cin>>k;
    VI all;
    for(int v=1;v<10;v++)rec(1,v,all);
    sort(ALL(all));
    cout<<all[k-1]<<endl;
}


Measured memory_bytes: 11656
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,k,w[N],head[N],nxt[N];
void add(int f,int t){
    static int cnt=0;
    w[++cnt]=t;
    nxt[cnt]=head[f];
    head[f]=cnt;
}
int ans,cnt,dep[N],num[N];
void dfs(int x,int fa){
    if (dep[x]<=k/2) cnt++;
    num[x]=0;
    if (dep[x]==k/2+1) num[x]++;
    for (int i=head[x];i;i=nxt[i]){
        int v=w[i];
        if (v==fa) continue;
        dep[v]=dep[x]+1;
        dfs(v,x);
        num[x]+=num[v];
    }
}
int main()
{
    scanf("%d%d",&n,&k);
    for (int i=1;i<n;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);add(v,u);
    }
    for (int v=1;v<=n;v++){
        dep[v]=cnt=0;
        dfs(v,0);
        if (k&1){
            int Max=0;
            for (int i=head[v];i;i=nxt[i]) Max=max(Max,num[w[i]]);
            cnt+=Max;
        }
        ans=max(ans,cnt);
    }
    printf("%d\n",n-ans);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b; cin >> n >> a >> b;
    if(a > b) cout << 0 << endl;
    else if(n == 1 and a != b) cout << 0 << endl;
    else
    {
        ll left = a * (n - 1) + b, right = a + (n - 1) * b;
        cout << right - left + 1 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
// AOJ ALDS1_14_A Naive String Search
// 2018.4.27 bal4u

#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

char text[1000005];
char pattern[10005];
int  next[10005], skip[258];

char *bmMatch(char *text, int len, char *pattern, int patlen,
              int *skip, int *next)
{
    int i, j;

    i = patlen - 1;
    while (i < len) {
        j = patlen - 1;
        while (j >= 0 && text[i] == pattern[j]) {
            i--;
            j--;
        }
        if (j < 0) return text + i + 1;
        if (skip[text[i]] >= next[j]) i += skip[text[i]];
        else i += next[j];
    }
    return NULL;
}

int bmSkip(int *skip, int slen, char *pattern, int patlen)
{
    int j;

    if (slen < 256) return -1;
    for (j = 0; j < 256; j++) skip[j] = patlen;
    for (j = 0; j < patlen - 1; j++)
        skip[pattern[j]] = patlen-1-j;
    return 0;
}

int bmNext(int *next, int nlen, char *pattern, int patlen)
{
    int  j, k, s;
    int  *g;

    g = malloc(sizeof(int)*patlen);
    for (j = 0; j < patlen; j++) next[j] = 2*patlen - 1 - j;
    j = patlen;
    for (k = patlen - 1; k >= 0; k--) {
        g[k] = j;
        while (j != patlen && pattern[j] != pattern[k]) {
            next[j] = (next[j] <= patlen-1-k) ? next[j] : patlen-1-k;
            j = g[j];
        }
        j--;
    }
    s = j;
    for (j = 0; j < patlen; j++) {
        next[j] = (next[j] <= s+patlen-j) ? next[j] : s+patlen-j;
        if (j >= s) s = g[s];
    }
    free(g);
    return 0;
}

int main()
{
	int c, tlen, plen, len;
	char *pos;

	pos = text; while (1) {
		if ((c = gc()) <= ' ') break;
		*pos++ = c;
	}
	*pos = 0; tlen = pos-text;

	pos = pattern; while (1) {
		if ((c = gc()) <= ' ') break;
		*pos++ = c;
	}
	*pos = 0; plen = pos-pattern;

    bmSkip(skip, 256, pattern, plen);
    bmNext(next, plen, pattern, plen);
	pos = text, len = tlen;
	while (1) {
	    pos = bmMatch(pos, len-(pos-text), pattern, plen, skip, next);
		if (pos == NULL) break;
		printf("%d\n", pos-text);
		pos++;
	}
	return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
//#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
#define data data1
// std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// int myRand(int R) {
// 	int val=rng() % R;
//       assert(val>=0);
//       return val;
// }
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int MOD=MOD1;

int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
           char ch;
           cin>>ch;
           if(ch>='a' && ch<='z')cout<<'a'<<endl;
           else cout<<'A'<<endl;   
      }      
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

#define int long long

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int s, t, d, w[112345], sum, mn, mnd;

signed main(){
    cin >> s >> t >> d;
    REP(i, d) cin >> w[i];
    REP(i, d){
        sum += w[i];
        if(mn > sum){
            mn = sum;
            mnd = i;
        }
    }

        int st = s;
        for(int i = 0; i < d; ++i){
            st += w[i];
            if(st <= t){
                cout << i + 1 << endl;
                return 0;
            }
        }
    if(sum >= 0){
        cout << -1 << endl;
        return 0;
    }

    // cout << sum << endl;
    // cout << mn << " " << mnd << endl;
    int ans = (s - t + mn - 1) / (- sum) + 1;
    st = s + ans * sum;
    ans *= d;
    if(st > t)
    for(int i = 0; i < d; ++i){
        st += w[i];
        if(st <= t){
            ans += i + 1;
            break;
        }
    }
    cout << ans << endl;
}


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

using namespace std;
const int N = 2e5 + 5;
int val[N];
vector<int> adj[N];

void dfs(int u, int pr = -1, int sum=0){
    val[u] += sum;
    for(int v:adj[u]){
        if(v != pr){
            dfs(v, u, val[u]);
        }
    }
}
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
    int n, q;
    scanf("%d %d", &n, &q);
    for(int i=0; i<n-1; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        --u, --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    while(q--){
        int u, v;
        scanf("%d %d",&u,&v);
        --u;
        val[u] += v;
    }
    dfs(0);
    for(int i=0; i<n; i++)
        printf("%d ", val[i]);
    return 0;
}


Measured memory_bytes: 23424
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define memset(v, h) memset((v), h, sizeof(v))
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using P = pair<ll, ll>;
const int INF = 1001001001;

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; }

struct uf {
    vector<ll> par;
    vector<ll> sizes;

    uf(int n)
    {
        for(int i = 0; i < n; i++) {
            par.push_back(i);
            sizes.push_back(1);
        }
    }

    ll root(int x) 
    {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) 
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
        sizes[ry] = sizes[rx] + sizes[ry];
    }

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

    ll size(int x)
    {
        return sizes[root(x)];
    }
};

struct node
{
    public: ll x;
    public: ll y;

    node(ll xx, ll yy)
    {
        x = xx;
        y = yy;
    }
};

ll comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v[n][r];
}

ll digit(ll num)
{
    if(num < 10)
    {
        return 1;
    }

    ll d = 1;
    ll k = 10;
    while(num >= k)
    {
        d++;
        k *= 10;
    }

    return d;
}

ll digitNum(ll num, ll count)
{
    ll a = (num % (ll) pow((double) 10, (double) count));
    return a / pow(10, count - 1);
}

bool less_abs(int lhs, int rhs) {
    if(lhs < 0)
    {
        lhs *= -1;
    }
    if(rhs < 0)
    {
        rhs *= -1;
    }

    return lhs < rhs;
}

bool IsTrueBit(int bit, int index)
{
    return (bit & (1 << index));
}

int main(){
    ll h, w;
    cin >> h >> w;
    if(h >= 10)
    {
        cout << w << endl;
    }
    else
    {
        cout << w + (100 * (10 - h)) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)
	var B [4][3][10]int
	for i := 0; i < n; i++ {
		var b, f, r, v int
		fmt.Scanf("%d%d%d%d", &b, &f, &r, &v)
		b--; f--; r--
		B[b][f][r] += v
	}

	for i:= 0; i < 4;i++{
		for j:=0;j<3;j++{
			for k:=0;k < 10;k++{
				fmt.Printf(" %d",B[i][j][k])
			}
			fmt.Print("\n")
		}
		if i != 3{
			fmt.Println("####################")
		}
	}
}



Measured memory_bytes: 1180
import numpy as np

N = int(input())
S = list(input())
S2 = np.array([1 if x == ')' else -1 for x in S])
S_cum = S2.cumsum()
S = ['('] * S_cum.max() + S
left = S.count('(')
right = len(S) - left
if left > right:
    S = S + [')'] * (left-right)
elif right > left:
    S = ['('] * (right-left)
print(''.join(S))


Measured memory_bytes: 12484
n = int(input())
route = {}

for i in range(n-1):
    u, v, w = map(int, input().split())
    if u in route:
        route[u].append((v, w))
    else:
        route[u] = [(v, w)]
    if v in route:
        route[v].append((u, w))
    else:
        route[v] = [(u, w)]

r = [-1] * n
q = [1]
r[0] = 0
while len(q) > 0:
    u = q.pop()
    vws = route[u]
    for (v, w) in vws:
        if r[v-1] != -1:
            continue
        r[v-1] = (w & 1) ^ r[u-1]
        q.append(v)

for i in r:
    print(i)

Measured memory_bytes: 45472
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
  int x;
  scanf("%d", &x);

  int happy = 0;
  happy += (x / 500) * 1000;
  happy += (x % 500) / 5 * 5;


  cout << happy << endl;
  return 0;
}


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

int main(){
  int n,k; cin >> n >> k;
  vector<int> p(n);
  for(int i=0;i<n;i++) cin >> p[i];
  set<int> s;
  vector<bool> c(n, true);
  int cs=0,cg=0;
  for(int i=0;i<k-2;i++){
    if(p[i] < p[i+1]) cs++;
    else cg++;
  }
  for(int i=k-1;i<n;i++){
  	if(p[i-1] < p[i]) cs++;
    else cg++;
    if(cg==0) c[i]=false;
	
    if(p[i-1-k+2] < p[i-k+2]) cs--;
    else cg--;
  }
  int ans=1;
  bool nor = false;
  if(!c[k-1]){
    nor = true;
    ans = 0;
  }
  for(int i=0;i<k;i++) s.insert(p[i]);
  for(int i=k;i<n;i++){
  	s.insert(p[i]);
    auto lit = s.begin();
    auto rit = s.end(); rit--;
  	if(*lit == p[i-k] && *rit == p[i]) ;
    else if(c[i]) ans++;
    else nor = true;
    
    s.erase(p[i-k]);
  }
  if(nor) ans++;
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 10496
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <utility>
#include <stack>
#include <queue>

using namespace std;

long long n,k;
long long a[200000];

int main()
{
	cin >> n >> k;
	long long f=0;
	for (long long i=1;i<=n;i++)
	{
		cin >> a[i];
		if (!f&&a[i]>=0) f=i;
	}
	long long mn=0x3f3f3f3f3f3f3f3f;
	if (!f) f=n+1,a[f]=mn;
	if (f+k-1<=n) mn=a[f+k-1];
	if (f-k>0 && -a[f-k]<mn) mn=-a[f-k];
	if (a[f]==0 && f-k+1>0 && -a[f-k+1]<mn) mn=-a[f-k+1];
	for (long long i=1;i<k;i++)
	{
		if (f+i-1<=n && f-k+i>0)
		{
			if (a[f+i-1]*2-a[f-k+i]<mn) mn=a[f+i-1]*2-a[f-k+i];
			
			if (a[f+i-1]-2*a[f-k+i]<mn) mn=a[f+i-1]-2*a[f-k+i];
		}
	}
	cout << mn << endl;
	return 0;
}


Measured memory_bytes: 1024
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)



Measured memory_bytes: 47544
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N=2200;
int a[N][N],n,m,d[N][N],h[N][N],ans,stack[N][2],top,tt;
char ch;
int main(){
//    freopen("1.in","r",stdin);
    scanf("%d%d\n",&n,&m);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            scanf("%c",&ch);
            if(ch=='#')a[i][j]=1;
            else a[i][j]=0;
        }scanf("\n");
    } ans=max(n,m);n=n-1;m=m-1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            d[i][j]=1-((a[i][j]+a[i+1][j]+a[i][j+1]+a[i+1][j+1])%2);
        }
    }
   
    for(int i=1;i<=n;i++){
        for(int j=m;j>=1;j--){
            if(d[i][j]==1)h[i][j]=h[i][j+1]+1;
            else h[i][j]=0;
        }
    }
//    for(int i=1;i<=n;i++){
//    	for(int j=1;j<=m;j++)printf("%d ",d[i][j]);
//    	printf("\n");
//    }printf("\n\n");
//    for(int i=1;i<=n;i++){
//    	for(int j=1;j<=m;j++)printf("%d ",h[i][j]);
//    	printf("\n");
//    }
    for(int j=1;j<=m;j++){
        top=0;memset(stack,0,sizeof stack);
        for(int i=1;i<=n+1;i++){
            tt=1;
            while(top>0&&stack[top][0]>=h[i][j]){
                tt+=stack[top][1];
                ans=max(ans,(stack[top][0]+1)*(tt));
                --top;
            }
            ++top;
            stack[top][0]=h[i][j];
            stack[top][1]=tt;
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 55424
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break

    n = x - 3 if n >= x - 2 else n
    count = 0
    
    for maximum in range(n, 2, -1):
        for mid in range(maximum - 1, 1, -1):
            for minimum in range(mid - 1, 0, -1):
                if maximum + mid + minimum == x:
                    count += 1
                    
    print(count)
        


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

using namespace std;

bool pred(pair<int,int> a, pair<int,int> b){
    return a.first > b.first;
}

int main(){
    int n,m;
    while(cin >> n >> m){
        if((n|m) == 0) break;

        pair<int,int> seg[n];

        for(int i=0;i<n;i++){
            cin >> seg[i].second >> seg[i].first;
        }
        sort(seg, seg+n, pred);

        int ret=0;
        for(int i=0;i<n;i++){
            if(m > 0){
                if(seg[i].second > m){
                    ret += (seg[i].second - m) * seg[i].first;
                    m = 0;
                }else{
                    m -= seg[i].second;
                }
            }else{
                ret += seg[i].second * seg[i].first;
            }
        }
        cout << ret << endl;
    }
}

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

using namespace std;

int n, x, y, ans[10005];

int main()
{
	cin >> n >> x >> y;
	for(int i = 1; i <= n; i++)
	{
		for(int j = i + 1; j <= n; j++)
		{
			int t = min(min(j - i, abs(x - i) + abs(j - x)), min(abs(y - i) + abs(j - y), abs(x - i) + 1 + abs(j - y)));
			ans[t]++;
		}
	}
	for(int i = 1; i <= n - 1; i++)
		printf("%d\n", ans[i]);
	return 0;
}

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

using namespace std;
using ll = long long;

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

    string t;

    cin >> t;

    char c0;

    for(char& c: t) {
        if(c == '?') c = 'D';
    }

    cout << t << "\n";

    return 0;
}

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

int main() {
  double a, b, x, rad;
  cin >> a >> b >> x;
  rad = (2 * x > a * a * b ? atan(2 * (a * a * b - x) / (a * a * a))
         : atan(a * b * b / (2 * x)));
  printf("%.8lf", rad * 180 / M_PI);
}


Measured memory_bytes: 256
//sumitrust2019
//Chandigarh University
//author: shivamkr21 (pseduo coders)
#include<bits/stdc++.h>
//#include "boost/multiprecision/cpp_int.hpp"
//#define eint int1024_t
#define lli long long int
#define endl "\n"
#define vint vector<int>
#define vvint vector< vector<int> >
#define pub push_back 
#define mod 1000000007
//using namespace boost::multiprecision;
using namespace std;
lli fun_cal(lli x, lli y, lli l, lli r);
int main()
{
    std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

  	lli n;
	cin>>n;
	lli p1=ceil(n/1.08);

	lli np=p1*1.08;
	if(np == n)
		cout<<p1;
	else
		cout<<":(";
	
	
	return 0;

}

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

int main()
{
    int N, K;
    cin >> N >> K;
    int h[N];
    int passNum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
        if (h[i] >= K)
            passNum++;
    }
    cout << passNum << endl;
    return 0;
}


Measured memory_bytes: 640
#define rp(x)for(int i=0;i<x;i++)
int main(){
  int sx,sy,tx,ty;
  scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
  rp(ty-sy)printf("U");
  rp(tx-sx)printf("R");
  rp(ty-sy)printf("D");
  rp(tx-sx+1)printf("L");
  rp(ty-sy+1)printf("U");
  rp(tx-sx+1)printf("R");
  printf("DR");
  rp(ty-sy+1)printf("D");
  rp(tx-sx+1)printf("L");
  printf("U");
}

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

public class Main {
    public static InputReader in;
    public static PrintWriter out;
    public static void main(String[] args) {
        in = new InputReader(System.in);
        out = new PrintWriter(System.out);
        int n = in.nextInt();
        String s = in.next();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = (s.charAt(i) - '0');
        }
        for (int i = 0; i < n - 1; i++) {
            a[i] = Math.abs(a[i] - a[i + 1]);
        }
        n -= 2;
        boolean hasOne = false;
        for (int i = 0; i <= n; i++) {
            if (a[i] == 1) hasOne = true;
        }
        int[] prime2 = new int[n + 1];
        for (int i = 2; i <= n; i *= 2) {
            for (int j = i; j <= n; j += i) {
                prime2[j] += 1;
            }
        }
        int[] coefParity = new int[n + 1];
        coefParity[0] = 1;
        coefParity[n] = 1;
        int cur = 0;
        for (int i = 1; i <= n / 2; i++) {
            cur += prime2[(n + 1 - i)] - prime2[i];
            if (cur > 0) {
                coefParity[i] = 0;
                coefParity[n - i] = 0;
            } else {
                coefParity[i] = 1;
                coefParity[n - i] = 1;
            }
        }
        if (hasOne) {
            int ans = 0;
            for (int i = 0; i <= n; i++) {
                if ((a[i] & 1) == 0) continue;
                ans ^= coefParity[i];
            }
            out.println(ans);
        } else {
            int ans = 0;
            for (int i = 0; i <= n; i++) {
                if (a[i] == 0) continue;
                ans ^= coefParity[i];
            }
            out.println(ans * 2);
        }
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public Long nextLong() {
            return Long.parseLong(next());
        }
        public Double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 50056
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int lli;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=(x);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define SZ(container) ((int)container.size())

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, m, n;

main(){
	int i,j;
	cin >> T;
	while(T--){
		cin >> m >> n;
		int ans = 0;
		for(int p=-150;p<150;p++)for(int q=-150;q<150;q++){
			int g = p*p+q*q;
			if(!g) continue;
			if((m*p+n*q)%g == 0 && (m*q-n*p)%g == 0) ans ++;
		}
		cout << (ans>8 ? "C":"P") << endl;
	}
	return 0;
}

Measured memory_bytes: 1152