akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <inttypes.h>

int main(void){
	long double a;
	long double b;
	long long int sum;

	scanf("%llf %llf",&a,&b);
	sum=(long long int)(a*b);
	printf("%lld",sum);
	return 0;
}


Measured memory_bytes: 1752
#include <iostream>
using namespace std;
int main() {
int h,w,y[15][15],a,s=0,i,j,k;
cin>>h>>w;
for(i=0;i<10;i++)for(j=0;j<10;j++)cin>>y[i][j];
for(k=0;k<10;k++)for(i=0;i<10;i++)for(j=0;j<10;j++)y[i][j]=min(y[i][j],y[i][k]+y[k][j]);
for(i=1;i<=h;i++)for(j=1;j<=w;j++){
cin>>a;
if(a!=-1)s+=y[a][1];
}
cout<<s<<endl;
}


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

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

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

    int cnt = 0;
    for (int i=0; i<n; i++) {
        if ((i+1)%2 == 1 && a[i]%2 == 1) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int num = n;
      int digitSum = 0;
      while(num > 0) {
        digitSum += num % 10;
        num /= 10;
      }
      if(n % digitSum == 0)
      System.out.println("Yes");
      else
      System.out.println("No");
  }
}

Measured memory_bytes: 21076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  ll res;
  res = n / 2;
  if(n % 2 == 0)res--;
  cout << res << endl;
}

Measured memory_bytes: 3672
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"input()\n"
"s=input()\n"
"while 1:\n"
"  for i in range(len(s)):\n"
"    if s[i]=='('and s[i:].count(')')<(len(s)-i)/2:\n"
"      s+=')'\n"
"      break\n"
"  else:\n"
"    break\n"
"print('('*(s.count(')')-s.count('('))+s)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
int n,k;
double mid,Left,Right,len[200005];
const double eps=1e-6;
bool Judge(double lim)
{
	int cnt=0;
	for(int i=1;i<=n;i++) cnt+=ceil(len[i]/lim)-1;
	return cnt<=k;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%lf",&len[i]),Right=max(Right,len[i]);
	while(abs(Left-Right)>eps)
	{
		mid=(Left+Right)/2.0;
		if(Judge(mid)) Right=mid;
		else Left=mid;
	}
	printf("%.0lf\n",ceil(Right));
	return 0;
}


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

const long long INF = 1LL << 60;
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; }

typedef long long ll;
#define vl vector<ll>
#define vll vector< vector<ll> >
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)

int N;
int H[110000][3];
int dp[110000][3];

int main() {

	cin >> N;
	rep1(i, N + 1) cin >> H[i][0] >> H[i][1] >> H[i][2];
	rep1(i, N + 1) {
		rep(p, 3) {
			rep(y, 3) {
				if (p != y)
					chmax(dp[i][p], dp[i - 1][y] + H[i][p]);

			}
		}
	}
	
	int ans = 0;
	rep(i, 3) ans = max(ans, dp[N][i]);

	cout << ans << endl;

}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    vector<int> v(n);
    iota(ALL(v), 1);
    int x, y;
    int c = 1;
    do {
        bool ok = true;
        REP(i, n) if (a[i] != v[i]) {
            ok = false;
            break;
        }
        if (ok) x = c;
        ok = true;
        REP(i, n) if (b[i] != v[i]) {
            ok = false;
            break;
        }
        if (ok) y = c;
        c++;
    } while (next_permutation(ALL(v)));
    cout << abs(x - y) << EOL;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    long long  a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    
    return 0;

}
/*


*/


Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sst stringstream
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int N,g[111][111];

int main(){
	while(cin>>N && N){
		memset(g,0,sizeof(g));
		rep(i,N){
			int M,p;
			cin>>M;
			rep(j,M){
				cin>>p;
				g[i][p-1]=1;
			}
		}
		int K;
		cin>>K;
		vi v;
		rep(i,K){
			int l;
			cin>>l;
			v.pb(l-1);
		}
		int ans=-1;
		rep(i,N){
			int ok=1;
			rep(j,v.sz){
				if(g[i][v[j]]==0){
					ok=0;break;
				}
			}
			if(ok){
				if(ans==-1)ans=i+1;
				else{
					ans=-1;
					break;
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 956
#include <bits/stdc++.h>
#define itn int
#define rep(i, n) for(int i = 0; i < n; i++)
#define irep(i,n) for(int i = n-1; i>=0; i--)
#define FOR(a,b) for(int i=a; i<b+1; i++)
using namespace std;
typedef long long ll;


int main() {
    string s;
    cin >> s;
    ll k;
    cin >> k;
    rep(i,s.size()){
        int tmp='z'-s[i]+1;
        if(s[i]=='a'){
            continue;
        }
        if(k>=tmp){
            k-=tmp;
            s[i]='a';
        }
    }
    if(k!=0){
        k=k%26;
        s[s.size()-1]=char(s[s.size()-1]+k);
    }
    cout << s << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>
inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll ans=0;
    vector<ll> a(3);
    rep(i,3) cin>>a[i];

    sort(a.begin(),a.end());
    rep(i,2){
        ans+=abs(a[i+1]-a[i]);
    }

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3572
N = int(input())
H = list(map(int, input().split()))

ans = 'Yes'

for i in reversed(range(0, N-1)):
    if H[i] > H[i+1] + 1:
        ans = 'No'
    elif H[i] == H[i+1] + 1:
        H[i] -= 1

print(ans)

Measured memory_bytes: 14396
import java.util.*;

public class Main {
	private void doit(){
		
		Scanner sc = new Scanner(System.in);
		long mod = 1000000007;
		while(sc.hasNext()){
			int w = sc.nextInt();
			int h = sc.nextInt();
			int n = sc.nextInt();
			
			int minx = 0, miny = 0;
			int maxx = w, maxy = h;
			for(int i = 0; i < n; i++){
				int x = sc.nextInt();
				int y = sc.nextInt();
				int a = sc.nextInt();
				if(a == 1){
					minx = Math.max(minx, x);
				}
				if(a == 2){
					maxx = Math.min(maxx, x);
				}
				if(a == 3){
					miny = Math.max(miny, y);
				}
				if(a == 4){
					maxy = Math.min(maxy, y);
				}
			}
			int resx = Math.max((maxx - minx), 0);
			int resy = Math.max((maxy - miny), 0);
			System.out.println( resx * resy);
		}

	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 10580
//d
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int n;
int a[100010];
int f[100010];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	if(n==2)
	{
		cout<<abs(a[1]-a[2]);
		return 0; 
	}
	f[1]=0;
	f[2]=abs(a[2]-a[1]);
	for(int i=3;i<=n;i++)
	{
		f[i]=min(f[i-1]+abs(a[i-1]-a[i]),f[i-2]+abs(a[i-2]-a[i]));
	}
	cout<<f[n];

	
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n, m;
    cin>>n>>m;

    if(abs(n-m) > 1){
        cout<<0<<endl;
        return 0;
    }
    ll ans = 1;
    for(ll i=1;i<=n;++i){
        ans *= i;
        ans %= mod;
    }
    for(ll i=1;i<=m;++i){
        ans *= i;
        ans %= mod;
    }
    if(n == m){
        ans *= 2;
    }
    ans %= mod;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int n;
  cin >> n;

  int64_t res = 0;
  map <string, int> seen;

  rep(i,n) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if(seen.count(s)) res += seen[s], seen[s]++;
    else seen[s]++;
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 11264
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

template <typename T>
T Max(T x, T y) {return x > y ? x : y;}

template <typename T>
T Min(T x, T y) {return x < y ? x : y;}

#define LL long long

int m, d, ans;

int main() {
    scanf("%d %d", &m, &d);
    for(int i = 1; i <= m; i ++) {
        for(int j = 1; j <= d; j ++) {
            int p1 = j % 10;
            int p2 = j / 10;
            if(p1 < 2 || p2 < 2) continue;
            if(p1 * p2 == i)
                ans ++;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
//専用ライブラリ
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e12
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------
ll n,k;
vector<ll> a;
vector<ll> f;
ll s=0;
bool check(ll x)
{
    //if(<xs?)
    ll cnt=0;
    for(ll i=0;i<n;i++)
    {
       if(x<a[i]*f[i])
           cnt+=a[i]-x/f[i];
    }
    if(cnt<=k)
        return true;
    else
        return false;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    cin>>n>>k;
    a.resize(n);
    f.resize(n);
    
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    for(ll i=0;i<n;i++)
        cin>>f[i];
  //  if(s<=k){cout<<0<<endl;return 0;}
    sort(a.begin(),a.end());
    sort(f.begin(),f.end());
    reverse(f.begin(),f.end());
    ll l=-1;
    ll r=INF;
    while(abs(r-l)>1)
    {
        ll mid=(r+l)/2;
        if(check(mid))
            r=mid;
        else
            l=mid;
    }
        cout<<r<<endl;
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

const int limit = 100010;
int a[limit];
multiset<int> ord, rev;


int main(void) {
	int n;
	cin >> n;
	rep(i, n) cin >> a[i];


	vector<int> ans;

	rep(i, n) {
		const int ridx = n - 1 - i;
		
		{
			auto it = rev.find(a[i]);
			if(it != end(rev)){
				rev.erase(it);
			}else{
				ord.insert(a[i]);
			}
		}

		{
			auto it = ord.find(a[ridx]);
			if(it != end(ord)){
				ord.erase(it);
			}else{
				rev.insert(a[ridx]);
			}
		}

		if(ord.empty() and rev.empty()) ans.push_back(i + 1);
	}

	const int m = ans.size();
	rep(i,m) cout << (i?" ":"") << ans[i];
	cout << endl;


	return 0;
}


Measured memory_bytes: 4436
#include <bits/stdc++.h>
#define forn(x, n)              for (int x = 0; x < n; x++)
#define forr(x, n)              for (int x = n; x >= 0; x--)
#define fore(x, a, b, c)        for (int x = a; x <= b; x += c)
#define forre(x, a, b, c)       for (int x = a; x >= b; x -= c)
#define clr                     cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define all(container)          (container).begin(), (container).end()
#define rall(container)         (container).rbegin(), (container).rend()
#define tracev(v)               for (auto& x: v) cerr << x << " "; cerr << '\n';
#define trace2v(v)              for (auto& x: v) cerr << x.fi << " - " << x.se << '\n'; cerr << '\n';
#define FILL(x, val)            memset(x, val, sizeof(x))
#define pb                      push_back
#define eb                      emplace_back
#define fi                      first
#define se                      second
#define mod                     (int)1000000007
#define INF                     (int)0x3f3f3f3f

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }  

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

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifndef ONLINE_JUDGE
    freopen("errlog", "w", stderr);
#endif
    int n; cin >> n;
    vector<int> skew(2 * n);
    forn(i, 2 * n) cin >> skew[i];
    sort(rall(skew));
    int ans = 0;
    fore(i, 0, 2 * n-2, 2) {
        ans += min(skew[i], skew[i + 1]);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846

int n, k;
ll c;
int main(){
    cin >> n >> k;
    fox1(l, n){
        for (int l2=0; l2<=n; l2+=l){
            c+=max(0, min(l2+l, n+1-(k==0))-l2-k);
        }
        //cout << c << endl;
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int Y = scanner.nextInt();

        int sum1, sum2, sum3;
        for (int s=N; s >= 0; s--) {
            // 10,000
            sum1 = 10000 * s;
            if (sum1 > Y) {
                continue;
            }
            for (int t=N - s; t >= 0; t--) {
                // 5,000
                sum2 = 5000 * t;
                if (sum1 + sum2 > Y) {
                    continue;
                }

                // 1,000
                int u = N - s - t;
                sum3 = 1000 * u;
                if (s + t + u == N) {
                    if (sum1 + sum2 + sum3 == Y) {
                        System.out.printf("%d %d %d\n", s, t, u);
                        return;
                    }
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}

Measured memory_bytes: 22868
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;
const ll M=1000000000+7;

ll n,k;
ll res=0;

ll sum_dp_seq_num[110000];
ll dp_seq_num[110000];

ll my_pow(ll x, ll y)
{
    if (y==0) return 1;
    ll half = my_pow(x, y/2);
    ll res = (half*half)%M;
    if (y%2==1) res=(res*x)%M;
    return res;
}

int a[10000];

ll num_of_k(ll j, ll n)
{
    return n/j - (n/(j+1));
}

void test()
{
    for (int i=2; i<=n; ++i)
    {
        int res = n/i;
        a[res]++;
    }
    a[n]++;
    for (int i=1; i<=n; ++i)
        cout<<i<<' '<<a[i]<<' '<<num_of_k(i, n)<<endl;
}

    
ll dp_seq_num1[110000];
ll check(ll n, ll k)
{
    ll res = 0;

    for (int i=1; i<=k; ++i)
    {
        if (i==1) dp_seq_num1[i]=1;
        else
        {
            dp_seq_num1[i] = my_pow(i,n);
            for (int j=2; j<=i; ++j)
                dp_seq_num1[i] = (dp_seq_num1[i] - dp_seq_num1[i/j])%M;
        }
    }
    for (ll i=1; i<=k; ++i)
    {
        res += (dp_seq_num1[k/i]*i)%M;
        res %= M;
    }
    return res;
}

ll check2(ll n, ll k)
{
    ll res = 0;
    for (int i=1; i<=k; ++i)
    {
        if (i==1) dp_seq_num[i]=1;
        else
        {
            dp_seq_num[i] = my_pow(i,n);
            ll remain_num=0,cal_num = 0;
            for (int tmp = 2; tmp<=sqrt(i); ++tmp)
            {
                ll b1=tmp, b2=i/tmp;
                cal_num+=num_of_k(b1,i);
                dp_seq_num[i] = (dp_seq_num[i] - dp_seq_num[b1]*num_of_k(b1,i))%M;
                if (b1!=b2)
                {
                    cal_num+=num_of_k(b2,i);
                    dp_seq_num[i] = (dp_seq_num[i] - dp_seq_num[b2]*num_of_k(b2,i))%M;
                }
            }
            remain_num = i-1-cal_num;
            dp_seq_num[i] -= remain_num; 
        }
    }
    for (ll i=1; i<=k; ++i)
    {
        res += (dp_seq_num[k/i]*i)%M;
        res %= M;
    }
    return res;
}

int main()
{
    cin>>n>>k;
    cout<<check2(n,k)<<endl;
    //cout<<check(n, k)<<' '<<check2(n,k)<<endl;
    //for (int i=1; i<=k; ++i)
     //   cout<<dp_seq_num1[i]<<' '<<dp_seq_num[i]<<endl;
    return 0;
}



Measured memory_bytes: 4456
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int d[200020], t[200020];
int main(){
	int n, m;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	cin >> m;
	for (int j = 0; j < m; j++) {
		cin >> t[j];
	}
	sort(d, d + n);
	sort(t, t + m);
	int co = 0;
	for (int k = 0; k < n; k++) {
		if (d[k] == t[co]) {
			co++;
		}
	}
	if (co == m) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 1792
l = input().split()
S = l[0]
l = input().split()
T = l[0]

ls = len(S)
lt = len(T)

# print(S, T, len(S), len(T))

found = False

def match(pos, max_pos, src, dst):
    if pos == max_pos:
        return True
    if src[pos] == '?' or src[pos] == dst[pos]:
        return match(pos + 1, max_pos, src, dst)
    return False

for i in range(ls - lt + 1):
    index = ls - lt - i
    if match(0, lt, S[index:], T):
        S = S[:index] + T + S[index + lt:]
        found = True
        break

if found:
    S = S.replace('?', 'a')
    print(S)
else:
    print('UNRESTORABLE')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;

vector<ll> g;
int c = 0;
int k;

// void dfs(int i, string num){
//   g.push_back(num);
//   c++;
//   if(c == k) return;
//   int n = int(num.size());
//   for(int j = 0; j <= 9; j++) {
//     int l = stoi(num.substr(n-1, 1));
//     if(c == k) return;
//     if(abs(l - j) > 1) continue;
//     else dfs(i+1, num + to_string(j));
//   }
// }

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> k;
  if(k <= 9){
    cout << k << endl;
    return 0;
  }

  priority_queue<ll, vector<ll>, function<bool(ll,ll)>>q(
      [](ll a,ll b){return a>b;}
      );
  for (int i = 1; i < 10; ++i) {
    q.push((i));
  }
  c = 9;

  while(!q.empty() && c <= k){
    string v = to_string(q.top());
    // cout << v << endl;
    q.pop();
    int n = int(v.size());
    for(ll i = 0; i <= 9; i++){
      ll l = stoi(v.substr(n-1));
      if(abs(l - i) > 1) continue;
      q.push(stoll(v + to_string(i)));
      c++;
      if(c == k) {
        cout << v+to_string(i) << endl;
        return 0;
      }
    }
  }

  // cout << g[k-1] << endl;

}


Measured memory_bytes: 1400
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod = 1e9+7;

int main(void){
	ll N,P[200010],d[200010]={},inv[200010],ans=0;
	scanf("%lld",&N);
	reg(i,1,N){
		scanf("%lld",&P[i]);
		inv[P[i]]=i;
	}
	reg(i,1,N){
		if(d[i]==0){//まだきたことがなければ
			ll cnt=1,p=i;
			d[p]=1;
			while(1){
				// printf("%d: %d\n",i,p);
				if(P[p]<N && inv[P[p]+1]>p){//１つ後の要素が右側にあれば
					p = inv[P[p]+1];
					d[p]=1;
					cnt++;
				}else{
					break;
				}
			}
			if(ans<cnt)ans=cnt;
		}
	}
	printf("%lld\n",N-ans);
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    ll A,B;cin>>A>>B;
    cout<<(A%2!=B%2?"IMPOSSIBLE":to_string((A+B)/2))<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
using pii = pair <int, int>;
#define int ll
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = false;
int water_possible[3030];
int sugar_possible[3030];
pii best = {0, 0};
double bv = 0;
int32_t main()
{
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    for (int i = 0; i<=100; i++)
    {
        for (int j = 0; j<=100; j++)
        {
            int u = 100*a*i+100*b*j;
            if (u <= f)
                water_possible[u] = 1;
        }
    }
    for (int i = 0; i<=3000; i++)
    {
        for (int j = 0; j<=3000; j++)
        {
            int u = c*i+d*j;
            if (u <= f)
                sugar_possible[u] = 1;
        }
    }
    best = {100*a, 0};
    for (int i = 100; i<=3000; i+=100)
    {
        if (!water_possible[i]) continue;
        for (int j = 0; j<=3000; j++)
        {
            if (j>e*(i/100)) continue;
            if (i+j>f) continue;
            if (!sugar_possible[j]) continue;
            if (j/(1.0*i+j)>bv)
            {
                best = {i, j};
                bv = j/(1.0*i+j);
            }
        }
    }
    cout << best.first+best.second << ' ' <<  best.second << '\n';
}


Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

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

  int len = s.size();

  if (k >= len) {
    cout << s;
  } else {
    rep(i, k) { cout << s.at(i); }
    cout << "...";
  }
  return 0;
}


Measured memory_bytes: 3632
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
const ll tl= 1000000007;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    inl(n);
    map<ll,ll>T;
    FOR(i,2,n+1){
        inl(x);
        T[x]++;
    } 
    REP(i,n){
        out(T[i+1]);
    }
    // out();
}

Measured memory_bytes: 16180
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
long long int dp[110][100100];
long long int w,weight[110],value[110];
int main(void){
    int n;
    cin>>n>>w;
    for (int i=0;i<n;i++) {
        cin>>weight[i]>>value[i];
    }
    for (int i=0;i<110;i++) {
        for (int j=0;j<100100;j++) {
            dp[i][j]=0;
        }
    }
    for (int i=0;i<n;i++) {
        for (int sum_w=0;sum_w<=w;sum_w++) {
            if (sum_w-weight[i]>=0) {
                chmax(dp[i+1][sum_w],dp[i][sum_w-weight[i]]+value[i]);
            }
            chmax(dp[i+1][sum_w],dp[i][sum_w]);
        }
    }
    cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 89636
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main() {
  string x;
  cin >> x;
  
  if ((x[0] == x[1] && x[1] == x[2]) || (x[1] == x[2] && x[2] == x[3])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

#define pb push_back
#define ff first
#define ss second
#define N 100005
#define inf 1000000009
#define ll long long
#define all(a) a.begin(),a.end()
#define mid(a,b) (a+b)/2
#define pii pair<int,int>

using namespace std;

int n;
set <string> m;
string s;

int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		cin >> s;
		m.insert(s);
	}
	cout << m.size();
}


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

const int maxn=2e5+10;
int n,k,a[maxn],ans;

int main(){
	cin>>n>>k;
	for(int i=1,x;i<=n;++i){
		cin>>x;
		++a[x];
	}
	sort(a+1,a+n+1,greater<int>());
	for(int i=k+1;i<=n;++i)
		ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,k;
  cin>>n>>k;
  vll a(n);
  ll ans=0;
  rep(i,n) cin>>a[i];
  sort(all(a));
  a.pb(MOD);
  vll h(0);
  ll cu=1;
  rep(i,n){
    if(a[i]==a[i+1]) cu++;
    else{
      h.pb(cu);
      cu=1;
    }
  }
  sort(all(h));
  ll s=sz(h); 
  if(k>=s) COUT(0);
  else{
    rep(i,s-k) ans+=h[i];
    COUT(ans);
  }
}

Measured memory_bytes: 5476
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a[3];
  rep(i,0,3) cin >> a[i];
  sort(a, a+3);
  co(a[0] + a[1]);
}


Measured memory_bytes: 256
import javax.print.DocFlavor;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.function.BiConsumer;

public class Main {

    //グローバル変数を定義

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n+1];

        array[0] = 0;
        for(int i=1; i<=n; i++){
            array[i] = sc.nextInt();
        }

        int sum = 0;
        int before = 0;

        for(int i=1; i<=n; i++){
            int now = array[i];
            sum += Math.abs(now - before);
            before = now;
        }
        sum+=Math.abs(0-array[array.length-1]);

        for(int i=1; i<=n; i++){
            int ans = 0;
            if(i < n){
                ans = sum - (Math.abs(array[i] - array[i-1]) + Math.abs(array[i+1] - array[i])) + Math.abs(array[i+1] - array[i-1]);
            } else {
                ans = sum - (Math.abs(array[i] - array[i-1]) + Math.abs(0 - array[i])) + Math.abs(0 - array[i-1]);
            }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 66096
# include"stdio.h"
int main(){
  int a[6];
  for(int i=0;i<6;i++)
      scanf("%d",&a[i]);
  int a1=0,b=0,c=0,d=0;
  for(int i=0;i<6;i++)
  {
    if(a[i]==1)  a1++;
    if(a[i]==2)  b++;
    if(a[i]==3)  c++;
    if(a[i]==4)  d++;
  }
  if(a1==3||b==3||c==3||d==3)
      printf("NO\n");
  else printf("YES\n");
}

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

int main(){
	int x[10010];
	int y[10010];
	int i = 0, i2, i3 = 0;
	while (i < 10010){
		cin >> x[i];
		cin >> y[i];
		if (x[i] == 0){
			if (y[i] == 0){
				i2 = i;
				break;
			}
		}
		i++;
	}
	while (i3 < i2){
		for (int i4 = 0; i4 < x[i3]; i4++){
			for (int i5 = 0; i5 < y[i3]; i5++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
		i3++;
	}
	return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N=17, M=70000;
int a[N][N], n, F[M];
void precomp(int x)
{
	for(int i = 0; i < n; i++)
	{
		if((x & (1<<i)) == 0LL) continue;
		for(int j = 0; j < n; j++)
		{
			if(x & (1<<j))
			{
				F[x]+=a[i][j];
			}
		}
	}
	F[x]/=2;
}
signed main()
{
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			cin >> a[i][j];
		}
	}
	for(int i = 0; i < (1<<n); i++)
	{
		precomp(i);
		for(int j = i; j > 0; j = (j-1)&i)
		{
			F[i]=max(F[i], F[j] + F[i^j]);
		}
	}
	cout << F[(1<<n)-1];
}

Measured memory_bytes: 768
def dp1(n,h):
    dp=[10^5]*n
    dp[0]=0
    dp[1]=abs(h[1]-h[0])
    for i in range(2,n):
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
    return dp[n-1]

n=int(input())
h = list(map(int, input().split()))
print(dp1(n,h))

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

using namespace std;

int n;
long long res = 0;

int main() {
    scanf("%d", &n);
    res = 1ll * n * (n + 1) * (n + 2) / 6ll;
    for (int i = 1; i < n; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        if (x > y) swap(x, y);
        res -= 1ll * x * (n - y + 1);
    }
    printf("%lld", res);
}


Measured memory_bytes: 3800
#include <map>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define mo 1000000007
#define num(x) (x>='0' && x<='9')
typedef unsigned long long ull;
typedef long long ll;
using namespace std::tr1;
using namespace std;
int read(){
    int p=0, q=1;
    char ch=getchar();
    while (!num(ch))
        (ch=='-'?q=-1:0),
        ch=getchar();
    while (num(ch)) p=p*10+ch-'0', ch=getchar();
    return p*q;
}
int power(ll a, int b){
	ll c=1;
	while (b){
		if (b&1) c=c*a%mo;
		a=a*a%mo;
		b>>=1;
	}
	return c;
}
int main(){
	ll a=read(), b=read(), c=read(), d=read();
	cout<<max(max(a*c,b*d), max(a*d, b*c))<<endl;
    return 0;
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
    

    char ch;
    cin>>ch;

    if(ch>='A'&&ch<='Z') cout<<"A";
    else cout<<"a";
    
    return 0;
}



Measured memory_bytes: 3588
N = int(input())
dic = dict()
lis = list()
for i in range(N):
    tmp = input()
    lis.append(tmp)
    dic[tmp] =0
maxi = 0
for i in lis:
    dic[i] +=1
    if maxi < dic[i]:
        maxi = dic[i]
result = list()
for name in dic:
    if dic[name] == maxi:
        result.append(name)

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

Measured memory_bytes: 34564
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
main=print.solve.unfoldr(B.readInt.B.dropWhile isSpace)=<<B.getContents
solve(n:ls)=length[True|i<-[0..n-1],j<-[i+1..n-1],k<-[j+1..n-1],f[i,j,k]]where
  vs=V.fromList ls
  f=(\d@[a,b,c]->a+b>c&&a/=b&&b/=c).sort.map(vs V.!)

Measured memory_bytes: 5296
#include <bits/stdc++.h>
using namespace std;
const int N=10;
int path[N];
bool st[N];
int n,x,t;
int e[100010];
void dfs(int u)
{
    if(u==n)
    {
        for(int i=0;i<n;i++){
			//cout<<path[i]<<" ";
		x*=10;
		x+=path[i];
	}
	e[t++]=x;
        //cout<<x<<" "<<t;
	//puts("");
        x=0;
        return ;
    }
    for(int i=1;i<=n;i++)
        if(!st[i])
        {
        st[i]=true;
        path[u]=i;
        dfs(u+1);
        st[i]=false;
        }
}
int main()
{
    cin>>n;
    dfs(0);
    int y=0,z;
    int t1,t2;
    for(int i=0;i<n;i++)
    {
    	cin>>z;
	y*=10;
    	y+=z;
    }
    //cout<<y<<endl;
    for(int j=0;j<100010;j++)
	{
		if(e[j]==y)t1=j;
	}
	y=0;
        for(int i=0;i<n;i++)
    {
    	cin>>z;
    	y*=10;
    	y+=z;
    }

    for(int j=0;j<100010;j++)
	{
		if(e[j]==y)t2=j;
	}
	   // cout<<y<<endl;
    cout<<abs(t2-t1);

    return 0;
}


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

using namespace std;

const long long MOD = 1e9+7;
int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(12);
    cout << fixed;
    cin.tie(0);

    int n;
    cin >> n;
    long long ans = 1LL * n * (n+1) * (n+2) / 6;
    for (int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b;
        ans -= 1LL * min(a,b) * (n+1-max(a,b));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int X,Y;
  cin >> X >> Y;
  long long int a = Y/X;
  long long int k = 1;
  int c = 0;
  while(k <= a){
    k *= 2;
    c++;
  }
  cout << c << endl;
}


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

using namespace std;

#define int long long



main(){


	int h, w; cin >> h >> w;


	if(h == 1 or w == 1){
		cout << 1 << endl; return 0;
	}

	if((h * w) & 1LL){
		cout << (h * w + 1) / 2 << endl;
	}else{
		cout << h * w / 2 << endl;
	}

	


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
using namespace std;
int n,m;
map<int,vector<int> > e[111111];
int len[111111];
bool trans[111111];
map<int,set<int> > a[111111];

int q[111111],op,cl;
int main(){
	memset(len,-1,sizeof(len));
	scanf("%d%d",&n,&m);
	while(m--){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		if(x>y)swap(x,y);
		e[x][z].push_back(y);
		e[y][z].push_back(x);
		if(x == 1){
			len[y] = 1;
			a[1][z].insert(y);
		}
	}
	len[1] = 0;
	trans[1] = true;
	
	for(int step=1;;step++){

		if(a[step].empty()){
			puts("-1");
			return 0;
		}

		//same color.
		for(map<int,set<int> >::iterator it = a[step].begin(); it != a[step].end(); it++){
			op=cl=0;
			for(set<int>::iterator it2 = it->second.begin(); it2 != it->second.end(); it2++)
				q[op++]=*it2;
			int col = it->first;
			while(cl<op){
				int y = q[cl++];
				if(!e[y].count(col))continue;
				for(vector<int>::iterator it2 = e[y][col].begin(); it2 != e[y][col].end(); it2++){
					int to = *it2;
					if(len[to] != -1 && len[to] < step)continue;
					if(a[step][col].count(to))continue;
					a[step][col].insert(to);
					q[op++]=to;
					len[to]=step;
				}
			}
		}

		//different color
		for(map<int,set<int> >::iterator it = a[step].begin(); it != a[step].end(); it++){
			for(set<int>::iterator it2 = it->second.begin(); it2 != it->second.end(); it2++){
				int y = *it2;
				if(trans[y])continue;
				for(map<int,vector<int> >::iterator it3 = e[y].begin(); it3 != e[y].end(); it3++)
					for(vector<int>::iterator it4 = it3->second.begin(); it4 != it3 ->second.end(); it4++){
						int to = *it4;
						if(len[to] != -1 && len[to] <= step)continue;
						len[to] = step+1;
						a[step+1][it3->first].insert(to);
					}
				trans[y] = true;
			}
		}

		if(len[n]!=-1){
			printf("%d\n",len[n]);
			return 0;
		}
	}
}

Measured memory_bytes: 82560
#include <bits/stdc++.h>
using namespace std;
int n;
int arr[200001],found;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for (int i=0;i<n;i++) cin>>arr[i];
    for (int i=0;i<n;i++){
        if (arr[i]==found+1){
            found++;
        }
    }
    if (found==0) cout<<-1;
    else cout<<n-found;
}

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

int main(){
  int N,A,B,sum,s,k;
  
  sum = 0;
  s = 0;
  A = 1;
  
  cin >> N;
  k = N;
  
  //何桁の数か特定
  for(int i=1; i<=N; i*=10)
    s++;
  //桁数に合わせた数Aを出力
  for(int i=0; i<s-1;i++)
    A *=10;
  
  //各桁の和sumを計算
  for(int i=0; i<s;i++){
    B = k/A;
    k -= B*A;
    A /= 10;
    sum += B;

  }
  if(N%sum == 0)
    cout <<"Yes"<<endl;
  else 
    cout <<"No" <<endl;
}

Measured memory_bytes: 256
import math
def ii():
  return int(input())

N = ii()

def facts(n):
  facts = []
  for i in range(1, n):
    if i*i>n:
      break
    if n%i==0:
      facts.append(i)
  return facts

fs = facts(N)
a = fs[-1]
b = N//a

print(a+b-2)


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
int main(){
  int i, j, k,length, key, *A;
  scanf("%d",&length);
  A = (int *)malloc(sizeof(int) * length);
  for(j=0; j<length; j++)
    scanf("%d",&A[j]);
  for(i=0; i<length; i++){
    key = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
      A[j+1] = key;
    }
    for(k=0; k<length; k++){
      printf("%d",A[k]);
      if(k+1 < length)
	printf(" ");
    }
      printf("\n");
  }
  free(A);
  return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(10);
    int x;
    cin >> x;
    vector<bool> a(101000);
    a[0] = true;
    rep(i, 0, 100010) {
        if (a[i]) {
            rep(j, 100, 106) a[i + j] = true;
        }
    }
    cout << a[x] << endl;
    return 0;
}

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

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

	long long sum = 0;
	int mini = 1e9, minus_count = 0;

	for(int i=0; i<N; ++i){
		int a; cin>>a;
		if(a<0){ a = -a; ++minus_count; }
		mini = min(mini, a);
		sum += a;
	}

	cout<< (minus_count%2? sum - mini*2: sum) <<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	vector<string> s2;
	for(int i=0;i<n;i++){
		char s[10];
		scanf("%s",s);
		sort(s,s+10);
		s2.push_back(s);
	}
	int t=0;
	long long sum=0;
	sort(s2.begin(),s2.end());
	for(int i=1;i<s2.size();i++){
		if(s2[i]==s2[i-1]){
			t++;
			sum+=t;
		}
		else{
			t=0;
		}
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 6132