akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

typedef long long ll;
const ll MOD = 1000000007;
const int MAX_N = 100000;
bool used[MAX_N+5];
int idx[MAX_N+5];
ll fact[MAX_N+2];
ll inv_fact[MAX_N+2];

ll power(const int b, ll p) {
  ll res = b;
  ll ans = 1;
  while (p > 0) {
    if (p % 2 == 1) {
      ans = res * ans % MOD;
    }
    p = p >> 1;
    res = res * res % MOD;
  }
  return ans;
}

void make_fact_table(int n) {
  fact[0] = 1;
  inv_fact[0] = 1;
  ll f = 1;
  for (int i = 1; i <= n; i++) {
    f = f * i % MOD;
    fact[i] = f;
    inv_fact[i] = power(f, MOD - 2);
    //cout << i << " "  << fact[i] << " " << inv_fact[i] << endl;
  }
}

ll combination(ll n, ll k) {
  if (n < k) return 0;
  ll x = fact[n] * inv_fact[k] % MOD;
  //cout << "x: " << x << endl;
  //cout << "n-k: " << n-k << ", comb: " << inv_fact[n-k] << endl;
  return x * inv_fact[n-k] % MOD;
}

ll solve(int k, int n, int p) {
  ll ans, comb;
  comb = combination(n, k) - combination(p, k-1);
  ans = (MOD + comb) % MOD;
  // cout << ans << " " << k << endl;
  return ans;
}

int main() {
  int n;
  cin >> n;
  make_fact_table(n+1);
  fill(used, used+n, false);
  int inter;
  for (int i = 0; i < n+1; i++) {
    int x;
    cin >> x;
    if (used[x] == true) {
      inter = i - idx[x] + 1;
    }
    used[x] = true;
    idx[x] = i;
  }
  int p = n+1 - inter;
  for (int i = 1; i <= n+1; i++) {
    cout << solve(i, n+1, p) << endl;
  }
}

Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int X;cin >> X;
    int A = X/100;
    if(A*100 <= X && X <= 105*A){
        cout << 1 << endl;
    }
    else cout << 0 << endl;
}

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

int main() {

    long long int n;
    cin >> n;

    long long int cnt = 0;
    bool ans = true;

    for ( long long int i = 0; i < n; i++ ) {
        long long int in;
        cin >> in;

        if ( in > cnt ) in--;
        if ( in < cnt ) ans = false;

        cnt = in;
    }

    if ( ans ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;

}


Measured memory_bytes: 256
def solve():
  ans = float('inf')
  H, W = map(int, input().split())
  for h in range(1,H):
    o1 = (H-h)//2*W
    o2 = (H-h)*W-o1
    a = [h*W,o1,o2]
    ans = min(ans,max(a)-min(a))
    o1 = W//2*(H-h)
    o2 = (H-h)*W-o1
    a = [h*W,o1,o2]
    ans = min(ans,max(a)-min(a))
  for w in range(1,W):
    o1 = (W-w)//2*H
    o2 = (W-w)*H-o1
    a = [w*H,o1,o2]
    ans = min(ans,max(a)-min(a))
    o1 = H//2*(W-w)
    o2 = (W-w)*H-o1
    a = [w*H,o1,o2]
    ans = min(ans,max(a)-min(a))
  return ans
print(solve())

Measured memory_bytes: 73912
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 3000 + 5;
const int MOD = 998244353;
int arr[MAX], memo[MAX][MAX][3];
int n, s;

inline int add(int a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
    return a;
}

int roll(int idx, int sum, int state) {
    if (state == 2) {
        return sum == 0;
    }
    if (sum < 0 or idx > n) {
        return 0;
    }
    int &ans = memo[idx][sum][state];
    if (~ans) {
        return ans;
    }
    ans = 0;
    if (state == 0) {
        int a = roll(idx + 1, sum, state);
        int b = roll(idx + 1, sum, 1);
        int c = roll(idx + 1, sum - arr[idx], 1);
        int d = roll(idx + 1, sum - arr[idx], 2);
        ans = add(add(a, b), add(c, d));
    }
    if (state == 1) {
        int a = roll(idx + 1, sum, state);
        int b = roll(idx + 1, sum, 2);
        int c = roll(idx + 1, sum - arr[idx], state);
        int d = roll(idx + 1, sum - arr[idx], 2);
        ans = add(add(a, b), add(c, d));
    }
    return ans;
}

void solve() {
    cin >> n >> s;
    fori (i, 1, n + 1) cin >> arr[i];
    memset(memo, -1, sizeof memo);
    cout << roll(1, s, 0) << endl;
}

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



Measured memory_bytes: 106240
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top = 0, S[1000];

void push(int x) {
  S[++top] = x;
}

int pop(void) {
  top--;
  return S[top+1];
}

int main(void) {
  int a, b;
  top = 0;
  char s[100];
  while(scanf("%s",s) != EOF) {
    if(s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if(s[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    } else if(s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}


Measured memory_bytes: 2724
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)

//C++で提出








	int main()
	{
		int n, a, b;
		cin >> n >> a >> b;
		int Ans = 0;
		int j;

		for (j = a; j <= b; j++) {
			for (int k = 1; k <= n; k++) {
				if (k/10000%10+k/1000%10+k/100%10+k / 10%10 + (k % 10) == j) {
					Ans += k;
				}
			}
		}

		cout << Ans;
	}
	




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;  
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
 
const int MOD = 1e9 + 7; 
const int N = 1e5+10; 
const int INF = 1e9 + 5; 

int main(void) 
{

	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
	#endif

	int n; 
	cin >> n; 
	ll ans =0; 
	for (int a=1; a<=n; a++) 
	{
		if (a%3 == 0 && a%5==0) continue; 
		else if (a%3==0) continue; 
		else if (a%5==0) continue; 
		else ans+=a; 
	}
	cout << ans << '\n'; 
	return false; 
}


Measured memory_bytes: 3636
from collections import Counter

N = int(input())
A = tuple(map(int, input().split(' ')))
counter = Counter(A)
Q = int(input())
s = sum(A)
for _ in range(Q):
    B, C = map(int, input().split(' '))
    diff = (C - B) * counter[B]
    s += diff
    counter[C] += counter[B]
    counter[B] = 0
    print(s)


Measured memory_bytes: 24196
def solve(c, f, s, n, idx)
    cur = 0
    idx.upto(n - 2) do |i|
        cur = ([cur - s[i], 0].max + f[i] - 1) / f[i] * f[i] + s[i] + c[i]
    end
    return cur
end

n = gets.to_i
c = Array.new(n - 1)
s = Array.new(n - 1)
f = Array.new(n - 1)
(n-1).times do |i|
    c[i], s[i], f[i] = gets.split.map(&:to_i)
end
n.times do |i|
    p solve(c, f, s, n, i)
end

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

int main() {
    long long n;
    cin>>n;
    long long c=0;
    if(n&1){
        cout<<0<<endl;
        return 0;
    }
    for(long long i=10;i<=n;i*=5){
        c+=n/i;
    }
    cout<<c<<endl;
    
	return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define int long long int
#define endl '\n'
using namespace std;

int a[110];

void solve(){
    int n , m, sum = 0 , cnt = 0; cin >> n >> m;

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

    for(int i = 0 ; i < n; ++i){
        if(a[i]*4*m >= sum) cnt++;
    }

    if(cnt >= m){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int maxtime(int x){
    return (x+9) /10 *10;
}
int difftime(int x){
    return maxtime(x)-x;
}
int main(){
    vector<int> a(5,0);
    int total = 0;
    for(int i=0;i<5;i++){ 
        cin >> a[i];
        total += maxtime(a[i]);
    }
    total -= max({difftime(a[0]), difftime(a[1]),difftime(a[2]),difftime(a[3]),difftime(a[4]) });
    cout << total << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int nam[100001];
bool vis[100001];
vector<int> a[100001];
queue<int> q;
bool ok=false;
int n,u,k,x,m,qq,s,e,t=1;
void dfs(int k){
	 if (k==e)
	    ok=true;
	 if (ok) return; 
     vis[k]=true;
	 for (int i=0; i<a[k].size(); i++){
	     if (!vis[a[k][i]] && !ok){
	     	dfs(a[k][i]);
		 }
     }
}
int main(){
	memset(a,0,sizeof(a));
	memset(vis,false,sizeof(vis));
	memset(nam,0,sizeof(nam));
	cin>>m>>n;
	for (int i=0; i<n; i++){
		cin>>u>>k;
		a[u].pb(k);
		a[k].pb(u);
	}
	cin>>qq;
	while (qq--){
	       ok=false; 
	       while (!q.empty()) q.pop();
		   cin>>s>>e;
		   if (!vis[s]){
		      q.push(s); 
		      while (!q.empty()){
		   	        x=q.front(); vis[x]=true; q.pop(); 
		   	        nam[x]=t;
				    for (int i=0; i<a[x].size(); i++){
	                    if (!vis[a[x][i]])
	     	               q.push(a[x][i]);
                    }
		      }
		      t++;
		  }
		  if (nam[s]==nam[e])
		      cout<<"yes"<<endl;
		   else 
		      cout<<"no"<<endl;	
	} 
	return 0;
}


Measured memory_bytes: 9028
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>
#include <set>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    FAST_IO
    ll r;
    cin >> r;
    cout << r * r;
}


Measured memory_bytes: 3156
// Code for A - Disjoint Set Union
#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;

int main(){
	int n, q; cin >> n >> q;
	dsu d(n);
	while(q--){
		int t, u, v;
		cin >> t >> u >> v;
		if(t==0)
			d.merge(u,v);
		else
			cout << d.same(u,v) << endl;
	}
	return 0;
}


Measured memory_bytes: 4028
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int n;
    cin >> n;
    int i = n;
    while (1) {
        if (i < 10) {
            cout << i << endl;
            return 0;
        }
        else if (i < 100) {
            if (i /10 == i %10) {
                cout << i << endl;
                return 0;
            }
        } else if (i < 1000) {
            if (i % 10 == (i /10) % 10 && i%10 == (i/10) /10) {
                cout << i << endl;
                return 0;
            }
        }
        ++i;
    }
}

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

struct UnionFind {
    vector<int64_t> par;
    vector<int64_t> count;
    
    UnionFind (int64_t n): par(n+1), count(n+1) {
        for ( int64_t i = 0; i < n; ++i){
            par[i] = i;
            count[i] = 1;
        }
    }
    
    int64_t root (int64_t x){
        if (par[x] == x){
            return x;
        } else {
            return par[x] = root(par[x]);
        }
    }
    
    void unite (int64_t x, int64_t y){
        int64_t rx = root(x);
        int64_t ry = root(y);
        if ( rx == ry ) return;
        if ( rx > ry ){
            count[rx] += count[ry];
            par[ry] = rx;
        } else {
            count[ry] += count[rx];
            par[rx] = ry;
        }
    }
    
    bool same ( int64_t x, int64_t y){
        int64_t rx = root(x);
        int64_t ry = root(y);
        return rx == ry;
    }
    
    int64_t size ( int64_t x ){
        return count[root(x)];
    }
};

int main(){
    int64_t N, M;
    cin >> N >> M;
    vector<int64_t> A(M), B(M);
    for ( int64_t i = 0; i < M; ++i){
        cin >> A.at(i) >> B.at(i);
    }
    
    UnionFind tree(N);
    
    vector<int64_t> ans(M);
    
    int64_t res = N * (N-1) / 2;
    for ( int64_t i = M - 1; i >=0; --i){
        int64_t a,b;
        a = A.at(i); b = B.at(i);
        //cout << res << endl;
        ans.at(i) = res;
        if ( tree.same (a,b) == false ){
            int64_t asize, bsize;
            asize = tree.size(a); bsize = tree.size(b);
            res = res - asize * bsize;
        }
        tree.unite(a,b);
    }
    
    for (int64_t i = 0; i < M; ++i){
        cout << ans.at(i) << endl;
    }
    
    return 0;
}



Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    vector<long long> a(n, 0);
    for(int i = 0; i < n; ++i) cin >> a.at(i);

    vector<long long> x(n, 0);
    for(int i = 0; i < n; ++i) {
        if(i % 2 == 0) x.at(0) += a.at(i);
        else x.at(0) -= a.at(i);
    }

    for(int i = 0; i < n-1; ++i) {
        x.at(i+1) = 2*a.at(i) - x.at(i);
    }

    for(int i = 0; i < n; ++i) {
        cout << x.at(i) << " ";
    }
}

Measured memory_bytes: 2944
/** BiSmIlLaHiR rAhMaNiR rAhIm **\

*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*
*$*                                             *$*
*$*    ||||||||  ||||||||  ||||||||  ||||||||   *$*
*$*    ||    ||  ||           ||     ||         *$*
*$*    ||||||||  ||||||||     ||     ||||||     *$*
*$*    ||    ||        ||     ||     ||         *$*
*$*    ||    ||  ||||||||  ||||||||  ||         *$*
*$*                                             *$*
*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*

            \**  DIIT(17th batch) **/

#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define pf printf
#define sf scanf
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define makep make_pair
#define MOD 1000000007
#define PI 2*acos(0.0)
#define PII pair<ll, ll>
#define pii pair<int, int>
#define what_is(x) cerr<<#x<<" is "<<x<<endl;
#define fio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    fio();*/
    ll i,count=0;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
    	if(s[i]=='-')
    		count--;
    	else
    		count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

struct P {
  int y,x,t,d;
  P(int y, int x, int t, int d) :y(y),x(x),t(t),d(d) {}
};
bool operator<(const P &a, const P& b) {
  return a.d > b.d;
}

int ba[210][210];
int dist[210][210][6];

int main() {
  int sx,sy,gx,gy;
  while(cin>>sx>>sy>>gx>>gy) {
    int n;
    cin >> n;
    memset(ba,0,sizeof(ba));
    REP(i,n) {
      int x, y;
      cin >> x >> y;
      ba[y+100][x+100] = 1;
    }
    int lx,ly;
    cin >> lx >> ly;
    priority_queue<P> Q;
    Q.push(P(sy,sx,0,0));
    REP(i,210)REP(j,210)REP(k,6) dist[i][j][k] = INF;
    dist[sy+100][sx+100][0] = 0;

    const int dx[7] = {0,1,1,0,-1,-1,0};
    const int dy[2][7] = {{1,0,-1,-1,-1,0,0},
                          {1,1,0,-1,0,1,0}};
    int ans = -1;
    while(!Q.empty()) {
      P p = Q.top(); Q.pop();
//      cout << p.y << " " << p.x << endl;
      if (dist[p.y+100][p.x+100][p.t] < p.d) continue;

      if (p.y == gy && p.x == gx) {
        ans = p.d;
        break;
      }
      int dir = abs(p.x*p.y*p.t) % 6;
      
      REP(i,7) {
        int cost = 1;
        if (i==dir) cost = 0;
        int dd = p.d + cost;
        int yy = p.y + dy[abs(p.x)%2][i];
        int xx = p.x + dx[i];
        int tt = (p.t + 1) % 6;
        if (abs(yy)>ly || abs(xx)>lx) continue;
        if (ba[yy+100][xx+100]) continue;
        if (dist[yy+100][xx+100][tt] > dd) {
          dist[yy+100][xx+100][tt] = dd;
          Q.push(P(yy,xx,tt,dd));
        }
      }
    }
    cout << ans << endl;
  }
}

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

int main(int argc, char const *argv[])
{
	string s; cin >> s;
	int n = s.size(), ans = 0;
	for (int i = 0; i < n / 2; i++) {
		if (s[i] != s[n - i - 1])
			ans++;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int dfs(vector<vector<int> > &field, int y, int x) {
    int dx[] = {1, -1, 0, 0};
    int dy[] = {0, 0, 1, -1};

    field[y][x] = 0;
    int ans = 0;
    for(int i = 0; i < 4; ++i) {
        int nx = x+dx[i];
        int ny = y+dy[i];
        if(field[ny][nx]) {
            ans = max(ans, dfs(field, ny, nx)+1);
        }
    }
    field[y][x] = 1;
    return ans;
}

int main() {
    while(true) {
        int M, N;
        cin >> M >> N;
        if(!M && !N) break;

        vector<vector<int> > field(M+2, vector<int>(N+2, 0));
        for(int i = 1; i <= M; ++i) {
            for(int j = 1; j <= N; ++j) {
                cin >> field[i][j];
            }
        }

        int ans = 0;
        for(int i = 1; i <= M; ++i) {
            for(int j = 1; j <= N; ++j) {
                if(field[i][j]) ans = max(ans, dfs(field, i, j)+1);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

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

const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;

int main() {
#ifdef Mr_Emrul
	freopen("inputf.in", "r", stdin);
#endif /// Mr_Emrul

	long double n, sum = 1, x;
	cin >> n;
	bool f = 0;
	bool zero = 0;
	while(n--) {
		cin >> x;
		if(!x) {
			zero = 1;
		}
		sum *= x;
		if(sum > 1e18) {
			f = 1;
		}
	}
	if(zero) {
		sum = 0;
	}
	else if(f) {
		sum = -1;
	}
	cout << setprecision(0) << fixed << sum << endl;
	return 0;
}

Measured memory_bytes: 3792
// finish date: 2018/02/24

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N, L;
    cin >> N >> L;
    int a, b;
    int checkpoint = 0;
    rep(i, N) {
        cin >> a;
        if (i >= 1 && a + b >= L) checkpoint = i;
        b = a;
    }
    if (checkpoint == 0) cout << "Impossible" << endl;
    else {
        cout<<"Possible"<<endl;
        for (int i = 1; i < checkpoint; i++) cout << i << endl;
        for (int i = N - 1; i >= checkpoint; i--) cout << i << endl;
    }

    return 0;
}





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


int main(){
    int n, x, ans;
    vector<int> final;
    while(1){
        ans = 0;
        cin >> n >> x;
        if (n == 0 && x == 0) exit(0);
        for (int i = 1; i <= n-2; i++){
            for (int j = i+1; j <= n-1; j++){
                for (int k = j+1; k <= n; k++){
                    if (i + j + k == x) {
                        ans++;
                    }
                }
            }
        }
        cout << ans << endl;
    } 
    return 0;
}


Measured memory_bytes: 3092
N, W = gets.split.map(&:to_i)
items = []

N.times do
  v, w = gets.split.map(&:to_i)
  items << [v, w]
end

dp = Array.new(N + 1) { Array.new(W + 1, 0) }

N.times do |i|
  v, w = items[i]

  (1..W).each do |j|
    dp[i + 1][j] = [dp[i + 1][j], dp[i][j - w] + v].max if j - w >= 0
    dp[i + 1][j] = [dp[i + 1][j], dp[i][j]].max
  end
end

p dp[N][W]



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

long long a[1005];

int main(){
	int n,q,c,b,e;
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	cin>>q;
	for(int i=0;i<q;i++){
		long long minn=20000000000,maxn=-20000000000;
		cin>>c>>b>>e;
		switch(c){
			case 0:
				for(int j=b;j<e;j++){
					minn=min(minn,a[j]);
				}
				cout<<minn<<endl;
				break;
			case 1:
				for(int j=b;j<e;j++){
					maxn=max(maxn,a[j]);
				}
				cout<<maxn<<endl;
				break;
		}
	}
	return 0;
}


Measured memory_bytes: 3120
#include<stdio.h>

int main(){
int H,W;
int i;
int j;

while(1){
scanf("%d %d",&H,&W) ;

if(H==0 && W==0)
break ;



for(i=0;i<H;i++){

    for(j=0;j<W;j++){
     printf("#");
    }
    printf("\n") ;
}

printf("\n") ;


}
return 0 ;

}

Measured memory_bytes: 572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication18
{

    //ONLINE JUDGE (ITP1_9_D)

    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char[] ch = str.ToCharArray();
            int q = int.Parse(Console.ReadLine());

            for (int i = 0; i < q; ++i)
            {
                string[] meirei = Console.ReadLine().Split(' ');
                

                int a = int.Parse(meirei[1]);
                int b = int.Parse(meirei[2]);
    
                if (meirei[0] == "replace")
                {
                    string p = meirei[3];
                    for (int j = 0; j < b - a + 1; ++j)
                    {
                        ch[j + a] = p[j];
                    }
                    continue;
                }
                else if (meirei[0] == "reverse")
                {
                    
                    Array.Reverse(ch,a, b - a + 1);
                }
                else
                {
                    for (int j = a; j <= b; ++j)
                    {
                        Console.Write(ch[j]);
                    }
                    Console.WriteLine();
                }
            }

        }
    }
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  bool check=true;
  for(int i=0;i<n;i++){
    if(a[i]>i+1){
      check=false;
    }
  }
  if(!check){
    cout << -1 << endl;
  }
  else{
    int ans[n];
    for(int i=n-1;i>=0;i--){
      int point;
      for(int j=0;j<n;j++){
        if(a[j]==j+1){
          ans[i]=j+1;
          point=j;
        }
      }
      for(int j=point;j<i;j++){
        a[j]=a[j+1];
      }
      a[i]=-1;
    }
    for(int i=0;i<n;i++){
      cout << ans[i] << endl;
    }
  }
}

Measured memory_bytes: 256
import sys
def main():
    N=int(sys.stdin.readline())
    p=[float(x) for x in sys.stdin.readline().split()]
    dp=[[0 for _ in range(N+1)] for _ in range(N+1)]
    dp[0][0]=1.0
    for i in range(1,N+1):
        dp[i][0]=dp[i-1][0]*(1-p[i-1])
        for j in range(1,N+1):dp[i][j]=dp[i-1][j-1]*p[i-1]+dp[i-1][j]*(1-p[i-1])
    print(sum(dp[N][N//2+1:]))
if __name__=='__main__':main()

Measured memory_bytes: 224048
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N, T;
    cin >> N >> T;
    vi t(N);
    rep(i, N) {
        cin >> t[i];
    }

    int res = 0;
    rep(i, N-1) {
        int temp = min(T, t[i+1]-t[i]);
        res += temp;
    }
    res += T;

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

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

const int MOD = 998244353;
int poww(int a , int b){int tms = 1; while(b){if(b & 1) tms = 1ll * tms * a % MOD; a = 1ll * a * a % MOD; b >>= 1;} return tms;}
int mex[3][503] , N , M , ans; vector < int > nxt[100003];

void calc(int *arr){
	for(int i = 1 ; i <= N ; ++i) nxt[i].clear();
	cin >> M; for(int i = 1 ; i <= M ; ++i){int p , q; cin >> p >> q; nxt[min(p , q)].push_back(max(p , q));}
	static int tmp[503] , val[100003]; memset(val , 0 , sizeof(val));
	for(int i = N ; i ; --i){
		for(auto t : nxt[i]) tmp[val[t]] = 1;
		while(tmp[val[i]]) ++val[i];
		for(auto t : nxt[i]) tmp[val[t]] = 0;
		arr[val[i]] = (arr[val[i]] + poww(10 , 18 * i)) % MOD;
	}
}

int main(){
	cin >> N; calc(mex[0]); calc(mex[1]); calc(mex[2]);
	for(int i = 0 ; i <= 500 ; ++i)
		for(int j = 0 ; j <= 500 ; ++j)
			ans = (ans + 1ll * mex[0][i] * mex[1][j] % MOD * mex[2][i ^ j]) % MOD;
	cout << ans; return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj,n,m,a,b,c,e,f,g,h,r,w,l,num,ans,sum,ok,ng,mid;
ll x[500005],y[500005],z[500005];
ll segtree[500005];
char s[500005],t[500005],u[500005];
bool dame,flag;
ll segn;

void seginit(ll n_){	
	segn = 1;
	while(segn < n_)segn *= 2;
	for(int i=0;i<2*segn-1;i++)segtree[i] =0;
}
void update(ll k,ll a){
	//k := 0-indexed
	k += segn - 1;
	segtree[k] = a;
	while(k > 0){
		k = (k-1)/2;
		segtree[k] = max(segtree[k * 2 + 1],segtree[k * 2 + 2]);
	}
}
ll query(ll a,ll b,ll k,ll l,ll r){
	//when call:query(a ,b ,0, 0, n)
	//min of [a,b)
	if(r <= a || b <= l)return 0;
	if(a <= l && r <= b){
		return segtree[k];
	}else{
		ll vl = query(a,b,k * 2 + 1,l ,(l + r) / 2);
		ll vr = query(a,b,k *+ 2 + 2,(l + r )/2 ,r);
		return max(vl,vr);
	}
}

int main(){
	cin >> n;
	seginit(n);
	for(i=0;i<n;i++){
		update(i,0);
	}
	for(i=0;i<n;i++){
		cin >> x[i];
		x[i]--;
	}
	for(i=0;i<n;i++){
		cin >> y[i];
	}
	for(i=0;i<n;i++){
		a = query(0,x[i],0,0,segn) + y[i];
		//pe(i);pe(x[i]);p(a); 
		update(x[i],a);
		for(j=0;j<n;j++){
			//pe(query(j,j+1,0,0,segn));
		}
		//el;
	}
	ans = query(0,n,0,0,segn);
	p(ans);

	
	return 0;
}

Measured memory_bytes: 37248
{-# LANGUAGE PartialTypeSignatures #-}
module Main (main) where

import Data.Array
import Control.Monad
import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = do
  [n,m,q] <- readInts
  replicateM q readInts >>= output . solve n m

solve :: Int -> Int -> [[Int]] -> _
solve n m xs = maximum . map go $ genAscList m n
  where
    go as =
      let arr = listArray (1,n) as
       in sum [ d | [a,b,c,d] <- xs, (arr!b) - (arr!a) == c ]

genAscList :: Int -> Int -> [[Int]]
genAscList = gen 1
  where
    gen _ m 0 = [ [] ]
    gen a m n = [ i:is | i <- [a..m], is <- gen i m (pred n) ]

output :: _ -> IO ()
output = print

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine

Measured memory_bytes: 6640
a,b,k = map(int,input().split())
m = b if a<b else a
count = 0
cd = []
for i in range(1,m+1) :
	if a%i == 0 and b%i==0 :
		count+=1
		cd.append(i)
cd.sort(reverse=True)
print(cd[k-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define printvector(v,n) for(int i=1;i<=n;i++) cout<<v[i]<<" "; cout<<ln;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for int64)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define RFOR(i,b,a) for(int i=b; i>=a; i--)
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define setPresent(x,s) (s.find(x)!=s.end())
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
typedef map<ll,ll> m64;
#pragma GCC optimize ("-O2")
template<class T> using min_heap = priority_queue<T, std::vector<T>, std::greater<T> >; 
const int LM=1e5;
int n,v[LM+2];
int main()
{    
    ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	FOR(i,1,n) cin>>v[i];
	int ans=1e9;
	v32 c1(1e5+1,0);
	FOR(i,1,n/2){
		c1[v[2*i]]++;
	}
	set<p32> s1; s1.insert(mp(n/2,0));
	FOR(i,1,1e5) s1.insert(mp(n/2-c1[i],i));
	v32 c2(1e5+1,0);
	FOR(i,1,n/2){
		c2[v[2*i-1]]++;
	}
	FOR(i,1,1e5){
		s1.erase(mp(n/2-c1[i],i));
		ans=min(ans,n/2-c2[i]+(*(s1.begin())).fi);
		s1.insert(mp(n/2-c1[i],i));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6144
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int A  = sc.nextInt();
		int B  = sc.nextInt();
		int Q  = sc.nextInt();

		Long[] AA = new Long[A+2];
		Long[] BB = new Long[B+2];
		Long[] QQ = new Long[Q+2];

		for(int i = 1 ; i <= A ; i++){
			AA[i] = sc.nextLong();
		}
		for(int i = 1 ; i <= B ; i++){
			BB[i] = sc.nextLong();
		}
		for(int i = 1 ; i <= Q ; i++){
			QQ[i] = sc.nextLong();
		}

		AA[A+1] = 100000000001L;
		BB[B+1] = 100000000001L;

		AA[0] = (long) -100000000001l;
		BB[0] = (long) -100000000001l;
		sc.close();

		int s1 = 0;
		int t1 = 0;



		for(int i = 1 ; i <= Q ; i++){
			int L = 0;
			int R = A+1;
			while(L<R){
				int M = (L+R)/2;
				if(AA[M]<QQ[i] && AA[M+1]>QQ[i]){
					s1 = M;
					break;
				}
				else if(AA[M+1] < QQ[i]){
					L = M+1;
				}
				else if(AA[M] > QQ[i]){
					R = M;
				}
			}

			int L1 = 0;
			int R1 = B+1;
			while(L1<R1){
				int M = (L1+R1)/2;

				if(BB[M]<QQ[i] && BB[M+1]>QQ[i]){
					t1 = M;
					break;
				}
				else if(BB[M+1] < QQ[i]){
					L1 = M+1;
				}
				else if(BB[M] > QQ[i]){
					R1 = M;
				}
			}
			//System.out.println(i + " " + AA[s1] + " " + AA[s1+1] + " " + BB[t1] + " " + BB[t1+1]);
			long[] SS = {AA[s1],AA[s1+1]};
			long[] TT = {BB[t1],BB[t1+1]};
			long ans = 90000000001l;
				for(int ii = 0 ; ii < 2 ; ii++){
					for(int jj = 0 ; jj < 2 ; jj++){
						//System.out.println(QQ[i] + " " + SS[ii] + " " + TT[jj]);
						if(SS[ii] > 0 && TT[jj] > 0 && SS[ii] <  100000000001L && TT[jj]<  100000000001L){
							ans = Math.min(ans, Math.abs(QQ[i]-SS[ii])+Math.abs(SS[ii]-TT[jj]));
							ans = Math.min(ans, Math.abs(QQ[i]-TT[jj])+Math.abs(TT[jj]-SS[ii]));
							//System.out.println(ans);
						}
					}
				}
				System.out.println(+ans);
		}

	}
}

Measured memory_bytes: 118332
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
#define MAX 100

void solve(void){
    double a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    double water = 0, sugar = 0, noudo = 0;
    rep(MAX, j) {
        rep(MAX, i){
            if ((a*i + b*j) * 100 > f) break;
            double temp_water  = (a*i + b*j) * 100;
            rep(MAX, l){
                rep(MAX, k){
                    if (((a*i + b*j) * e >= c * k + d * l) and (temp_water + c * k + d * l <= f)){
                        double temp_sugar = c * k + d * l;
                        double temp_noudo = temp_sugar / (temp_water + temp_sugar);
                        if (temp_noudo > noudo) {
                            water = temp_water;
                            sugar = temp_sugar;
                            noudo = temp_noudo;
                        }
                    }
                }
            }
        }
    }
    if (water == 0) water = a*100;
    cout << water + sugar << ' ' << sugar << endl;
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  bool ch=true;
  vector<int> da(26),ta(26);
  vector<bool> ju(26,false),dg(26,false);
  cin >> s >> t;
  for(int i=0;i<s.size();i++){
    int x=s[i]-'a';
    int y=t[i]-'a';
    if(ju[x]){
      if(da[x]!=y){
        ch=false;
        //cout << i << endl;
        break;
      }
    }
    else{
      da[x]=y;
      ju[x]=true;
    }
    if(dg[y]){
      if(ta[y]!=x){
        ch=false;
        //cout << i << endl;
        break;
      }
    }
    else{
      ta[y]=x;
      dg[y]=true;
    }
  }
  if(ch)
    cout << "Yes" <<endl;
  else
    cout << "No" << endl;
}
    

Measured memory_bytes: 776
from collections import deque

N = int(input())
edges = [[]for _ in range(N+1)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    edges[a].append((b,c))
    edges[b].append((a,c))
dp = [0]*(N+1)

Q,K = map(int,input().split())
que = deque()
que.append((K,0))
path = {}
while que:
    now,cost = que.pop()
    path[now] = ""
    dp[now] = cost
    for x,c in edges[now]:
        if x not in path:
            que.append((x,cost+c))

for _ in range(Q):
    x,y = map(int,input().split())
    print(dp[x]+dp[y])


Measured memory_bytes: 90140
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        if(b - a == c - b){
            System.out.print("YES");
        }else{
            System.out.print("NO");
        }
    }
}

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

int main(){
    long long n;
    cin >> n;
    
    vector <long long> a(n,0);
    vector <long long> b(n,0);
    vector <long long> delta(n,0);

    long long cnt=0;
    long long sum = 0;
    priority_queue <long long, vector<long long>, less<long long>> que;

    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
        delta[i] = a[i]-b[i];
        if(delta[i]>0){
            que.push(delta[i]);
        }else if(delta[i]<0){
            sum += delta[i];
            cnt++;
        }
    }

    long long delta_sum;
    delta_sum = accumulate(delta.begin(), delta.end(), 0);
    // cout << delta_sum << endl;
    // if(delta_sum<0){
    //     cout << -1 << endl;
    //     return 0;
    // }

    while(sum<0 && !que.empty()){
        long long tmp = que.top();
        sum += tmp;
        que.pop();
        cnt++;
    }
    if(sum<0){
        cout << -1 << endl;
    }else{
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3196
import java.util.*;
import java.util.Arrays;
public class Main {
	public static void main(String args[] ){
	    Scanner sc = new Scanner(System.in);
	    int num[] = new int[3];
	    for(int i = 0 ; i < num.length ; i++){
	        num[i] = sc.nextInt();
	    }
	    Arrays.sort(num);
	    
	    System.out.println(num[0]+" "+num[1]+" "+num[2]);
	    
	}
}


Measured memory_bytes: 26252
#include <algorithm>
#include <cmath>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INFL = 1e18;
const int INF = 1000000007;
const ld PI = acos(-1);
const ld EPS = 1e-13;
const ll MOD = 1000000007;

void add(ll& a, ll b) {
    a += b;
    while (a >= MOD) {
        a -= MOD;
    }
}

void mul(ll& a, ll b) {
    a = (a * b) % MOD;
}

ll todeg(ll x, ll d) {
    if (d < 0LL) {
        d += MOD - 1;
    }
    if (d == 0LL) {
        return 1LL;
    }
    ll ans = todeg(x, d / 2LL);
    mul(ans, ans);
    if (d % 2 == 1) {
        mul(ans, x);
    }
    return ans;
}

vector<ll> fact;
vector<ll> rfact;

void prep(int n) {
    fact.assign(n + 1, 1);
    rfact.resize(n + 1);
    for (int i = 1; i <= n; ++i) {
        fact[i] = fact[i - 1];
        mul(fact[i], i);
    }
    rfact[n] = todeg(fact[n], -1);
    for (int i = n - 1; i >= 0; --i) {
        rfact[i] = rfact[i + 1];
        mul(rfact[i], i + 1);
    }
}

ll C(int n, int k) {
    ll ans = fact[n];
    mul(ans, rfact[k]);
    mul(ans, rfact[n - k]);
    return ans;
}

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

    prep(10000);

    ll s;
    cin >> s;

    ll ans = 0LL;
    for (int i = 1; i * 3 <= s; ++i) {
        //cout << i << " " << C(s - i * 3 + i - 1, i - 1) << "\n";
        add(ans, C(s - i * 3 + i - 1, i - 1));
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A, B, C; cin >> A >> B >> C;
    vector<int> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];
    sort(v.begin(), v.end(), greater<int>());
    int w = 0, ans = C / A;
    for(int i = 0; i < N; i++)
    {
        int tmp = (C + w + v[i]) / (A + (i + 1) * B);
        if(tmp >= ans)
        {
            w += v[i];
            ans = tmp;
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3228
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var A int64
	scanner.Scan()
	A, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	var B int64
	scanner.Scan()
	B, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	var C int64
	scanner.Scan()
	C, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	var K int64
	scanner.Scan()
	K, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	fmt.Println(solve(A, B, C, K))
}
func solve(A int64, B int64, C int64, K int64) int64 {
	if K <= A {
		return K
	}
	if K <= A+B {
		return A
	}
	return A - (K - A - B)
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    cout << (!(m % n) ? n + m : m - n) << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]

cand1 = [0] * n
cand2 = [0] * n
for i in range(n - 1):
    if i % 2 == 0:
        cand1[i] -= 1
        cand1[i + 1] += 1
        cand2[i] += 1
        cand2[i + 1] -= 1
    else:
        cand1[i] += 1
        cand1[i + 1] -= 1
        cand2[i] -= 1
        cand2[i + 1] += 1

cand1.sort()
cand2.sort()
a.sort()

ans = max(
    sum(a[i] * cand1[i] for i in range(n)),
    sum(a[i] * cand2[i] for i in range(n)),
)
print(ans)


Measured memory_bytes: 14972
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
const int MD = 1000000007;
const int MX = 200005;
int n;
ll a, b, c, u, aa[MX] = {1}, bb[MX] = {1}, ans;
ll exp(ll b, ll n){
	ll res = 1;
	for(; n; n/=2,(b*=b)%=MD) if(n%2) (res *= b) %= MD;
	return res;
}
ll fact[MX] = {1}, invf[MX];
void setcomb(int n){
	for(int i = 1; i <= n; i++) fact[i] = (fact[i-1] * i) % MD;
	invf[n] =  exp(fact[n] ,MD-2);
	for(int i = n; i > 0; i--) invf[i-1] = (invf[i] * i) % MD;
}
inline ll comb(int a, int b){return fact[a] * invf[a-b] % MD * invf[b] % MD;}
int main(){
	scanf("%d%lld%lld%lld", &n, &a, &b, &c);
	u = exp(a+b, MD-2);
	a = a * u % MD;
	b = b * u % MD;
	setcomb(n*2);
	rep(i,n){
		aa[i+1] = aa[i] * a % MD;
		bb[i+1] = bb[i] * b % MD;
	}
	for(int i = n; i < n*2; i++){
		ans += comb(i-1, n-1) * (aa[n] * bb[i-n] % MD + bb[n] * aa[i-n] % MD) % MD * 100 % MD * u % MD * i % MD;
	}
	printf("%lld\n", ans % MD);
}

Measured memory_bytes: 4992
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <list>
#include <string>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

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

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

    int cntR = 0;
    int cntB = 0;
    for (int i = 0; i < N; i++)
    {
        if (s[i] == 'R')
            cntR++;
        if (s[i] == 'B')
            cntB++;
    }

    if (cntR > cntB)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void cheatsheet()
{
    // loop
    // vector<int> vec(10);
    vector<int> vecloop;
    REP(i, 10)
    {
        vecloop.push_back(i);
    }

    // swap
    int a = 1;
    int b = 5;
    swap(a, b); // -> a = 5, b = 1

    // sort
    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    sort(arr, arr + 9, greater<int>()); // 9 8 7 6 5 4 3 2 1

    // lower
    vector<int> vec(arr, end(arr));
    sort(vec.begin(), vec.end());
    cout << lower_bound(vec.begin(), vec.end(), 2)[0]; // 2

    // map
    map<Pll, ll> m;
    m[Pll(10, 100)] = 100;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    double x, result = 0.0;
    string u;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x >> u;
        if (u == "JPY") {
            result += x;
        }
        if (u == "BTC") {
            result += x * 380000.0;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 384