akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int f(int x){
    return x*100+x*10+x;
}

int main(void){
    // Your code here!
    int x,y;
    scanf("%d\n",&x);
    y=x/100;
    if(x%100>y*10+y) y++;
    printf("%d\n",f(y));
    
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"

int32_t main(){
	boost;
	int n;
	cin >> n;
	vector <int > g[n + 1];
	for(int i = 1,u ,v; i < n; i++) {
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	vector< int > a(n);
	int tot = 0;
	for(int &i : a){
		cin >> i;
		tot += i;
	}
	sort(a.rbegin(), a.rend());
	tot -= a[0];

	int ans[n+1] = {0};
	int l = 0;
	function < void (int , int) > dfs = [&] (int u, int p) {
		ans[u] = a[l++];
		for(int v:g[u]) {
			if(v == p)
				continue;
			dfs(v, u);
		}
	};

	dfs(1,0);
	cout << tot << endl;
	for(int i = 1; i <= n; i++)
		cout << ans[i] << " ";
}



Measured memory_bytes: 5200
#include<stdio.h>
#include<stdlib.h>
int comp(const void *a,const void *b){
	return *(long long int *)a - *(long long int *)b;
}
int main(){
	long long int n,a[10005],i,ans;
	while(scanf("%lld",&n)!=EOF){
		if(n==0)break;
		for(i=0;i<n;i++)scanf("%lld",&a[i]);
		qsort(a,n,sizeof(long long int),comp);
		ans=0;
		for(i=0;i<n-1;i++)ans+=a[i]*(n-i-1);
		printf("%lld\n",ans);
	}
	return 0;
}

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

int main(){
    int i, l, n, flag;
    string s;
    string t;
    cin >> n >> s >> t;
    for(i = 0; i < n; i++){
        int k = i;
        flag = 1;
	l = 0;
        while(k < n && l < n){
		if(s[k] == t[l]){
			k++;
			l++;
			continue;
		}else{
			flag = 0;
			break;
		}
	}
        if(flag == 1){
            break;
        }
    }
    cout << i+t.size() << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-9;
int a[1010];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    int minn=1e9*2;
    for(int i=-100;i<=100;i++)
    {
        int ans=0;
        for(int j=1;j<=n;j++)
        {
            ans+=(a[j]-i)*(a[j]-i);
        }
        minn=min(minn,ans);
    }
    printf("%d\n",minn);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int 
#define MOD 1000000007
#define fi(i,a,n) for(lli i = a; i < n; i++)
#define fd(i,a,n) for(lli i = a; i > n; i--)
#define fv(i,a) for(auto i:a)
#define pb push_back
#define mp make_pair

lli dp[1000000];

lli cost(lli i,lli arr[],lli n,lli last)
{
	if(dp[i]!=-1)
		return dp[i];
	if(i==n-2)
	{
		dp[i]=min(abs(arr[i-1]-arr[i])+abs(arr[i]-arr[i+1]),abs(arr[i-1]-arr[i+1]));
		return dp[i];
	}
	if(i==n-1)
		return abs(last-arr[i]);
	dp[i]=min(abs(last-arr[i])+cost(i+1,arr,n,arr[i]),abs(last-arr[i+1])+cost(i+2,arr,n,arr[i+1]));
	return dp[i];
}

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

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
lli t=1;
//cin>>t;
while(t--)
{
	lli n;
	cin>>n;
	lli arr[n];
	fi(i,0,n)
	cin>>arr[i];
	memset(dp,-1,sizeof(dp));
	dp[0]=arr[0];
	cout<<cost(1,arr,n,arr[0]);
}
return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N;
int a[MAXN],b[MAXN],tot;
int sta[MAXN],top;
pii p[MAXN * 2];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {
	read(a[i]);
	p[++tot] = mp(a[i],0);
    }
    for(int i = 1 ; i <= N ; ++i) {
	read(b[i]);
	p[++tot] = mp(b[i],1);
    }
    sort(p + 1,p + tot + 1);
    int ans = 1;
    for(int i = 1 ; i <= tot ; ++i) {
	if(top && sta[top] != p[i].se) {
	    ans = mul(ans,top);
	    --top;
	}
	else sta[++top] = p[i].se;
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 2944
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll n, m;
	cin >> n >> m;
	vector<ll> a(n + 1);
	repn(i, 1, n + 1) cin >> a[i];
	vector<ll> sum(n + 1, 0);
	sum[0] = 0;
	map<ll, ll> cnt;
	repn(i, 1, n + 1) sum[i] = sum[i - 1] + a[i];
	ll ans = 0;
	cnt[0]++;
	for(ll i = 1; i <= n; i++){
		ll md = sum[i] % m;
		ans += cnt[md];
		cnt[md]++;
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 5760
N=int(input())
A=list(map(int,input().split()))
ans=[]
B=0
P=0
if abs(max(A))>=abs(min(A)):
    #print("A")
    B=max(A)
    for i in range(N):
        if A[i]==max(A):
            B=A[i]
            P=i
    for i in range(1,N):
        if A[i-1]<=A[i]:
            pass
        else:
            A[i]+=B
            ans.append([P+1,i+1])
            if B<A[i]:
                B=A[i]
                P=i
            if A[i-1]<=A[i]:
                pass
            else:
                A[i]+=B
                ans.append([P+1,i+1])
                if B<A[i]:
                    B=A[i]
                    P=i
    print(len(ans))
    for i in range(len(ans)):
        print(ans[i][0],ans[i][1])
else:
    B=min(A)
    for i in range(N):
        if A[i]==min(A):
            B=A[i]
            P=i
    #print(B,P)
    for i in range(N-1):
        #print(A,B)
        if A[N-2-i]<=A[N-1-i]:
            pass
        else:
            A[N-2-i]+=B
            ans.append([P+1,N-1-i])
            if B>A[N-2-i]:
                B=A[N-2-i]
                P=N-2-i
            if A[N-2-i]<=A[N-i-1]:
                pass
            else:
                A[N-2-i]+=B
                ans.append([P+1,N-1-i])
                if B>A[N-2-i]:
                    B=A[N-2-i]
                    P=N-2-i
    print(len(ans))
    for i in range(len(ans)):
        print(ans[i][0],ans[i][1])
#print(A)

Measured memory_bytes: 3192
#include<iostream>
#include<atcoder/all>
using namespace std;
typedef long long li;
#define MAX 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

// pair 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const pair<T,S>& p){
  cout << "(" << p.first << "," << p.second << ")";
  return os;
}


int main(){
  int n,k; cin >>n >>k;
  int s=2*n;
  atcoder::mcf_graph<int,li> g(s+2);
  g.add_edge(s,s+1,n*k,MAX);
  rep(i,n){
    g.add_edge(s,i,k,0);
    g.add_edge(i+n,s+1,k,0);
    if(df)print("",s,i,"\n",i+n,s+1);
  } 
  rep(i,n) rep(j,n){
    li a; cin >>a;
    g.add_edge(i,n+j,1,MAX-a);
    if(df)print(i,n+j,MAX-a);
  }
  // vector<pair<int,li>> v=g.slope(s,s+1);
  // int t=v.size(),mi=0;
  // rep(i,t){
  //   print(v[i]);
  //   v[i].second=(li)MAX*v[i].first-v[i].second;
  //   print("->",v[i]);
  //   if(v[mi].second<v[i].second) mi=i;
  // }
  
  // t=v[mi].first;
  // if(df)print(mi,t);
  
  pair<int,li> p=g.flow(s,s+1,n*k);
  if(df)print(p);
  p.second=(li)MAX*n*k-p.second;
  print(p.second);
  vector<string> ans(n);
  rep(i,n) rep(j,n) ans[i].push_back('.');
  vector<atcoder::mcf_graph<int,li>::edge> es=g.edges();
  for(auto x: es){
    if(x.from==s or x.to==s+1 or x.flow==0) continue;
    ans[x.from][x.to-n]='X';
    if(df)print(x.from,x.to);
    //if(df)print(ans[x.from]);
  }
  rep(i,n){
    for(char c:ans[i]) printf("%c",c);
    print("");
  }
}


Measured memory_bytes: 3964
#include <algorithm>
#include <chrono>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>

using namespace std;

const char LEFT = '<';
const char RIGHT = '>';

string s;
vector<int> a;

void Solve()
{
    const int n = s.length();
    a.assign(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        int j = i;
        while (j < n && s[j] == RIGHT) {
            ++j;
        }
        for (int k = i; k < j; ++k) {
            assert(a[k] == 0);
            a[k] = j - k;
        }
        i = j;
    }
    for (int i = 0; i < n; ++i) {
        int j = i;
        while (j < n && s[j] == LEFT) {
            ++j;
        }
        for (int k = i; k < j; ++k) {
            assert(a[i] == 0);
            a[k + 1] = max(a[k + 1], k + 1 - i);
        }
        i = j;
    }
    long long sum = 0;
    for (auto v : a) {
        sum += v;
    }
    cout << sum << endl;
}

bool Read()
{
    if (!(cin >> s)) {
        return false;
    }
    return true;
}

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

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

    while (Read()) {
        Solve();
    }

    return 0;
}


Measured memory_bytes: 5352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

ll gcd(ll a, ll b)
{
	if (a < b) swap(a, b);
	return (a%b ? gcd(a%b, b) : b);
}

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

void extgcd(ll a, ll b, ll& x, ll& y)
{
	if (b != 0) { extgcd(b, a % b, y, x); y -= a / b * x; }
	else { x = 1; y = 0; }
}


int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, k; cin >> n >> k;
	vi a(n); cin >> a;
	ll g = a[0];
	REP(i, n) g = gcd(g, a[i]);
	bool f = false;
	REP(i, n)
	{
		if (k <= a[i] && (k - a[i]) % g == 0) f = true;
	}
	cout << (f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}

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

int main(){
  long a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  long dist=max(a,b)-min(a,b);
  long speed=v-w;
  if(dist>speed*t) cout<<"NO";
  else cout<<"YES";
}


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

int main(){
    int n;
    cin>>n;
    int mod=n%10;
    if(mod==3) cout<<"bon";
    else if(mod==0 || mod==1 ||mod==6 ||mod==8) cout<<"pon";
    else cout<<"hon";
}

Measured memory_bytes: 3640
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




int main() {
    int h, w;
    cin >> h >> w;
    string s[h];
    REP(i, h){
        cin >> s[i];
    }
    REP(i, h){
        REP(j, w){
            if(s[i][j] == '#'){
                bool ok = false;
                if(i > 0){
                    if(s[i - 1][j] == '#'){
                        ok = true;
                    }
                }
                if(i < h - 1){
                    if(s[i + 1][j] == '#'){
                        ok = true;
                    }
                }
                if(j > 0){
                    if(s[i][j - 1] == '#'){
                        ok = true;
                    }
                }
                if(j < w - 1){
                    if(s[i][j + 1] == '#'){
                        ok = true;
                    }
                }
                if(!ok){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)

using namespace std;

int main(){
	int an,bn,r;
	int flyX[100001];
	int flyY[100001];
	int px,py;
	vector<int> energy[10001];
	int sum;
	while(cin>>an>>bn>>r&&!(an==0&&bn==0&&r==0)){
		for(int i = 0; i < 10001; i++)
			energy[i].clear();
		for(int i = 0; i < an; i++)
			cin>>flyX[i]>>flyY[i];
		for(int i = 0; i < bn; i++){
			cin>>px>>py;
			energy[px].push_back(py);
		}
		for(int i = 0; i < 10001; i++)
			sort(energy[i].begin(),energy[i].end());
		sum=0;
		for(int i = 0; i < an; i++){
			int minx=max(0,flyX[i]-4*r);
			int maxx=min(9999,flyX[i]+4*r);
			for(int j = minx; j <= maxx; j++){
				if(energy[j].empty())
					continue;
				int ovlimit=(int)(sqrt((double)(-((flyX[i]-j)*(flyX[i]-j))+16*r*r))+flyY[i]+EPS);
				double lolimit2=(-sqrt((double)(-((flyX[i]-j)*(flyX[i]-j))+16*r*r))+flyY[i]);
				int lolimit=(int)(lolimit2+EPS);
				if(!EQ(lolimit2,(int)lolimit2))
					lolimit++;
				sum+=(upper_bound(energy[j].begin(),energy[j].end(),ovlimit)
					-lower_bound(energy[j].begin(),energy[j].end(),lolimit));
			}
		}
		cout<<sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 3156
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
ii0 = lambda: ii() - 1
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    N, K = mis()
    A = lmis()
    A.sort(reverse=True)
    F = lmis()
    F.sort()
    #
    class solver:
        def __getitem__(self, score_limit):
            k = K
            for i in range(N):
                if A[i]*F[i] > score_limit:
                    k -= A[i] - score_limit//F[i]
                    if k < 0:
                        return False
            return True
    #
    import bisect
    print(bisect.bisect_left(solver(), True, hi=A[0]*F[-1]))

main()


Measured memory_bytes: 119500
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int a,b,x;
	cin >> a >> b >> x;
	double z=(double)180/M_PI;
	double theta;
	double ans;

	if(x==a*a*b){
		cout << 0 << endl;
		return 0;
	}else	if(x<a*a*b/2){
		theta = atan2(2*x,(a*b*b));
		ans=theta*z;
		if(ans<0) ans*=-1;
		if(ans>90) ans=ans-90;
		ans=90-ans;
	}else{
		theta = atan2(a*a*a,(2*(a*a*b-x)));
		ans=theta*z;
		if(ans<0) ans*=-1;
		if(ans>90) ans=ans-90;
		ans=90-ans;
	}

	cout << std::setprecision(12) << ans << endl;

	return 0;
}

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

int main(){
  
  int n,x; cin>>n>>x;
  vector<int>a(n);
  for(auto &i:a)cin>>i;
  a.push_back(x);
  sort(a.begin(),a.end());
  vector<int> b(n);
  for(int i=0; i<n; i++){
    b.at(i) = a.at(i+1)-a.at(i);
  }
  int ans = b.at(0);
  for(int i=0; i<n-1; i++){
    ans = gcd(ans,b.at(i+1));
  }
  cout << ans << endl;
}



Measured memory_bytes: 4040
#include <iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int j = 0;
	while (n > 0) {
		if (n % 10 == 7) {
			cout << "Yes" << endl;
			j = 1;
			break;
		}
		else {
			n /= 10;
		}
	}
	if (j == 0) {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
N = int(input())
words = [[] for i in range(N)]
for i in range(N):
  s = input()
  l = []
  for t in s:
    l.append(t)
  l.sort()
  words[i] = l
words.sort()
#print(words)
materials = [1]
for i in range(1, N):
  if words[i] == words[i-1]:
    materials[-1] += 1
  else:
    materials.append(1)
print(sum([i * (i-1) // 2 for i in materials]))

Measured memory_bytes: 26080
from sys import stdin
import sys
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7
input = stdin.readline

H, W, A, B = [int(x) for x in input().rstrip().split()]

factorial = [1]
for i in range(1, H+W):
	factorial.append(factorial[i-1] * i % mod)

def power(x, y):
	if y == 0:
		return 1
	elif y == 1:
		return x % mod
	elif y % 2 == 0:
		return power(x, int(y/2)) ** 2 % mod
	else:
		return power(x, int((y-1)/2)) ** 2 * x % mod
def C(n, r):
	return (((factorial[n] * x_inv[r]) % mod) * x_inv[n-r]) % mod
# x_inv = []
# for i in range(H+W):
# 	x_inv.append(power(factorial[i], mod-2))

x_inv = [0] * (H+W)
x_inv[-1] = power(factorial[-1], mod-2)
for i in range(H+W-2, -1, -1):
	x_inv[i] = x_inv[i+1] * (i+1) % mod

sum = 0
for i in range(B, W):
	sum += C(i+H-A-1, i) * C(A+W-i-2, A-1) % mod
print(sum%mod)


Measured memory_bytes: 18964
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int x,h=0;
    cin>>x;
    if(x==0){
        cout<<0<<endl;
    }
    else{
    long long int f=x/500;
    h+=f*1000;
    long long int ff=(x%500)/5;
    h+=ff*5;
    cout<<h<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

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

    int n;
    cin >> n;

    stack<int> st;
    st.push(3);
    st.push(5);
    st.push(7);
    vector<int> ans;
    vector<int> a = {3, 5, 7};
    while(not st.empty()){
        int x = st.top();
        st.pop();

        if(x > n){
            continue;
        }
        ans.push_back(x);

        rep(i, 3){
            st.push(x * 10 + a[i]);
        }
    }

    int cnt = 0;
    for(int x : ans){
        bool is[8] = {};

        while(x != 0){
            is[x%10] = true;
            x /= 10;
        }

        if(is[3] && is[5] && is[7]){
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <numeric>

//#include <map>

using namespace std;

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

	vector<long> vData;

	for (long i = 0; i < n; i++)
	{
		int t;
		cin >> t;
		vData.push_back(t);
	}

	cout << *min_element(vData.begin(), vData.end()) << " " <<
			*max_element(vData.begin(), vData.end()) << " " <<
			accumulate(vData.begin(), vData.end(), 0L) <<
			endl;
	return 0;
}

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

signed main(){
  int k, a, b;
  cin >> k >> a >> b;

  if(a % k == 0 || b % k == 0){
    cout << "OK" << endl;
    return 0;
  }
  if(((a / k) + 1) * k <= b){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3596
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
 
public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        int mondaiCount = int.Parse(Reader.ReadLine());
        int[] time = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray();

        int total = time.Sum();

        int drinkCount = int.Parse(Reader.ReadLine());

        int[] timeDiff = new int[drinkCount];
        for(int i=0; i<drinkCount; i++) {
            int[] inpt = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray();
            timeDiff[i] = time[inpt[0]-1] - inpt[1];
        }

        StringBuilder ans = new StringBuilder();
        foreach(int df in timeDiff) {
            ans.AppendLine((total-df).ToString());
        }
        Console.Write(ans.ToString());

    }

    public class Reader {
        public static bool IsDebug = true;
        private static System.IO.StringReader SReader;
        private static string InitText = @"


5
7 2 3 8 5
3
4 2
1 7
4 13



";
        public static string ReadLine() {
            if(IsDebug) {
                if(SReader == null) {
                    SReader = new System.IO.StringReader(InitText.Trim());
                }
                return SReader.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 2904
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]

C = [0] * (N + 1)
S = [0] * (N + 1)

for a in Counter(A).values() :
    C[a] += 1
    S[a] += a

for i in range(1, N + 1) :
    C[i] += C[i-1]
    S[i] += S[i-1]

for K in range(1, N + 1) :
    ok, ng = 0, N + 1
    while ng - ok > 1 :
        mid = (ng + ok) // 2
        if S[mid] + mid * (C[-1] - C[mid]) >= K * mid :
            ok = mid
        else :
            ng = mid
    print(ok)

Measured memory_bytes: 120888
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
    int n;
    cin>>n;
    int a[2];
    bool b[2];
    for(int i = 0; i<2; i++){
        a[i] = n%100;
        b[i] = true;
        n/=100;
        if(a[i]==0||a[i]>12) b[i] = false;
    }
    if(b[0]&&b[1]) cout<<"AMBIGUOUS"<<endl;
    else{
        if(b[0]) cout<<"YYMM"<<endl;
        else if(b[1]) cout<<"MMYY"<<endl;
        else{
            cout<<"NA"<<endl;
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  int A = N / 1000;
  int B = (N - A * 1000) / 100;
  int C = (N - A * 1000 - B * 100) / 10;
  int D = N - A * 1000 - B * 100 - C * 10;
  
  if(A == B && B == C || B == C && C == D){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main() {
    long long N, D;
    cin >> N >> D;
    long long ans=0;
    for (long long i=0; i<N; i++) {
        long double X,Y;
        long double d = 2.0;
        long double e = 0.5;
        cin >> X >> Y;
        if (powl(powl(X,d)+powl(Y,d),e)<=D) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3828
import sys
N = int(input())
W = [input() for _ in range(N)]
if len(set(W)) == len(W):
  for i in range(1, len(W)):
    if W[i-1][-1] != W[i][0]:
      print('No')
      sys.exit()
else:
  print('No')
  sys.exit()
print('Yes')

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
   int A[5][5],i,j,a,b;
   for(i=1;i<=3;i++) for(j=1;j<=3;j++) cin>>A[i][j];
   a=A[2][2]+A[1][1]+A[1][1]-A[2][1]-A[1][2];
   b=1;
   if(a!=A[3][3]+A[1][1]+A[1][1]-A[1][3]-A[3][1]) b=0;
   if(a!=A[2][3]+A[1][1]+A[1][1]-A[2][1]-A[1][3]) b=0;
   if(a!=A[3][2]+A[1][1]+A[1][1]-A[3][1]-A[1][2]) b=0;
   if(b) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}

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

int n, k;
int a[N];

int main()
{
    scanf("%d%d", &n, &k);
    int ans = 0;
    while (n--)
    {
        int x;
        scanf("%d", &x);
        if (x >= k)
            ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		int P[]=new int[N];
		int z=0,y=0,m1=0,m2=0,m3=0;
		while(z<N){
			P[z]=stdIn.nextInt();
			if(P[z]<=A)
				m1++;
			if(P[z]>A&&P[z]<=B)
				m2++;
			if(P[z]>B)
				m3++;
			z++;
		}
		if(m1<=m2&&m1<=m3)
			System.out.println(m1);
		else
			if(m2<=m1&&m2<=m3)
				System.out.println(m2);
			else
				if(m3<=m1&&m3<=m2)
					System.out.println(m3);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int mid = a[n / 2];
    long long sum = 0;
    int mi1 = M, mi2 = M;
    for (int i = 0; i < n; ++i) {
        int b = abs(a[i] - mid);
        sum += b;
        if (mi1 > b) {
            mi2 = mi1;
            mi1 = b;
        }
        else if (mi2 > b) {
            mi2 = b;
        }
    }
    if (n % 2 == 0) {
        cout << sum * 2 - abs(a[n / 2 - 1] - mid) - abs(a[n / 2] - mid) << "\n";
    }
    else {
        cout << sum * 2 - mi2 << "\n";
    }
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int a[101][101], b[101], c[101];
    int i, j;
    int n, m;
 
    scanf("%d%d", &n, &m);
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
    }
    for (j = 0; j < m; j++) scanf("%d", &b[j]);
 
    for (i = 0; i < n; i++) {
        c[i] = 0;
        for (j = 0; j < m; j++) c[i] += a[i][j] * b[j];
    }
 
    for (i = 0; i < n; i++) {
        printf("%d\n", c[i]);
    }
    return 0;
}



Measured memory_bytes: 2148
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int N_MAX = 2000001;
constexpr ll MOD = 1000000007;

ll fact[N_MAX+1], rfact[N_MAX+1];

ll perm(ll n, ll k) {
    if(n-k < 0LL) return 0LL;
    return (fact[n] * rfact[n-k]) % MOD;
}

ll comb(ll n, ll k) {
    if(n-k < 0LL) return 0LL;
    return (perm(n, k) * rfact[k]) % MOD;
}

ll modpow(ll a, ll p) {
    ll ret = 1LL;
    while(p) {
        if(p & 1) {
            ret = (ret * a) % MOD;
        }
        a = (a * a) % MOD;
        p >>= 1;
    }
    return ret;
}

void init_fact(ll n) {
    fact[0] = fact[1] = 1;
    rfact[0] = rfact[1] = 1;
    for(ll i=2;i<=n;++i) {
        fact[i] = (fact[i-1] * i) % MOD;
        rfact[i] = modpow(fact[i], MOD-2);
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    init_fact(c2+r2+1);

    ll ans = 0LL;
    for(ll r=r1;r<=r2;++r) {
        ans += comb(c2+r+1, r+1);
        ans %= MOD;
        ans += (MOD - comb(r+c1, r+1)) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 31488
#include<iostream>
#include<set>
#include<string>
#include<vector>
using namespace std;
int main()
{
  int n;
  string a,b;
  vector<string> answer;
  typedef set<string> set_t;
  set_t A;
  cin >>n;
  for(int variable = 0;variable < n;++variable){
    cin >> a;
    if(a == "insert"){
      cin >> b;
      A.insert(b);
    }
    else{
      cin >> b;
      if(A.count(b) == 1) answer.push_back("yes") ;
      else answer.push_back("no");
    }
  }
  for(int variable = 0;variable < answer.size();++variable)
    cout << answer[variable] <<endl;
}

Measured memory_bytes: 54428
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#include <memory>
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define l_double long double
#define vtr vector
#define PB push_back
#define EB emplace_back
#define gcd __gcd
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define TEST uint _ {}; cin >> _; while (_--)
#define PIE (3.1415926535897932384626433832795)
#define MOD 1'00'00'00'007
using namespace std;

template<typename T>
void vtrS(const vector<T> &ARR) { for (auto const &val: ARR) cout<<val<<" "; cout<<endl; }

template<typename T>
void vtrV(const vector<T> &ARR) { for (auto const &val: ARR) cout<<val<<endl; }

ull lcm (ull a, ull b) { return ((a*b)/gcd(a, b)); }
ull countDigits(const ull &N) { return (floor(log10(N)) + 1); }
bool isPowOfTwo(ull const &N) { return (N && (!(N&(N-1)))); }
// ---------------------------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<boolalpha<<fixed<<setprecision(3); 
    // --------------------------------------
    
    ll n {}, k {};
    cin >> n >> k;

    n -= (n/k) * k;
    cout<<min(abs(n-k), abs(abs(n-k) - k));
    return 0;
}


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


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    ll R,C,K;
    cin>>R>>C>>K;
    vv grid(R,v(C,0));
    rep(i,0,K){
        ll r,c,v;
        cin>>r>>c>>v;
        r--;c--;
        if(v<=0)continue;

        grid[r][c]=v;
    }

    vv max_grid(R,v(C,0));
    rep(i,0,R){
        v dp(4,0);
        rep(j,0,C){
            ll now = 0;

            dp[0] = i==0 ? 0 : max(dp[0],max_grid[i-1][j]);
            dp[3] = max(dp[3],dp[2] + grid[i][j]);
            dp[2] = max(dp[2],dp[1] + grid[i][j]);
            dp[1] = max(dp[1],dp[0] + grid[i][j]);

            now = max(now,dp[0]);
            now = max(now,dp[1]);
            now = max(now,dp[2]);
            now = max(now,dp[3]);
            max_grid[i][j] = now;
            //cout<<now<<dp[0]<<dp[1]<<dp[2]<<dp[3]<<endl;
        }
    }

    cout<<max_grid[R-1][C-1];
    return 0;
}

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

int main() {
  
  string a;
  string b;
  string c;
  char turn = 'a';
  char ans;

  int a_pnt = 0;
  int b_pnt = 0;
  int c_pnt = 0;

  cin >> a >> b >> c;

  while(true) {

    // 勝利条件
    /*
    if(turn == 'A' && a_pnt == a.size()) {
      break;
    } else if(turn == 'B' && b_pnt == b.size()) {
      break;
    } else if(turn == 'C' && c_pnt == c.size()) {
      break;
    }
    */

    //cout << turn << endl;

    if(turn == 'a') {
      if(a_pnt == a.size()) {
         break;
      }
      turn = a[a_pnt];
      a_pnt++;
    }else if(turn == 'b') {
      if(b_pnt == b.size()) {
         break;
      }
      turn = b[b_pnt];
      b_pnt++;
    }else if(turn == 'c') {
      if(c_pnt == c.size()) {
         break;
      }
      turn = c[c_pnt];
      c_pnt++;
    }
  }

  ans = turn - 32;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*input

*/

#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define pb          push_back
#define pp          pop_back
#define nl          cout << "\n"
#define MIN(con)    (*min_element(ALL(con)))
#define MAX(con)    (*max_element(ALL(con)))
#define NX(cont)    next_permutation(ALL(cont))
#define PX(cont)    prev_permutation(ALL(cont))
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define all(c)      c.begin(),c.end()
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define sp          cout << " "
#define ifalse      ios_base::sync_with_stdio(false),cin.tie(NULL)
#define debug(x)    cout << #x << " = " << x << "\n";

using ll = long long;
using ld = long double;
 
template <typename T> T GCD(T a, T b) { ll t; while(a){ t=a; a=b%a; b=t; } return b; }
template <typename T> T LCM(T a, T b) { return (a*b) / GCD(a, b); }
template <typename T> string toString(T a) { return to_string(a); }
template <typename T> void toInt(string s, T &x) { stringstream str(s); str >> x; }

ll add(ll x, ll y, ll MOD) { x += y; if(x >= MOD) x -= MOD; return x; }
ll sub(ll x, ll y, ll MOD) { x -= y; if(x < 0) x += MOD; return x; }
ll mul(ll x, ll y, ll MOD) { return ((x % MOD) * (y % MOD)) % MOD; }

ll powr(ll a, ll b, ll MOD) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a, MOD);
    a = mul(a, a, MOD);
    b >>= 1;
  }
  return x;
}

ll inv(ll a, ll MOD) { return powr(a, MOD-2, MOD); }
const ll INF =  1e18;
const int SINF = 1e9;
const ll MOD = 1e9 + 7;

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/************************************START***************************************/
const int N = 100005;

int main()
{
  ifalse;
  vector < int > v;
  rep(i, 0, 5) {
    int x;
    cin >> x;
    v.pb(x);
  }
  int k;
  cin >> k;
  bool flag = 0;
  for(int i = 0; i < 5; i ++) {
    for(int j = i + 1; j < 5; j ++) {
      if(abs(v[i] - v[j]) <= k) {
        
      }
      else {
        flag = 1;
      }
    }
  }
  if(!flag) {
    cout << "Yay!";
  }
  else {
    cout << ":(";
  }
  return 0;
}

Measured memory_bytes: 256
// Problem : C - A x B + C
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
const long long int  modu=1e9+7;
#define endl '\n'
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define inp(x)  for(auto &t:x) cin>>t;
#define itr     vector<int>::iterator
#define debug(a) cout << #a << "=" << a << ' '<<endl;
#define out(x)  for(auto &t:x) cout<<t<<" "; cout<<endl;
#define ff first
#define ss second
#define pb push_back
#define initialize(a,v)  for(int i=0;i<a.size();++i) a[i]=v;
#define all(x) x.begin(),x.end()
#define mpt(mp) for(auto it=mp.begin();it!=mp.end();it++)
#define trav(x) for(int i=0;i<(int)x.size();++i)
#define mkp(a,b) make_pair(a,b)
#define sz(x)  (int)x.size()

int noofdig(int N)
{
	return floor(log10(N))+1;
}


ll f(ll a)
{

return 0;

}



void pre()
{

}



void solve()
{
	ll n;
	cin>>n;
	ll sum=0;
	for(int i=1;i<=n;++i)
	{
		if(n%i==0)
		sum+=(n/i)-1;
		else
		sum+=n/i;
 
     		
	}
	
	cout<<sum<<endl;


}



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

	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a.at(i).at(j);
    }
  }
  vector<vector<char>> b(H+2, vector<char>(W+2));
  for (int i = 0; i < H+2; i++) {
    for (int j = 0; j < W+2; j++) {
      if (min(i,j) == 0 || i == H+1 || j == W+1) b.at(i).at(j) = '#';
      else b.at(i).at(j) = a.at(i-1).at(j-1);
    }
  }
  for (int i = 0; i < H+2; i++) {
    for (int j = 0; j < W+2; j++) {
      cout << b.at(i).at(j);
      if (j == W+1) cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int h, w;
    cin >> h >> w;
    auto v = make_v(h, w, false);
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j) v[i][j] = s[j] == '#';
    }
    auto v2 = make_v(h-1, w-1, 0);
    h--; w--;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            v2[i][j] = 1-(v[i][j] ^ v[i][j+1] ^ v[i+1][j] ^ v[i+1][j+1]);
        }
    }
    for (int i = 1; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(v2[i][j]) v2[i][j] += v2[i-1][j];
        }
    }

    int ans = max(h+1, w+1);
    for (int i = 0; i < h; ++i) {
        stack<int> S;
        vector<int> l(w), r(w);
        for (int j = 0; j < w; ++j) {
            while(!S.empty() && v2[i][S.top()] >= v2[i][j]) S.pop();
            l[j] = (S.empty() ? 0 : S.top() + 1);
            S.emplace(j);
        }
        while(!S.empty()) S.pop();
        for (int j = w-1; j >= 0; --j) {
            while(!S.empty() && v2[i][S.top()] >= v2[i][j]) S.pop();
            r[j] = (S.empty() ? w : S.top());
            S.emplace(j);
        }
        for (int j = 0; j < w; ++j) {
            chmax(ans, (v2[i][j]+1)*(r[j]-l[j]+1));
        }
    }
    cout << ans << "\n";
    return 0;
}


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

int main() {
  int A,B;
  cin >> A >> B;
  
  int sum=0;
  if(A>=B){
    sum += A;
    A--;
    if(A>=B){
    sum += A;
    }
    else{
    sum += B;
    }
  }
  else{
    sum += B;
    B--;
    if(A>=B){
    sum += A;
    }
    else{
    sum += B;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int> pii;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n;
const int Maxn=2e5+5;
int a[Maxn];
int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	ll tot=0;
	for(int i=0;i<n-1;i++){
		if(a[i]>a[i+1]){
			tot+=(ll)a[i]-a[i+1];
			a[i+1]=a[i];
		}
	}
	cout<<tot<<endl;
	return 0;
}


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

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double R;
  cin >> R;
  cout << 2*R*3.141592653589793238 <<endl;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	map<int,int> m;
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
		m[a[i]]++;
	}
	int ans = 0;
	for(auto x : m){
		ans += x.second * (x.second -1 )/2;
	}
	for(int i = 0; i < n; i++){
		int cur = ans;
		int cnt = m[a[i]];
		cur += (cnt-1)*(cnt-2)/2;
		cur -= (cnt)*(cnt-1)/2;
		cout << cur << endl;
	}
	

	return 0;
}



Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll a, b, c; cin >> a >> b >> c;
    ll k; cin >> k;
    int count = 0;
    while (a >= b) {
        b *= 2;
        count++;
    }
    while (b >= c) {
        c *= 2;
        count++;
    }

    if (count > k) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}

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

int main() {
  int n, m, a[100][100], b[100], ans[100];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      ans[i] += a[i][j] * b[j];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << '\n';
  }
  cout << flush;
}

Measured memory_bytes: 3108
#include <stdio.h>
#define ll long long

ll f(ll p, int key, int *w, int n) {
    int i = 0;
    int v = 0;
    int t = 0;
    ll sum = 0;
    for (i = 0; i < n; i++) {
        if (sum + w[i] <= p) {
            sum += w[i];
            v++;
        } else {
            if (sum > 0) t++;
            else return v;
            if (t >= key) return v;
            sum = 0;
            if (w[i] <= p) {
                sum += w[i];
                v++;
            } else return v;
        }
    }
    return v;
}

ll binarySearch(int key, int *w, int n, ll left, ll right) {
    if (right < left) return 0;
    ll mid = (left + right) / 2;
    ll vc1 = f(mid, key, w, n);
    ll vc2 = f(mid-1, key, w, n);
    if (vc1 == n) {
        if (vc2 < n) return mid;
        else if (vc2 == n) return binarySearch(key, w, n, left, mid-1);
    }
    else return binarySearch(key, w, n, mid+1, right);
}

int main(void) {
    int n, k, i;
    ll P;
    scanf("%d %d", &n, &k);
    int w[n];
    ll b = 0;
    for (i = 0; i < n; i++) {
        scanf("%d", &w[i]);
        b += w[i];
    }

    P = binarySearch(k, w, n, 1, b);

    printf("%lld\n", P);
    return 0;

}


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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  
// may need to add mod
// also check if int -> long long is required
int ipow(int base, int exp)
{
    int ans = 1;
    while(exp > 0)
    {
        if(exp&1)
            ans = ans*base;
        base = base*base;
        exp >>= 1;
    }
    return ans;
}

int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int x;
    cin >> x;
    int z = 100;
    long double curr = 100;
    long double inc = (long double)101/100;
    int c = 0;
    while(z < x)
    {
    	curr *= inc;
    	z = (int) curr;
    	curr = z;
    	c++;
    }
    cout << c << "\n";


    return 0;
}


Measured memory_bytes: 3612
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int n = sc.nextInt(), m = sc.nextInt();
                        int[][] a = new int[n][m];
                        for (int i = 0; i < n; i++) {
                                for (int j = 0; j < m; j++) {
                                        a[i][j] = sc.nextInt();
                                }
                        }
                        int[] x = new int[m];
                        for (int i = 0; i < m; i++) {
                                x[i] = sc.nextInt();
                        }
                        for (int i = 0; i < n; i++) {
                                int ans = 0;
                                for (int j = 0; j < m; j++) {
                                        ans += x[j] * a[i][j];
                                }
                                System.out.println(ans);
                        }
                }
        }
}

Measured memory_bytes: 40524