akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int N, M;
	cin >> N >> M;

	vector<bool> flg(N + 1, false);
	vector<int> T(N + 1, 0);

	for (int i = 0; i < M; i++) {
		int tmp;
		cin >> tmp;
		flg[tmp] = true;
	}

	T[0] = 1;

	for (int i = 1; i <= N; i++) {
		if (flg[i]) {
			continue;
		}
		if (i == 1) {
			T[i] += T[i - 1];
		} else {
			T[i] += T[i - 2];
			T[i] += T[i - 1];
		}
		T[i]%=MOD;
	}

	cout << T[N] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int x,a,b;
int main()
{
    cin>>x>>a>>b;
    int temp=b-a;
    if(b<=a)
        cout << "delicious" <<endl;
    else if(b>a)
    {
        if(temp<=x)
            cout << "safe" << endl;
        else
            cout << "dangerous" <<endl;
    }
    //cout << "Hello world!" << endl;
    return 0;
}


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    ll N; cin >> N;
    vector<bitset<10>> F(N);
    rep(i, N) {
        bitset<10> bs;
        rep(j, 10) {
            int f; cin >> f;
            bs.set(j, f);
        }
        F[i] = bs;
    }

    vector<vector<ll>> P(N, vector<ll>(11));
    cin >> P;

    ll ans = LLONG_MIN;
    for (int i = 1; i < (1<<10); i++) {
        bitset<10> joisino(i);
        vector<ll> c(N, 0);
        for (int j = 0; j < N; j++) {
            c[j] = (joisino & F[j]).count();
        }
        ll profit = 0;
        for (int j = 0; j < N; j++) {
            profit += P[j][c[j]];
        }
        chmax(ans, profit);
    }
    cout << ans << endl;
}


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

int main()
{
	int a;string b;
	cin >> a >> b;
	int y = b.length();
	if(y <= a){ cout << b;}
	else{
		for(int i = 0; i<a; i++){
		cout << b[i];
		}
		cout << "...";
		
		}


}

Measured memory_bytes: 3584
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cassert>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <list>
#include <forward_list>
#include <array>
#include <cstring>
#include <cmath>
#include <tuple>
#include <complex>
#include <bitset>
#include <climits>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pld = pair<LD, LD>;
const int MAX_NODES = 2e5;
vector<int> parent(MAX_NODES + 1), tree_size(MAX_NODES + 1);


inline void make_set(const int vertex)
{
    parent[vertex] = vertex;
    tree_size[vertex] = 1;
}


int find_leader(const int vertex)
{
    if (vertex == parent[vertex])
    {
        return vertex;
    }
    return parent[vertex] = find_leader(parent[vertex]);
}


void unite_sets(int node1, int node2)
{
    node1 = find_leader(node1);
    node2 = find_leader(node2);

    if (node1 != node2)
    {
        if (tree_size[node1] < tree_size[node2])
        {
            swap(node1, node2);
        }

        parent[node2] = node1;
        tree_size[node1] += tree_size[node2];
    }
}


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

    int N, M;
    cin >> N >> M;

    for (int node = 1; node <= N; ++node)
    {
        make_set(node);
    }
    
    while (M--)
    {
        int A, B;
        cin >> A >> B;

        unite_sets(A, B);
    }
    /*for (int i = 1; i <= N; ++i)
    {
        cerr << "adj[" << i << "]: ";
        for (auto &z : adj[i])
        {
            cerr << z << " ";
        }
        cerr << endl;
    }*/

    cout << *max_element(begin(tree_size), end(tree_size));
}


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

int main() {
  string s;
  cin >> s;
  
  if(s=="SAT"){
    cout << "1" << endl;
  }
  
  else if(s=="SUN"){
    cout << "7" << endl;
  }
  
  else if(s=="MON"){
    cout << "6" << endl;
  }
  
  else if(s=="TUE"){
    cout << "5" << endl;
  }
  
  else if(s=="WED"){
    cout << "4" << endl;
  }
  
  else if(s=="THU"){
    cout << "3" << endl;
  }
  
  else if(s=="FRI"){
    cout << "2" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            int n = scanner.nextInt();
            int result = 0;
            if (n == 0) {
                break;
            }
            while (n > 0) {
                result += n / 5;
                n /= 5;
            }
            System.out.println(result);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n)  RFOR(i,0,n)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
#define P pair<int,int>
#define PPi pair<P,int>
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int N,A,B,h[100000];

bool C(int X){ //N回の爆発で撃破可能->true
	ll tem=0;

	FOR(i,lower_bound(h,h+N,(ll)X*B)-h,N)
		tem+=(ll)ceil((h[i]-X*B)/(double)(A-B));
	
	return X>=tem;
}

int main(void){
	cin>>N>>A>>B;
	REP(i,N) cin>>h[i];
	SORT(h,N);

	ll lb=0,ub=INF;
	while(ub-lb>1){
		int mid=(ub+lb)/2;
		if(C(mid)) ub=mid; //(mid,ub]
		else lb=mid; //(lb,mid]
	}
	print(ub);
	return 0;
}




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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll A, B;
    cin >> A >> B;

    ll e = 1;
    for(int i = 0; i <= 20; i++ ){
       if( e >= B ){
         cout << i << endl;
         break;
       }
       e += A - 1;
    }
}


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

int func(int a, int b, int c) {
    if (a%2 or b%2 or c%2) return 0;
    if (a==b and a==c) return -1;
    return func((b+c)/2, (a+c)/2, (a+b)/2)+1;
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << func(a, b, c) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	ll n;
	cin>>n;
	if((n & 1) || (n < 2))
	cout<<"0\n";	
	else
	{
		ll p2 = n>>1LL;
		ll tc = p2;
		while(p2)
		{
			p2 >>= 1LL;
			tc += p2;
		}	
		ll p5 = n>>1LL;
		ll fc = 0;
		while(p5)
		{
			p5 /= 5LL;
			fc += p5;
		}
		cout<<min(tc, fc)<<"\n";
	}
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

#ifdef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	while(T--)
	solve(T);

#ifdef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N;
  cin >> N;

  vll A(N);
  rep(i, N) {
    cin >> A[i];
    A[i]--;
  }

  mll m;
  ll index = 0;
  ll ans = 0;
  while (m[index] == 0) {
    m[index]++;
    index = A[index];
    ans++;
    if (index == 1) {
      ANS;
      return 0;
    }
  }
  COUT(-1);
  return 0;
}

Measured memory_bytes: 10272
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long int
#define s(x)	cin>>x
#define p(x)	cout<<x<<"\n"
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 100000000000
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve() {
  ll x,k,d;
  cin>>x>>k>>d;
  x=abs(x);
  ll tp=x%d;
  ll tp1=x/d;
  ll res;
  if(tp1>k)
  { res=x-d*k;
  }
  else
  { ll tem=k-tp1;
    if(tem&1)
    res=abs(tp-d);
    else
    res=tp;
  }
  p(res);
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    //u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10692
def resolve():
    N, W = map(int, input().split())
    weight = []
    value = []
    for i in range(N):
        w, v = map(int, input().split())
        weight.append(w)
        value.append(v)
    dp = [[0 if i == 0 else W * N for i in range(N * max(value) + 1)]]
    for i in range(N):
        d = []
        for v in range(N * max(value) + 1):
            if v >= value[i]:
                d.append(min(dp[-1][v - value[i]] + weight[i], dp[-1][v]))
            else:
                d.append(dp[-1][v])
        dp.append(d)
    for i in reversed(range(N * max(value) + 1)):
        if dp[-1][i] <= W:
            print(i)
            return


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 171468
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>
 
using namespace std;
 
typedef long long ll;
 
const ll Inf = 1e18;
 
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n, x;
  cin >> n >> x;
  vector <int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector <ll> pref(n + 1);
  for (int i = 0; i < n; ++i) pref[i + 1] = pref[i] + a[i];
 
  auto get = [&] (int l, int r) {
    return pref[r + 1] - pref[l];
  };
 
  ll ans = Inf;
  for (int gs = 1; gs <= n; ++gs) {
    ll cost = 0; 
    int cnt = 0;
    for (int i = n - 1; i >= 0; i -= gs, ++cnt) {
      ll sm = get(max(0, i - gs + 1), i);
      if (cnt == 0) {
        cost += 5 * sm;
      } else {
        cost += (2 * (cnt + 1) + 1) * sm;
      } 
      cost = min(cost, Inf);
    }
    cost += (ll)n * x;
    cost += (ll)gs * x;
    ans = min(ans, cost);
  }
  cout << ans << '\n';
}
 


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define dcout cout<<fixed<<setprecision(20)
#define Accepted_MAGIC cin.tie(0);ios::sync_with_stdio(false);cerr << "compiled" << endl

// typedef long long ll;
using Real = long double;
#define int long long

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;
constexpr Real eps = 1e-9, pi = acos(-1);

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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 pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

signed main(void){
  Accepted_MAGIC;
  
  int N, A, B; cin >> N >> A >> B;
  int div = N / (A+B), md = N % (A+B);
  cout << A*div + min(md, A) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int n;
ll b[222222];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>b[i];
	for(int i=1;i<=n;i++)b[i]+=b[i-1];
	ll x=0,y=2,ans=LLONG_MAX;
	for(int i=2;i<n-1;i++){
		while(b[x+1]<b[i]-b[x+1])x++;
		while(b[y+1]-b[i]<b[n]-b[y+1])y++;
		for(int j=0;j<2;j++)
			for(int k=0;k<2;k++)
				ans=min(ans,abs(max({b[x+j],b[i]-b[x+j],b[y+k]-b[i],b[n]-b[y+k]})-min({b[x+j],b[i]-b[x+j],b[y+k]-b[i],b[n]-b[y+k]})));
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    int left = 1;
    int right = n;
    for(int i = 0; i < m; i++){
        int id_l, id_r;
        scanf("%d %d", &id_l, &id_r);
        if(id_l > left){
            left = id_l;
        }
        if(right > id_r){
            right = id_r;
        }
    }
    int ans;
    if(right - left + 1 < 0){
        ans = 0;
    }else{
        ans = right - left + 1;
    }
    printf("%d\n", ans);

}

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

string S;

int main(void) {
  cin >> S;

  ll cnt = 0;
  char last = 'A';
  REP(i, 0, S.size()) {
    if(S[i] <= last) cnt++;
    last = S[i];
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3196
# 太郎が花子と一緒にトランプ遊びをしようとしたところ、52枚あるはずのカードが n 枚のカードしか手元にありません。
# これらの n 枚のカードを入力として、足りないカードを出力するプログラムを作成して下さい。
# 太郎が最初に持っていたトランプはジョーカーを除く52枚のカードです。
# 52枚のカードは、スペード、ハート、クラブ、ダイヤの４つの絵柄に分かれており、各絵柄には13のランクがあります。


# coding: utf-8
# Your code here!
cards = {
    'S': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'],
    'H': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'],
    'C': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'],
    'D': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'],
}

n = int(input())
for i in range(n):
    a = input().split()
    cards.get(a[0]).remove(a[1])
for key, values in cards.items():
    for value in values:
        print(key, value)



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

using namespace std;

const int maxn = 100000;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> C(maxn + 5, 0);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    C[a]++;
  }
  int res = 0;
  for (int i = 1; i <= maxn; i++) {
    int tmp = 0;
    for (int j = -1; j <= 1; j++) {
      tmp += C[i + j];
    }
    res = max(res, tmp);
  }
  cout << res << '\n';
  return 0;
}


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


#define MOD 1000000007
class mll {
	unsigned long long val = 0;
public:
	mll(long long y = 0) : val(((y % MOD) + MOD) % MOD) {}
	mll operator + (const mll& y) { return mll(*this) += y; }
	mll& operator += (const mll& y) {
		val = (val + y.val) % MOD;
		return *this;
	}
	mll operator - (const mll& y) { return mll(*this) -= y; }
	mll& operator -= (const mll& y) {
		val = (val - y.val + MOD) % MOD;
		return *this;
	}
	mll operator * (const mll& y) { return mll(*this) *= y; }
	mll& operator *= (const mll& y) {
		val = (val * y.val) % MOD;
		return *this;
	}
	mll operator / (const mll& y) { return mll(*this) /= y; }
	mll& operator /= (const mll& y) {
		long long a = y.val, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = (((val * u) % MOD) + MOD) % MOD;
		return *this;
	}
	bool operator >= (const mll& y) {
		return this->val >= y.val;
	}
	mll pow(long long t) const {
		if (!t) return 1;
		mll a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}


	friend ostream& operator <<(ostream& os, mll& y) {
		os << y.val;
		return os;
	}
};
#undef MOD

ll N, K;
vector<pair<bool,mll> > T(100000 + 1, pair<bool,mll>(false, -1)); // T.at(i) には、{(a_1,...,a_N); 1 <= a_i <= i, gcd(a_1,...,a_N) = 1} の個数を入れる。T.at(0) = 0

mll askT(ll k) {
	if (T.at(k).first) {
		return T.at(k).second;
	}
	mll c = ((mll)k).pow(N);
	ll y = k;
	ll z = 1;
	while (true) {
		ll newy = (ll)(k / (z + 1));
		if (y - newy <= 1) break;
		c -= askT(z) * (y - newy);
		y = newy;
		z++;
	}
	while (y >= 2) {
		c -= askT((ll)(k / y));
		y--;
	}
	T.at(k).first = true;
	T.at(k).second = c;
	return c;
}

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

	cin >> N >> K;

	T.at(0) = pair<bool,mll>(true,0);
	mll c = 0;
	for (ll y = 1; y <= K; y++) {
		c += ((mll)y) * askT((ll)(K / y));
	}

	cout << c << endl;
}


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

int main() {
  
  int n;
  cin >> n;
  
  int t[n], s = 0;
  REP(i,n) {
    cin >> t[i];
    s += t[i];
  }
  
  int m;
  cin >> m;
  
  int p, x;
  REP(j,m) {
    cin >> p >> x;
    cout << s - t[p-1] + x << endl;
  }

}


Measured memory_bytes: 3460
while(True):
    h,w = [int(i) for i in input().split()]
    if(h == 0 and w == 0):
        break
    else:
        for i in range(h):
            for j in range(w - 1):
                if(i == 0 or i == h - 1 or j == 0):
                    print('#',end = '')
                else:
                    print('.',end = '')
            print('#')
    print('')

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

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define rf(i, a, b) for (int(i) = (a); (i) <= (b); (i)++)
#define rb(i, b, a) for (int(i) = (b); (i) >= (a); (i)--)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;

const int N = 1e5 + 1;
const int INF = 2e9;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    ll r = n % k;
    cout << min(r, k - r) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<int, pair<int, int>>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

int func(int a) {
    return (a % 10) + (a / 10);
}

pil rec(int d, ll c) {
    if (d == 0)
        return {0, c - 1};
    int tmp = (10 + d - 1) / d;
    if (c < tmp)
        return {d * c, c - 1};
    pil res = rec(func(d * tmp), c / tmp);
    res.second += (c / tmp) * tmp;
    c %= tmp;
    if (c) {
        res.first += d * c;
        res.second += c;
    }
    if (res.first >= 10) {
        res.first = func(res.first);
        res.second++;
    }
    return res;
}

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

    int M;
    cin >> M;
    ll cnt = 0;
    int num = 0;
    for (int i = 0; i < M; ++i) {
        int d;
        ll c;
        cin >> d >> c;
        pil tmp = rec(d, c);
        cnt += tmp.second;
        if (i > 0)
            cnt++;
        num += tmp.first;
        if (num >= 10) {
            num = func(num);
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}


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

typedef pair<int, int> P;

int main()
{
    int N, M;
    scanf("%d %d", &N, &M);
    vector<vector<int>> mp(N);
    for(int i = 0; i < M; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        --a, --b;
        mp[a].push_back(b);
        mp[b].push_back(a);
    }

    queue<P> task;
    vector<bool> vis(N, false);
    task.push(make_pair(0,0));
    vis[0] = true;
    while(!task.empty()){
        int from = task.front().first;
        int cost = task.front().second;
        if(from == N-1) {
            if(cost <= 2) cout << "POSSIBLE" << endl;
            else cout << "IMPOSSIBLE" << endl;
            return 0;
        }
        task.pop();
        if(cost >= 2) continue;
        for(int i = 0; i < mp[from].size(); ++i) {
            int to = mp[from][i];
            if(vis[to]) continue;
            vis[to] = true;
            task.push(make_pair(to, cost + 1));
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 12784
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
typedef long long int ll;

// Union Find begin

class UnionFind{
 private:
  vector<ll> _par;
  vector<ll> _rank;
 public:
  explicit UnionFind(ll n);
  ll find(ll x);
  void unite(ll x, ll y);
  bool isSame(ll x, ll y);
};

UnionFind::UnionFind(ll n) {
  for (ll i = 0; i < n; ++i) {
    _par.push_back(i);
    _rank.push_back(0);
  }
}

ll UnionFind::find(ll x) {
  if (_par.at(static_cast<unsigned long>(x)) == x) return x;
  else return _par.at(static_cast<unsigned long>(x)) = find(_par.at(static_cast<unsigned long>(x)));
}

void UnionFind::unite(ll x, ll y) {
  x = find(x);
  y = find(y);
  if (x==y) return;

  if (_rank.at(static_cast<unsigned long>(x)) < _rank.at(static_cast<unsigned long>(y)))
    _par.at(static_cast<unsigned long>(x)) =y;
  else {
    _par.at(static_cast<unsigned long>(y)) = x;
    if (_rank.at(static_cast<unsigned long>(x)) == _rank.at(static_cast<unsigned long>(y))) ++_rank.at(static_cast<unsigned long>(x));
  }

}

bool UnionFind::isSame(ll x, ll y) {
  return find(x) == find(y);
}

// Union Find end



int main() {
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  vector<ll> p(n), x(m), y(m);
  rep(i, n) cin >> p.at(i);
  rep(i, m) cin >> x.at(i) >> y.at(i);

  UnionFind uf(n);
  rep(i, m) uf.unite(x.at(i)-1, y.at(i)-1);

  ll cnt = 0;
  rep(i, n){
    if(uf.isSame(i, p.at(i)-1)) ++cnt;
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 4460
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;

int N;
int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    int count = 0;
    

    for(int i = 3; i <= N; i=i+2){
        int cou = 0;
        for(int j = 1; j <= i; j = j+2){
            if(i%j == 0) cou++;
        }
        if(cou == 8) count++;

    }
    cout << count << endl;

    

    return 0;
}

Measured memory_bytes: 256
// Problem : A - Calc
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vlli vector<int>
#define slli set<int>
#define mlli map<int,int>
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fint fast;test
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;

void solve(){
	int n;
	cin>>n;
	int k=n+(n*n)+(n*n*n);
	cout<<k;	
	return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}


Measured memory_bytes: 3640
#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 main(){
  int r;
  cin>>r;
  if(r<1200)cout<<"ABC";
  else if(r>=2800) cout<<"AGC";
  else cout<<"ARC";
  cout<<endl;
  return 0;
}


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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;

bool cek[5000100];

vector <int> prefix(string s){
    int n=s.length();
    vector <int> ans(n);

    int l=0;
    ans[0]=0;

    for (int r=1;r<n;r++){
        while (l!=0 && s[l]!=s[r]) l=ans[l-1];

        if (s[l]==s[r]){
            ans[r]=l+1;
            l++;
        }
        else ans[r]=0;
    }

    return ans;
}

int main()
{

    string s,t;
    cin >> s >> t;

    string st=s;

    while (s.length()<max(6*t.length(),6*st.length())){
        for (int i=0;i<st.length();i++){
            s.pb(st[i]);
        }
    }

    vector <int> pi_t,ans;
    pi_t=prefix(t);
    int n=s.length(),m=t.length();
    int ps=0,pt=0,cnt=0;
 //   cerr << n << " " << m << el;

    while (ps<n){
        while (pt!=0 && s[ps]!=t[pt]) pt=pi_t[pt-1];

        if (s[ps]==t[pt]) pt++;
        ps++;

        if (pt>=m){
        //    ans.push_back(ps-m+1);
            cek[ps-m]=1;
            cnt++;
        }
    }


    int res=0;
    bool infin=0;
    bool semua=1;
    for (int i=0;i<m;i++){
        int tm=0;
        bool bef=0;
        bool inf=1;
        for (int j=i;j<n-m+1;j+=m){
            inf=(inf&&cek[j]);
            semua=(semua&&cek[j]);
            if (bef){
                if (cek[j]){
                    tm++;
                } else{
                    tm=0;
                    bef=0;
                }
            } else{
                if (cek[j]){
                    tm=1;
                    bef=1;
                }
            }
            res=max(res,tm);
        }
        if (inf) infin=1;
    }

    if (semua||infin){
        cout << -1 << el;
        return 0;
    }
    cout << res << el;
    
}


Measured memory_bytes: 11784
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;
int main() {
    int n;
    cin >> n;
    int x[n][6];
    for (int i=0;i<n;i++){
        for (int j=0; j<6; j++) {
            cin >> x[i][j];
        }
    }
    
    char a[30]= {'N','N','N','N','E','E','E','N','N','N','E','E','E','N','N','N','E','N','N','N','E','N','N','N','E','E','E','N','N','N'};
    int b,c,d,e;
    b=c=d=e=0;
    for(int k=0;k<n;k++){
        for (int i=0;i<30;i++){
            if (a[i]=='E') {
                b=x[k][0];c=x[k][2];d=x[k][3];e=x[k][5];
                x[k][2]=b;x[k][5]=c;x[k][0]=d;x[k][3]=e;
                }
            
            if(a[i]=='N'){
                b=x[k][0];c=x[k][1];d=x[k][4];e=x[k][5];
                x[k][4]=b;x[k][0]=c;x[k][5]=d;x[k][1]=e;
                }
        for(int j=0;j<k;j++){
            if(x[j][0]==x[k][0]&&x[j][1]==x[k][1]&&x[j][2]==x[k][2]&&x[j][3]==x[k][3]&&x[j][4]==x[k][4]&&x[j][5]==x[k][5]){
                cout << "No"<<endl;
                exit(0);
            }
        }
            }
        if(k == n-1){
            cout << "Yes" << endl;
            
        }
        }
   
    
    }




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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int k, x; cin >> k >> x;
	k--;
	for(int i = -k; i <= k; i++){
		cout << x + i << " ";
	}
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC137A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = a + b;
            if (c < a - b)
                c = a - b;
            if (c < a * b)
                c = a * b;
            Console.WriteLine(c);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
const int MAX_K = 100100;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (auto& e : a) cin >> e;
    
    bool dp[MAX_K];
    fill(dp, dp+MAX_K, false);

    for (int j = 1; j <= k; j++) {
        for (int i = 0; i < n; i++) {
            if (j - a[i] >= 0) {
                if (dp[j-a[i]] == false) dp[j] = true;
            }
        }
    }
    
    if (dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}

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

using namespace std;

#define ll long long

void solve() {
	int a;
	cin >> a;
	cout << (a == 1 ? 0 : 1) << "\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   unik(v)       v.erase(unique(all(v)),v.end())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
void solve()
{
    string s;
    cin>>s;
    int ans=0;
    if(s[0]=='R' && s[1]=='R' && s[2]=='R'){
        cout <<3<<"\n";
        return;
    }
    else if(s[0]=='R' && s[1]=='R'){
        cout <<2<<"\n";
        return;
    }
    else if(s[1]=='R' && s[2]=='R'){
         cout <<2<<"\n";
        return;
    }
    else if(s[0]=='R' || s[1]=='R' || s[2]=='R'){
        cout <<1 <<"\n";
    }
    else cout << 0 <<"\n";
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 3608
import collections


if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))

    c = collections.Counter(a)

    l = 0
    w = 0

    max_num = -1
    for k,v in c.items():
        if max_num < k and v >= 2:
            max_num = k

    if max_num != -1:
        l = max_num
        c[max_num] = c[max_num] - 2

    max_num = -1
    for k, v in c.items():
        if max_num < k and v >= 2:
            max_num = k

    if max_num != -1:
        w = max_num
        c[max_num] = c[max_num] - 2

    print(l*w)


Measured memory_bytes: 18600
#include <iostream>
#include <cstdio>

using namespace std;

const int P=998244353;
const int G=3;
const int L=16384;

int fact[L],invf[L],f[L],g[L],h[L],t[L],trs[L];
int omega[L+5];
int n,m,len,ans;

inline int quick_power(int x,int y)
{
	int ret=1;
	for (;y;y>>=1,x=1ll*x*x%P) if (y&1) ret=1ll*ret*x%P;
	return ret;
}

void pre()
{
	fact[0]=1;
	for (int i=1;i<L;++i) fact[i]=1ll*fact[i-1]*i%P;
	invf[L-1]=quick_power(fact[L-1],P-2);
	for (int i=L-1;i>=1;--i) invf[i-1]=1ll*invf[i]*i%P;
}

inline int C(int n,int m){return n>=m?1ll*fact[n]*invf[m]%P*invf[n-m]%P:0;}

void NTT_pre()
{
	for (len=1;len<=n<<1;len<<=1);
	for (int i=0,ret;i<len;++i)
	{
		ret=0;
		for (int x=i,j=1;j<len;j<<=1,x>>=1) ret=(ret<<1)|(x&1);
		trs[i]=ret;
	}
	int g=quick_power(G,(P-1)/len);omega[0]=1;
	for (int i=1;i<=len;++i) omega[i]=1ll*omega[i-1]*g%P;
}

void DFT(int *a,int sig)
{
	for (register int i=0;i<len;++i) t[trs[i]]=a[i];
	for (register int l=2;l<=len;l<<=1)
		for (register int h=l>>1,j=0,wn=omega[sig>0?len/l:len-len/l];j<len;j+=l)
			for (register int i=0,w=1;i<h;++i,w=1ll*w*wn%P)
			{
				register int u=t[i+j],v=1ll*t[i+j+h]*w%P;
				t[i+j]=(u+v)%P,t[i+j+h]=(u-v+P)%P;
			}
	for (register int i=0;i<len;++i) a[i]=t[i];
	if (sig<0) for (register int i=0,inv=quick_power(len,P-2);i<len;++i) a[i]=1ll*a[i]*inv%P;
}

int main()
{
	//freopen("trinity.in","r",stdin),freopen("trinity.out","w",stdout);
	scanf("%d%d",&n,&m),pre(),NTT_pre();
	f[0]=1;
	for (int i=1;i<=n;++i) g[i]=invf[i+2];
	DFT(g,1);
	for (int i=1;i<=m;++i)
	{
		for (int j=0;j<=n;++j) h[j]=1ll*f[j]*invf[j]%P;
		for (int j=n+1;j<len;++j) h[j]=0;
		DFT(h,1);
		for (int j=0;j<len;++j) h[j]=1ll*h[j]*g[j]%P;
		DFT(h,-1);
		for (int j=0;j<=n;++j) f[j]=(1ll*fact[j+2]*h[j]%P+1ll*(C(j+1,2)+1)*f[j]%P)%P;
	}
	ans=0;
	for (int i=0;i<=n;++i) (ans+=1ll*C(n,i)*f[i]%P)%=P;
	printf("%d\n",ans);
	//fclose(stdin),fclose(stdout);
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin>>H.at(i);
  }
  int count = N;/*見える数を条件を満たす度に減らしていく*/
  for(int i=1;i<N;i++){/*2番目からスタート*/
    for(int j=i-1;j>=0;j--){/*(i+1)番目までの山の高さを(i+1)番目の山と比較*/
      if(H.at(i)<H.at(j)){/*自分より高い山があった時点でその山からは海は見えないのでbreak;*/
        count--;
        break;
      }
    }
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

main(){
  int n, m, now, num, data[1001], count, ans, i;
  
  while(1){
    scanf("%d %d", &n, &m);
    if(n==0 && m==0) break;
    for(i=0;i<=n;i++) data[i]=1;
    num=n;
    now=1;
    count=0;
    while(1){
      if(num<=1){
	ans=now;
	break;
      }
      count++;
      if(count==m){
	count=0;
	num--;
	
	data[now]=0;
	while(1){
	  now++;
	  if(now>n) now=1;
	  if(data[now]==1) break;
	}
	continue;
      }
      while(1){
	now++;
	if(now>n) now=1;
	if(data[now]==1) break;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#define INF 1000000007
using namespace std;

int main(void){
    double a, b;
    cin >> a >> b;
    cout << int(a / b) << ' ' << int(a) % int(b) << ' '  << fixed << a / b << endl;

    return 0;
}


Measured memory_bytes: 3292
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			Polyline base = new Polyline(sc);
			for (int i = 1; i <= N; ++i) {
				Polyline it = new Polyline(sc);
				if (equal(base, it) || equal(base, it.rev())) {
					System.out.println(i);
				}
			}
			System.out.println("+++++");
		}
	}

	static boolean equal(Polyline pa, Polyline pb) {
		if (!Arrays.equals(pa.len, pb.len)) return false;
		for (int i = 0; i < 4; ++i) {
			boolean ok = true;
			for (int j = 0; j < pa.dir.length; ++j) {
				if (pa.dir[j] != (pb.dir[j] + i) % 4) {
					ok = false;
					break;
				}
			}
			if (ok) return true;
		}
		return false;
	}

	static class Polyline {

		int[] dir;
		int[] len;

		Polyline(Scanner sc) {
			int m = sc.nextInt();
			dir = new int[m - 1];
			len = new int[m - 1];
			int x = sc.nextInt();
			int y = sc.nextInt();
			for (int i = 0; i < m - 1; ++i) {
				int nx = sc.nextInt();
				int ny = sc.nextInt();
				if (nx < x) {
					dir[i] = 0;
				} else if (ny < y) {
					dir[i] = 1;
				} else if (x < nx) {
					dir[i] = 2;
				} else {
					dir[i] = 3;
				}
				len[i] = Math.abs(x - nx) + Math.abs(y - ny);
				x = nx;
				y = ny;
			}
		}

		Polyline() {
		}

		Polyline rev() {
			Polyline ret = new Polyline();
			int m = this.dir.length;
			ret.dir = new int[m];
			ret.len = new int[m];
			for (int i = 0; i < m; ++i) {
				ret.dir[i] = (this.dir[m - 1 - i] + 2) % 4;
				ret.len[i] = this.len[m - 1 - i];
			}
			return ret;
		}
	}

}

Measured memory_bytes: 29148
#include <iostream>
#include <cmath>

using namespace std;
int isPrime(int n){
	for(int i=2; i<=sqrt(n); i++){
		if(n%i == 0){
			return 0;
		}
	}
	return 1;
}
int main() {
	int n, t;
	int ans = 0;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> t;
		if(isPrime(t)){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18

#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x, y;
	cin >> x >> y;
	int cnt = 0;
	ll now = x;
	while(now <= y){
		cnt++;
		now *= 2;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#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) cout << #x << ": " << x << endl
#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 fi first
#define se second
#define endl '\n'
const int MAXN = 1e5;

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

struct DSU{
	int S;
	struct node{
		int parent; ll sum;
	};
	vector<node> dsu;
	DSU(int n){
		S = n;
		rep(i, n){
			node tmp;
        		//set parent to itself
			tmp.parent = i; tmp.sum = 1;
			dsu.pb(tmp);
		}
	}
	void reset(int n){
		dsu.clear();
		S = n;
		rep(i, n){
			node tmp;
			tmp.parent = i; tmp.sum = 1;
			dsu.pb(tmp);
		}
	}
	int root(int u){
		if(dsu[u].parent == u) return u;
                //it works if a there is a subset of subset of a set (dfs)
		dsu[u].parent = root(dsu[u].parent);
		return dsu[u].parent;
	}
	void merge(int u, int v){
		u = root(u); v = root(v);
		if(u == v) return;
		//we choose to grow bigger sets over little sets (merge / unite by rank)
		//that alows us to use less memory and avoid MLE
		if(getsum(u) < getsum(v)) swap(u, v);
		//we don't erase the sum
		//it is fine since it is not pointing to itself
		dsu[v].parent = u;
		dsu[u].sum += dsu[v].sum;
	}
	bool sameset(int u, int v){
		if(root(u) == root(v)) return true;
		return false;
	}	
	ll getsum(int u){
		return dsu[root(u)].sum;
	}
};

ll a[2 * MAXN], b[2 * MAXN];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	DSU dsu(2 * MAXN);
	memset(a, 0, sizeof(a));
	memset(b, 0, sizeof(b));
	rep(i, n){
		int x, y;
		cin >> x >> y;
		x-- , y--;
		dsu.merge(x, MAXN + y);
	}
	rep(i, MAXN){
		a[dsu.root(i)]++;
		b[dsu.root(i + MAXN)]++;
	}
	ll ans = 0;
	rep(i, 2 * MAXN) if(dsu.root(i) == i) ans += a[i] * b[i];
	cout << ans - n << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 7532