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

using namespace std;

long long d[2][333][333];

int main() {
    int n, m, l, a, b, c, q;
    cin >> n >> m >> l;
    for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) d[0][i][j] = d[1][i][j] = 1e15;
    for(int i=1;i<=n;i++) d[0][i][i] = d[1][i][i] = 0;
    for(int i=0;i<m;i++) {
        scanf("%d %d %d", &a, &b, &c);
        d[0][a][b] = d[0][b][a] = c;
    }
    for(int k=1;k<=n;k++) for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) d[0][i][j] = min(d[0][i][j],d[0][i][k]+d[0][k][j]);
    for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) if(d[0][i][j] <= l) d[1][i][j] = 1;
    for(int k=1;k<=n;k++) for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) d[1][i][j] = min(d[1][i][j],d[1][i][k]+d[1][k][j]);
    cin >> q;
    for(int i=0;i<q;i++) {
        scanf("%d %d", &a, &b);
        printf("%lld\n", d[1][a][b] == 1e15 ? -1 : d[1][a][b]-1); 
    }
    return 0;
}


Measured memory_bytes: 2048
import java.util.*;
import java.lang.*;
import java.io.*;

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

	int A,B,C;
	int[] MAX = new int[3];
	int max = 0;

	Scanner sc = new Scanner (System.in);
		A=sc.nextInt();
		B=sc.nextInt();
		C=sc.nextInt();

	MAX[0] = A*10 + B    + C;
	MAX[1] = A    + B*10 + C;
	MAX[2] = A    + B    + C*10;

	for(int i = 0; i < MAX.length; i++)
		max = Math.max(max,MAX[i]);

		System.out.println(max);

	}

}

Measured memory_bytes: 23252
#include <stdio.h>

int main(void)
{
	int n, x,i,j,k,counter=0;

	for (;;)
	{
		scanf("%d %d", &n, &x);

		if ((n == 0) && (x == 0))
		{
			break;
		}

		for (i = 1; i <= n - 2; i++)
		{
			for (j = i + 1; j <= n - 1; j++)
			{
				for (k = j + 1; k <= n; k++)
				{
					if (((i + j) + k) == x)
					{
						counter++;
					}
				}
			}
		}

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

		counter = 0;
	}

	return 0;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	if(a == b){
		cout << a*2 << endl;
	}else if(a > b){
		cout << a*2-1 << endl;
	}else{
		cout << b*2-1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int N,ans=0,cnt=0;
  string S,T;
  cin>>N>>S;
  T=S;
  
  for(int i=1; i<N; ++i){
    for(int j=0; j<N-i; ++j){
      if(S.at(i+j)==T.at(j)){
        cnt++;
      }
      if(S.at(i+j)!=T.at(j) || cnt>=i+1 || j==N-i-1){
        if(cnt>=i+1) ans=max(ans,cnt-1);
        else ans=max(ans,cnt);
        cnt=0;
      }
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n,a=map(int,input().split())
for i in range(n+1):
  for j in range(n-i+1):
    z=n-i-j
    if (10000*i)+(5000*j)+(1000*z)==a:
      print(i,j,z)
      exit()
print(-1,-1,-1)
    

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n;
    int max=0;
    int s_max=0;
    bool max_f=false;
    vector<int> num;
    cin>>n;

    for(int i=0;i<n;i++){
        int inp;
        cin>>inp;
        num.push_back(inp);
        if(inp>s_max){
            if(inp>max){
                s_max=max;
                max=inp;
                max_f=false;
            }else if(inp==max){
                max_f=true;
            }else{
                s_max=inp;
            }
        }        
    }
    if(max_f){
        for(int i=0;i<n;i++){
            cout<<max<<endl;
        }    
    }else{
        for(int i=0;i<n;i++){
            if(num.at(i)==max){
                cout<<s_max<<endl;
            }else{
                cout<<max<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 2548
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//221
	int n,m;
	cin>>n>>m;
	vi arr(n);
	for(int &i:arr)cin>>i;
	sort(arr.begin(),arr.end());
	vpii bc(m);
	for(auto &i:bc) {
		cin>>i.S>>i.F;
		//cerr<<i.S<<i.F;
	}
	sort(bc.rbegin(),bc.rend());
	ll sum = 0;int pos=0;
	for(int i:arr) {
		//cerr<<pos<<" "<<m<<" "<<i<<" "<<bc[pos].F;
		if(pos!=m&&i<bc[pos].F) {
			sum+=bc[pos].F;
			bc[pos].S--;
			if(bc[pos].S==0)pos++;
		} else sum+=i;
	}
	cout<<sum;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

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

    string s;
    cin >> s;
    if(s == "ABC")cout << "ARC";
    else cout << "ABC";
    return 0;
}


Measured memory_bytes: 3600
import collections

N = int(input())
VoteStr = [input() for i in range(N)]

MaxStr = []
# VoteStrの値を調べて、重複回数を計算する？
# 回数が一番多いものを辞書順にする。最大数が同列ならそれらを全て。

col = collections.Counter(VoteStr)
most_value = col.most_common()[0][1]

# 出現回数が最大数かどうかをしらべる
for val, num in col.items():
    if num == most_value:
        MaxStr.append(val)

for i in sorted(MaxStr):
    print(i)

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

// --------------------------------------------------------------------------------

void solve()
{
    int n;
    cin >> n;
    int cnt = 0;
    bool ok = false;
    rep(i, n)
    {
        int x, y;
        cin >> x >> y;
        if (x == y)
            cnt++;
        else
            cnt = 0;
        if (cnt == 3)
        {
            ok = true;
        }
    }
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

// --------------------------------------------------------------------------------

int main()
{
    // srand((unsigned)time(NULL));
    // int bt = clock();
    solve();
    // double et = 1.0 * (clock() - bt) / CLOCKS_PER_SEC;
    // printf("Execution Time: %.4lf sec\n", et);
    return 0;
}

Measured memory_bytes: 3616
while line = gets
  l = line.chomp.to_i
  break if l == 0

  count = 1
  12.times do
    m, n = gets.chomp.split.map(&:to_i)
    l -= (m - n)
    if l > 0
      count += 1
    end
  end

  puts (count > 12) ? :NA : count
end

Measured memory_bytes: 8788
main = do
    [h, w, a, b] <- map read . words <$> getLine :: IO [Int]
    let m = [[if (i < b) == (j < a) then 0 else 1 | j <- [0..w - 1]] | i <- [0..h - 1]]
    mapM_ (putStrLn . mconcat . map show) m

Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
const ll 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; }

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n) a[i]--;
    vector<int> s(n+1);
    rep(i,n) s[i+1] = (s[i]+a[i]) % k;
    map<int,int> mp;
    ll ans = 0;
    queue<int> q;
    rep(i,n+1){
        ans += mp[s[i]];
        mp[s[i]]++;
        q.push(s[i]);
        if(q.size()==k){
            mp[q.front()]--;
            q.pop();
        }
    }
    cout << ans << endl;
}

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

int main() {
  int a,b;
  cin>>a>>b;
  if(a%3==0){
    cout<<"Possible"<<endl;
  }
  else if(b%3==0){
    cout<<"Possible"<<endl;
  }
  else if((a+b)%3==0){
    cout<<"Possible"<<endl;
  }
  else{
    cout<<"Impossible"<<endl;
  }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int h, w; cin >> h >> w;
	rep(j, w + 2)cout << "#";
	cout << endl;
	rep(i, h) {
		string s; cin >> s;
		cout << "#" << s << "#" << endl;
	}
	rep(j, w + 2)cout << "#";
	cout << endl;
	return 0;
}

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

const int N = 1e5 + 5;

int n, k, q, a[N];

int main() {
	scanf("%d%d%d", &n, &k, &q);
	for (int i = 1; i <= q; ++i) {
		int x; scanf("%d", &x);
		++a[x];
	}
	for (int i = 1; i <= n; ++i) {
		a[i] += k - q;
		if (a[i] > 0) puts("Yes"); else puts("No");
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	long x,r=0;
	cin >> x;
	r += (x / 500)*1000;
	r += (x % 500 / 5) * 5;
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
struct UnionFind{
    vector<int> par;//親(根)
    vector<int> rank;//木の深さ

    UnionFind(int n){//初期化関数
        par.resize(n);
        rank.resize(n);
        for(int i = 0; i < n; i++){
            par[i] = i;//初めはノード一個の木なので根は自身
            rank[i] = 1;
        }
    }

    int root(int x){//木の根を求める
    if(par[x] == x) return x;
    else return par[x] = root(par[x]);
    }

    bool same(int x, int y){//同じ木かどうか判定
        return root(x) == root(y);//同じ木ならtrue
    }

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;//もし同じ木に属していたら何もしない
        if(rank[x] < rank[y]) swap(x, y);//数が大きい方に小さい方を結合させる
        par[y] = x;
        rank[x] += rank[y];//深さが同じ時だけ結合後深さが増える
    }

    int size(int x) {//深さを返す関数
        return rank[root(x)];
    }
};
int main(){
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    for(int i = 0; i < N; i++) cin >> x[i] >> y[i];
    vector<int> ind(N);
    for(int i = 0; i < N; i++) ind[i] = i;
    sort(ind.begin(), ind.end(), [&](int i, int j){
        return x[i] < x[j];
    });
    vector<int> yind(N);
    for(int i = 0; i < N; i++){
        yind[y[ind[i]] - 1] = ind[i];
    }
    UnionFind U(N);
    set<int> s;
    for(int i = 0; i < N; i++){
        int flag = 0;
        if(i == 0) s.insert(y[ind[i]]);
        else{
            set<int> st;
            for(auto v: s){
                if(v > y[ind[i]]) break;
                else{
                    int t = U.root(yind[v - 1]);
                    U.unite(yind[v - 1], ind[i]);
                    flag = 1;
                    if(U.root(yind[v - 1]) != t) st.insert(v);
                }
            }
            if(flag == 0) s.insert(y[ind[i]]);
            for(auto v: st) s.erase(v);
        }
    }
    for(int i = 0; i < N; i++){
        cout << U.size(i) << endl;
    }
}

Measured memory_bytes: 18148
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

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

    vector<int> a(n);

    rep(i,0,a.size())
    {
        cin>>a[i];
    }

    bool ok = true;
    int x = 0;

    rep(i,0,a.size())
    {
        if (ok)
        {
            x += a[i];
        }
        else
        {
            x -= a[i];
        }
        ok = !ok;
    }

    vector<int> ans;
    ans.pb(x);

    rep(i,1,n)
    {
        if ( i != n-1 )
        {
            ans.pb((2*a[i-1])-ans[i-1]);
        }
        else
        {
            ans.pb((2*a[i])-ans[0]);
        }
        
    }

    rep(i,0,ans.size())
    {
        cout<<ans[i]<<" ";
    }
    cout<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



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


const int N = 3e5 + 20;
const double pi = 3.141592653;
void fast()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    fast();
//cout<<fixed<<setprecision(6);
    ll n,m;
    string s;
    vector<string>v;
    vector<string>::iterator it=v.begin();
    cin>>n>>m;
    while(n--)
    {
        cin>>s;
        v.push_back(s);
    }
    sort(v.begin(),v.end());
    for(auto it:v)
    {
        cout<<it;

    }
}

























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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const int maxn = 2e5 + 5;

int lab[maxn], N;
int a[maxn], D;
vector<pair<ll, ii>> edge;

void init(int n)
{
  for(int i = 1; i <= n; ++i)
    lab[i] = -1;
}

int finds(int u)
{
  if(lab[u] < 0) return u;
  return lab[u] = finds(lab[u]);
}

bool merges(int u, int v)
{
  u = finds(u); v = finds(v);
  if(u == v) return false;
  if(lab[v] < lab[u]) swap(u, v);
  lab[u] += lab[v];
  lab[v] = u;
  return true;
}

void solve(int l, int r)
{
  if(l >= r) return;
  int mid = (l + r) / 2;
  solve(l, mid); solve(mid + 1, r);
  int minl = l, minr = mid + 1;
  for(int i = l; i <= mid; ++i)
    if(1ll * D * (mid - i) + a[i] < 1ll * D * (mid - minl) + a[minl])
      minl = i;
  for(int i = mid + 1; i <= r; ++i)
    if(1ll * D * (i - mid) + a[i] < 1ll * D * (minr - mid) + a[minr])
      minr = i;
  for(int i = l; i <= mid; ++i)
    edge.eb(1ll * D * (minr - i) + a[i] + a[minr], mp(i, minr));
  for(int i = mid + 1; i <= r; ++i)
    edge.eb(1ll * D * (i - minl) + a[i] + a[minl], mp(i, minl));
}

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  #endif // LOCAL
  cin >> N >> D;
  for(int i = 1; i <= N; ++i)
    cin >> a[i];
  solve(1, N);
  init(N);
  sort(edge.begin(), edge.end());
  ll res = 0;
  for(auto & all : edge){
    if(merges(all.se.fi, all.se.se)){
      res += all.fi;
    }
  }
  cout << res;
}


Measured memory_bytes: 68704
#include<iostream>
using namespace std;
int main(){
    int H,W,X;
    cin >> H >> W;
    int A[H][W];
    int b[W];
    int ANS[H];
    
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> A[i][j];
        }
        ANS[i]= 0;
    }
    for(int i=0;i<W;i++){
        cin >> b[i];
    }
    
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            ANS[i] = ANS[i] + A[i][j]*b[j];
        }
    }
    
    for(int i=0;i<H;i++){
        cout << ANS[i] << endl;
    }
    
}



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

public class Main {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int n = in.nextInt();
        long k = in.nextLong();
        MultiSet<Integer> ms = new MultiSet<>();
        TreeSet<Integer> set = new TreeSet<>();
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            ms.add(a, b);
            set.add(a);
        }
        for(int v: set) {
            long freq = ms.get(v);
            k -= freq;
            if(k <= 0) {
                System.out.println(v);
                return;
            }
        }
    }
}

@SuppressWarnings("serial")
class MultiSet<T> extends HashMap<T, Long>{
    @Override public Long get(Object key){return containsKey(key)?super.get(key):0L;}
    public void add(T key,long v){put(key,get(key)+v);}
    public void add(T key){put(key,get(key)+1);}
    public void sub(T key){final long v=get(key);if(v==1)remove(key);else put(key,v-1);}
    public MultiSet<T> merge(MultiSet<T> set)
    {MultiSet<T>s,l;if(this.size()<set.size()){s=this;l=set;}else{s=set;l=this;}
        for(Entry<T,Long>e:s.entrySet())l.add(e.getKey(),e.getValue());return l;}
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}


Measured memory_bytes: 52812
import math
a,b,x=map(int,input().split())
if x<=a*a*b/2:
    h=2*x/a/b
    print(math.degrees(math.atan(b/h)))
else:
    h=2*(a*a*b-x)/a/a
    print(math.degrees(math.atan(h/a)))

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

bool del(vector<vector<char>> &g, int &h, int &w) {
  for(int i=0; i<h; i++) {
    bool f = true;
    for(int j=0; j<w; j++) {
      if(g.at(i).at(j) == '#') {
        f = false;
      }
    }
    if(f) {
      for(int j=i; j<h-1; j++) {
        for(int k=0; k<w; k++) {
          g.at(j).at(k) = g.at(j+1).at(k);
        }
      }
      g.pop_back();
      h--;
      return true;
    }
  }
  for(int i=0; i<w; i++) {
    bool f = true;
    for(int j=0; j<h; j++) {
      if(g.at(j).at(i) == '#') {
        f = false;
      }
    }
    if(f) {
      for(int j=0; j<h; j++) {
        for(int k=i; k<w-1; k++) {
          g.at(j).at(k) = g.at(j).at(k+1);
        }
        g.at(j).pop_back();
      }
      w--;
      return true;
    }
  }
  return false;
}
  

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> g(h, vector<char>(w));
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      cin >> g.at(i).at(j);
    }
  }
  while(del(g, h, w));
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      cout << g.at(i).at(j);
    }
    cout << endl;
  }
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
lli ans = LONG_MAX;

int main(){
  cin >> n;
  for(lli i = 1;i < n;i++){
    lli b = n-i;
    lli a = i;
    lli mem = 0;
    while(a > 0){
      mem += a%10;
      a /= 10;
    }
    while(b > 0){
      mem += b%10;
      b /= 10;
    }
    ans = min(ans, mem);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define fast  ios_base::sync_with_stdio(0); cin.tie(0);
#define f(i,k) for(i=0;i<k;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define input(i,n,arr) for(i=0;i<n;i++) cin>>j, arr.push_back(j)
#define vect_ll vector<long long>
#define vect_ll_it vector<long long>::iterator
#define pb(p) push_back(p)
#define endl "\n"
#define mod 1000000007
const ll inf = 1e18;
ll i, j, k, n, m, x, y, p, q, dp[101][100001];
#define v 100000
int main()
{
	fast
	int t = 1;
	//cin >> t;
	while (t--)
	{
		ll w;
		cin >> n >> w;
		ll a[n + 1][2];
		for (i = 0; i < n; i++) for (j = 0; j < 2; j++) cin >> a[i][j];
		f(i, n + 1) f(j, v + 1) dp[i][j] = inf;
		dp[0][0] = 0;
		for (i = 1; i <= n; i++)
		{
			for (j = 0; j <= v; j++)
			{
				if (j == 0)
				{
					dp[i][j] = 0;
					continue;
				}

				if (a[i - 1][1] > j) dp[i][j] = dp[i - 1][j];
				else dp[i][j] = min(dp[i - 1][j], a[i - 1][0] + dp[i - 1][j - a[i - 1][1]]);
			}

			//cout << dp[i][90099] << " ";
			//cout << endl;
		}
		for (i = v; i >= 0; i--) if (dp[n][i] <= w) break;
		cout << i << endl;
	}
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}


Measured memory_bytes: 82500
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
double dp[2][210];
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> t(n), v(n);
    for (int i = 0; i < n; i++) cin >> t[i];
    for (int i = 0; i < n; i++) cin >> v[i];
    for (int i = 0; i <= 206; i++) {
        dp[0][i] = -1;
        dp[1][i] = -1;
    }
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < t[i] * 2; j++) {
            for (int k = 0; k <= v[i] * 2; k++) {
                if (k < v[i] * 2 && dp[0][k + 1] != -1) {
                    dp[1][k] = max(dp[1][k], dp[0][k + 1] + (k + 0.5) * 0.25);
                }
                if (dp[0][k] != -1) {
                    dp[1][k] = max(dp[1][k], dp[0][k] + k * 0.25);
                }
                if (k > 0 && dp[0][k - 1] != -1) {
                    dp[1][k] = max(dp[1][k], dp[0][k - 1] + (k - 0.5) * 0.25);
                }
            }
            for (int k = 0; k <= 206; k++) {
                dp[0][k] = dp[1][k];
                dp[1][k] = -1;
            }
        }
    }
    cout << fixed << setprecision(10) << dp[0][0] << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split(" "))
 
student = [];
pos = [];
for i in range(N) :
	a, b = map(int, input().split(" "))
	student.append((a, b))
 
for i in range(M) :
	a, b = map(int, input().split(" "))
	pos.append((a,b))
 
for st in student :
	ans = -1;
	score = 10**10;
	for i in range(M) :
		tmpscore = abs(st[0] - pos[i][0]) + abs(st[1] - pos[i][1])
		if score > tmpscore :
			score = tmpscore;
			ans = i;
	print(ans+1);

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define X first
#define Y second
using namespace std;
const int MAX = 394; 
int dp[394];

void DP(int amount, int v){
	for(int i = 1; i < MAX; i++){
		if(amount <= i && dp[i-amount]) dp[i] = dp[i-amount]+v>dp[i] ? dp[i-amount]+v : dp[i];
	}
}

int main(){
	int n;
	cin >> n;
	fill(dp, dp+MAX, 0);
	while(n--){
		int up, down, v;
		cin >> down >> up >> v;
		while(down <= MAX){
			if(up>=MAX) up = MAX-1;
			for(int i = down; i <= up; i++) dp[i] = dp[i]<v?v:dp[i];
			for(int i = 0; i < 2; i++){
				if(i) DP(up, v);
				else DP(down, v);
			}
			up += up;
			down += down;
			v += v;
		}
	}
	int m;
	cin >> m;
	vector<int> ans;
	while(m--){
		int input;
		cin >> input;
		if(dp[input]) ans.push_back(dp[input]);
		else{
			cout << "-1" << endl;
			return 0;
		}
	}
	for(int i = 0; i < ans.size(); i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    using namespace __gnu_pbds;
    using namespace std;
     
    #define ff              first
    #define ss              second
    #define int             long long
    #define pb              push_back
    #define mp              make_pair
    #define pii             pair<int,int>
    #define vi              vector<int>
    #define mii             map<int,int>
    #define pqb             priority_queue<int>
    #define pqs             priority_queue<int,vi,greater<int> >
    #define setbits(x)      __builtin_popcountll(x)
    #define zrobits(x)      __builtin_ctzll(x)
    #define mod             1000000007
    #define inf             1e18
    #define ps(x,y)         fixed<<setprecision(y)<<x
    #define mk(arr,n,type)  type *arr=new type[n];
    #define w(x)            int x; cin>>x; while(x--)
    #define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
     
    typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
     
    int32_t main()
    {
    	FIO;
     
    	int n, k; cin >> n >> k;
    	mk(arr, n, int);
    	for (int i = 0; i < n; i++)
    		cin >> arr[i];
     
    	int state[k + 1] = {};
     
    	for (int i = k - 1; i >= 0; i--) {
    		int curr_state = 1;
    		for (int j = 0; j < n; j++) {
    			if (i + arr[j] <= k)
    				curr_state &= state[i + arr[j]];
    			else
    				break;
    		}
     
    		state[i] = !curr_state;
    	}
     
    	if (state[0])
    		cout << "First" << endl;
    	else
    		cout << "Second" << endl;
     
    	return 0;
    }

Measured memory_bytes: 4428
let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let tas = Array.init n (fun _ -> Scanf.scanf "%d %d\n" (fun t a -> t, a)) in
  Array.fold_left (fun (x, y) (t, a) ->
    let n = max ((x + t - 1) / t) ((y + a - 1) / a) in
    (t * n, a * n)) (1, 1) tas
  |> (fun (x, y) -> x + y)
  |> Printf.printf "%d\n"

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_set>

using namespace std;

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;

  int ans = 0;
  unordered_set<char> set;
  for (int i = 1; i < n; ++i) {
    set.clear();

    for (int j = 0; j < i; ++j) {
      set.insert(s[j]);
    }
    int c = 0;
    for (int j = i; j < n; ++j) {
      if (set.find(s[j]) != set.end()) {
        ++c;
        set.erase(s[j]);
      }
    }
    ans = max(ans, c);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a,b,x=0,y=0;
	scanf("%d %d", &a, &b);
	for(int i = 1; i < a; i++){
		x+=i;
	}
	for(int j = 1; j < b; j++){
		y+=j;
	}
	printf("%d", x + y);
	return 0;
}

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

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

    switch(n % 10)
    {
        case 0:
        case 1:
        case 6:
        case 8: cout << "pon" << endl;
        break;

        case 2:
        case 4:
        case 5:
        case 7:
        case 9: cout << "hon" << endl;
        break;

        case 3: cout << "bon" << endl;
        break;
    }

    return 0;
}

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

using namespace std;

#define FaSt ios::sync_with_stdio(0),cin.tie(0);
#define random uniform_int_distribution<long long>(1, 2000000000000000LL)(rng)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() * ((uint64_t) new char | 1));

const int N = 100005;
int n, k, a[N], dp[N];
bool solved[N];

int calc(int i)
{
    if (solved[i])
    {
        return dp[i];
    }
    
    if (i == n - 1)
    {
        return 0;
    }
    
    dp[i] = 1e9;
    for (int j = 0; j < k; j++)
    {
        if (i + j + 1 <= n - 1)
        {
            dp[i] = min(dp[i], calc(i + j + 1) + abs(a[i] - a[i + j + 1]));
        }
    }
    
    solved[i] = 1;
    return dp[i];
}

int main() 
{
    FaSt
    cin >> n >> k;
    
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    cout << calc(0);
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[11][11];
    int i,j,n,d,ans,chek,cnt=0;
    cin>>n>>d;
    for(i=0;i<n;i++){
        for(j=0;j<d;j++) cin>>a[i][j];
    }
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            ans=0;
            for(int k=0;k<d;k++){
                ans+=((a[i][k]-a[j][k])*(a[i][k]-a[j][k]));
            }
            chek=sqrt(ans);
            if(chek*chek==ans) cnt++;
        }
    }
    cout<<cnt;
}


Measured memory_bytes: 3560
a,b,c=map(int,input().split())
aa,bb,cc=a%2,b%2,c%2
def check(a,b,c):
    max_=max(a,b,c)
    ans=((max_-a)//2)+((max_-b)//2)+((max_-c)//2)
    return ans
if aa==bb==cc:
    print(check(a,b,c))
else:
    if aa==bb and aa!=cc:
        print(check(a+1,b+1,c)+1)
    elif cc==bb and aa!=cc:
        print(check(a,b+1,c+1)+1)
    else:
        print(check(a+1,b,c+1)+1)

Measured memory_bytes: 3064
import heapq

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

edges = [[] for _ in range(n)]
for a,b,dis in abc:
    edges[a-1].append((b-1, dis))
    edges[b-1].append((a-1, dis))

def dijkstra(edges, s):
    hq = []
    d = [-1] * n
    d[s] = 0
    heapq.heappush(hq, (0, s))
    while hq:
        d1, p = heapq.heappop(hq)
        for p2, d2 in edges[p]:
            if d[p2] == -1 or d[p2] > d1 + d2:
                d[p2] = d1 + d2
                heapq.heappush(hq, (d1+d2, p2))
    return d

d = []

for i in range(n):
    d.append(dijkstra(edges, i))

ans = 0

for a,b,dis in abc:
    if dis > d[a-1][b-1]:
        ans += 1

print(ans)


Measured memory_bytes: 76256
#include <iostream>

int main()
{
    int N;
    std::cin >> N;
    int count1 = 0, count2 = 0, count4 = 0;
    for(int i=0; i<N; i++){
        int tmp;
        scanf(" %d", &tmp);
        if(tmp % 4 == 0) count4++;
        else if(tmp % 2 == 0) count2++;
        else count1++;
    }

    if(N % 2 == 1 && (N-1)/2 <= count4){
        std::cout << "Yes" << std::endl; return 0;
    }

    if(count1 <= count4) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
}

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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

template <class Monoid>
struct SegTree {
    using Func = function<Monoid(Monoid, Monoid)>;
    const Func F;
    const Monoid UNITY;
    int SIZE_R;
    vector<Monoid> dat;

    SegTree(int n, const Func f, const Monoid &unity) : F(f), UNITY(unity) { init(n); }
    void init(int n) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2, UNITY);
    }

    /* set, a is 0-indexed */
    void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; }
    void build() {
        for (int k = SIZE_R - 1; k > 0; --k)
            dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }

    /* update a, a is 0-indexed */
    void update(int a, const Monoid &v) {
        int k = a + SIZE_R;
        dat[k] = v;
        while (k >>= 1) dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }

    /* get [a, b), a and b are 0-indexed */
    Monoid get(int a, int b) {
        Monoid vleft = UNITY, vright = UNITY;
        for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
            if (left & 1) vleft = F(vleft, dat[left++]);
            if (right & 1) vright = F(dat[--right], vright);
        }
        return F(vleft, vright);
    }
    inline Monoid operator[](int a) { return dat[a + SIZE_R]; }

    /* debug */
    void print() {
        for (int i = 0; i < SIZE_R; ++i) {
            cout << (*this)[i];
            if (i != SIZE_R - 1) cout << ",";
        }
        cout << endl;
    }
};

void solve(long long N, std::vector<long long> h, std::vector<long long> a) {

    SegTree<int> seg(
        N + 1, [](int a, int b) { return max(a, b); }, 0LL);

    for (int i = N - 1; i >= 0; i--) {
        auto m = seg.get(h[i], N + 1);
        seg.update(h[i], a[i] + m);
    }

    cout << seg.get(0, N + 1) << endl;
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    long long N;
    scanf("%lld", &N);
    std::vector<long long> h(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &h[i]);
    }
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &a[i]);
    }
    solve(N, std::move(h), std::move(a));
    return 0;
}


Measured memory_bytes: 7552
#include <stdio.h>
int main(){

  int a,b,i;

  while(scanf("%d %d",&a,&b) !=	EOF){

    a += b;

    for(i = 0; a/10 != 0; i++) a /= 10;

    printf("%d\n",i+1);

  }

  return 0;

}

Measured memory_bytes: 600
// Contest: AtCoder Beginner Contest 147 (https://atcoder.jp/contests/abc147)
// Problem: C: HonestOrUnkind2 (https://atcoder.jp/contests/abc147/tasks/abc147_c)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    int n; cin >> n;
    vector<vpi> t(n);
    rep(i, n) {
        int ai; cin >> ai;
        t[i].resize(ai);
        trav(p, t[i])
            cin >> p.first >> p.second, p.first--;
    }

    int mx = 0;
    for (u32 m = 1; m < (1u << n); ++m) {
        auto m2 = m;
        bool pos = true;
        while (m2) {
            int i = __builtin_ctz(m2); m2 &= m2 - 1;
            trav(p, t[i])
                pos &= ((m >> p.first) & 1u) == p.second;
        }
        if (pos)
            mx = max(mx, __builtin_popcount(m));
    }

    cout << mx << '\n';
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int n;
  int d;
  cin>>n>>d;
  int x=2*d+1;
  cout<<(n+x-1)/x<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
void maxm(int a, int b)
{
	int k=1;
	while (1)
	{
		k = a % b;
		if(k==0)break;
		a = b;
		b = k;
	}
	cout << b << endl;
}

int main()
{
	int a, b;
	cin >> a >> b;
	if(a > b) maxm(a, b) ;
	else maxm(b, a);
	return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int H, W;
  cin >> H >> W;
  VS vs(H);
  REP(y,H) cin >> vs[y];

  VVI xs(H-1, VI(W-1));
  REP(y,H-1) REP(x,W-1){
	int s = 0;
	REP(dy,2) REP(dx,2) if(vs[y+dy][x+dx] == '#') ++s;
	if(s%2 == 0) xs[y][x] = 1 + (y>0? xs[y-1][x]: 0);
  }

  //REP(y,H-1){REP(x,W-1)cout<<xs[y][x]<<" ";cout<<endl;}

  int ans = max(H, W);
  REP(y,H-1){
	stack<PII> s;
	REP(x,W-1){
	  int lx = x;
	  while(!s.empty() && s.top().FF > xs[y][x]){
		maxi(ans, (s.top().FF+1)*(x-s.top().SS+1));
		lx = s.top().SS;
		s.pop();
	  }
	  if(xs[y][x]) s.emplace(xs[y][x], lx);
	}
	while(!s.empty()){
	  maxi(ans, (s.top().FF+1)*(W-s.top().SS));
	  s.pop();
	}
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 20224
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

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

  return 0;
}


Measured memory_bytes: 256
from operator import itemgetter

n, m = map(int, input().split())

# 区間の終端でソート
ab = sorted([tuple(map(int, input().split())) for i in range(m)], key=itemgetter(1))
# 前回除いた橋
removed = -1
ans = 0

for a, b in ab:
    # a が removed より大きい = まだ取り除いてない
    if a > removed:
        removed = b - 1
        ans += 1

print(ans)

Measured memory_bytes: 24776
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	h := scanInt()

	ans := 0
	count := 0
	for i := 0; i < n-1; i++ {
		next := scanInt()
		if h >= next {
			count++
		} else {
			count = 0
		}

		if count > ans {
			ans = count
		}
		h = next
	}

	fmt.Println(ans)
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N;
    scan(N);
    vector<ll> v(N);
    scan(v);

    vector<vector<ll>> dp(N + 1, vector<ll>(2));
    dp[0][0] = 0;
    dp[0][1] = -INF64;
    FOR(i, 1, N + 1) {
        dp[i][0] = max(dp[i - 1][0] + v[i - 1], dp[i - 1][1] - v[i - 1]);
        dp[i][1] = max(dp[i - 1][0] - v[i - 1], dp[i - 1][1] + v[i - 1]);
    }
    print(dp[N][0]);

    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>

using ll = long long;

int main() {
    int N;
    std::cin >> N;
    std::vector<int> a(N);
    for (int i = 0; i < N; i++) {
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end());

    std::cout << a[N - 1] - a[0] << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	long long int a, b, c;
	int j=0, n;
	while(scanf("%lld%lld", &a, &b)!=EOF) {
		for(c=a+b; c>0; c/=10)
			j++;
		printf("%d\n", j);
		j=0;
	}
	return 0;
}


Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

ll calc_num(ll n, ll front, ll back){
    ll pw = 6;
    ll ret = 0;
    n -= back;
    while (pw >= 1){
        ll shita = pow(10, pw)*front;
        if (shita > n){
            pw--;
            continue;
        }
        ret += min(1 + (n - shita)/10, ll(pow(10, pw-1)));
        pw--;
    }
    return ret;
}



int main(void){
    ll n; cin >> n;
    ll ans = 0;
    for (int front_a=1; front_a<10; front_a++){
        for (int front_b=1; front_b<10; front_b++){
            ll a_num = calc_num(n, front_a, front_b);
            ll b_num = calc_num(n, front_b, front_a);
            if (front_a==front_b && front_a <= n){
                a_num++;
                b_num++;
            }
            ans += a_num * b_num;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	ll n,k;
	cin >> n >> k;
	vector<ll> arr(n);
	for(ll i=0;i<n;i++)
		cin >> arr[i];
	sort(arr.begin(),arr.end());
	ll i = min(n,k);
	i = n - 1 - i;
	ll sum = 0;
	for(;i>=0;i--)
		sum += arr[i];
	cout << sum;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int a, num = 0, maxn = 0;
    char s[100];
    cin >> a;
    cin >> s;
    for (int i = 0; i < a; i++)
    {
        if (s[i] == 'I')
        {
            num++;
        }
        else num--;
        maxn = max(num, maxn);
    }
    cout << maxn << endl;
}

Measured memory_bytes: 256