akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
using namespace std;

typedef long long ll;

int main()
{
	ll n, m;
	cin >> n >> m;
	ll ans = 0;
	if (n == 2 || m == 2) ans = 0;
	else if (n == 1 && m == 1) ans = 1;
	else if (n == 1) ans = m - 2;
	else if (m == 1) ans = n - 2;
	else {
		ans = (n - 2) * (m - 2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   char str[3];
   scanf("%s",str);
   int i,ans;
   ans=0;
   for(i=0;i<4;i++){
       if(str[i]=='+')ans=ans+1; else ans=ans-1;
   }
   
   printf("%d",ans);
   
    return 0;
}


Measured memory_bytes: 128
/* Akshat Sharma @akshat98 */
#include <iostream>
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp   make_pair
#define pb   push_back
#define F    first
#define S    second
#define ll   long long
#define MOD  1000000007
#define MAX  1000000001
#define vi   vector<int>
#define vl   vector<ll>
#define vpi  vector<pair<int,int> >
#define vpl  vector<pair<ll,ll> >
#define rep(i,a,b) for(i=a;i<b;i++)
#define reqp(i,a,b) for(i=a;i<=b;i++)
#define ren for(i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
ll mod(ll a,ll m=MOD){
        a%=m;
        if(a<0)a+=m;
        return a;
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input_file.txt", "r", stdin);
	//freopen("output_file.txt", "w", stdout);
	#endif
	ll i,j,k,l,n,test_case,m,r,ans=0;
	test_case=1;
	//cin>>test_case;
	while(test_case--){
		cin>>n>>k;
		reqp(i,k,n){
			ll st,en;
			st=(i*(i-1))/2;
			ll ts=n*(n+1)/2;
			en=ts-((n-i)*(n-i+1)/2);
			ans=mod(ans+en-st+1);
			// cout<<st<<"_"<<en<<"\n";
		}
		ans=mod(ans+1);
		cout<<ans<<"\n";

	}
	
	return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;


int main() {

    int n, q;
    cin >> n >> q;

    vector<priority_queue<ll>> pqs(n);

    rep(i, q) {
        int query, t;
        cin >> query >> t;
        if (query == 0) {
            ll x;
            cin >> x;
            pqs[t].push(x);
        } else if (query == 1) {
            if (pqs[t].empty()) continue;
            cout << pqs[t].top() << endl;
        } else if (query == 2) {
            if (pqs[t].empty()) continue;
            pqs[t].pop();
        }
    }

}


Measured memory_bytes: 5128
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repn(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define sz(v) (ll)v.size()
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
using namespace std;

ll MOD=1e9+7;
ll g,h,l;
const ll N=100005, inf=1e9+5;

ll add(ll a,ll b); ll mul(ll a,ll b); ll binpo(ll a,ll b);

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  string s;
  cin>>s;
  if(s=="SSS"){
    cout<<0;
  }
  else if(s=="RRS" or s=="SRR"){
    cout<<2;
  }
  else if(s=="RRR"){
    cout<<3;
  }
  else{
    cout<<1;
  }
}

//1. Change N before submitting.
//2. Remove debug statements.

ll add(ll a,ll b)
{
  return (a%MOD+b%MOD)%MOD ;
}
ll mul(ll a,ll b)
{
  return (a* 1ll *b)%MOD ;
}
ll binpo(ll a,ll b)
{
  int ans = 1 ;
  while(b)
  {
    if( b % 2 != 0)
    {
      ans = mul(ans,a);
    }
    a = mul(a,a);
    b = b/2;
  }
  return ans;
}

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

using namespace std;

#define L 250

#define INF 1000000000

struct RMQ {
	vector< vector<int> > v;
	vector<int> m;
	void shift(int l, int r) {
		int pos = 0;
		int rv = -1;
		for (int i = 0; i < v.size(); ++i) {
			int np = pos+v[i].size();
			if (pos <= r && r < np) {
				int j = r-pos;
				rv = v[i][j];
				v[i].erase(v[i].begin()+j);
				updateMin(i);
				break;
			}
			pos = np;
		}

		pos = 0;
		for (int i = 0; i < v.size(); ++i) {
			int np = pos+v[i].size();
			if (pos <= l && l < np) {
				int j = l-pos;
				v[i].insert(v[i].begin()+j, rv);
				updateMin(i);
			}
			pos = np;
		}
	}
	int get(int l, int r) {
		int ret = INF;
		int pos = 0;
		for (int i = 0; i < v.size(); ++i) {
			int np = pos+v[i].size();
			if (l <= pos && np-1 <= r) {
				ret = min(ret, m[i]);
			}
			else if (pos <= r && l < np) {
				for (int j = 0; j < v[i].size(); ++j) {
					if (l <= pos+j && pos+j <= r) {
						ret = min(ret, v[i][j]);
					}
				}
			}
			pos = np;
		}
		return ret;
	}
	void update(int x, int val) {
		int pos = 0;
		for (int i = 0; i < v.size(); ++i) {
			int np = pos+v[i].size();
			if (pos <= x && x < np) {
				v[i][x-pos] = val;
				updateMin(i);
				break;
			}
			pos = np;
		}
	}
	void updateMin(int pos) {
		m[pos] = INF;
		for (int i = 0; i < v[pos].size(); ++i) {
			m[pos] = min(m[pos], v[pos][i]);
		}
	}
	void smooth() {
		vector<int> a;
		for (int i = 0; i < v.size(); ++i) {
			for (int j = 0; j < v[i].size(); ++j) {
				a.push_back(v[i][j]);
			}
		}
		init(a);
	}
	void init(vector<int> a) {
		int N = a.size();
		v.clear(); v.resize((N-1)/L+2); // N > 0
		m = vector<int>(v.size(), INF);

		int pos = 0;
		for (int i = 0; i < v.size(); ++i) {
			for (int j = 0; j < L; ++j) {
				if (pos+j < N) {
					v[i].push_back(a[pos+j]);
				}
			}
			updateMin(i);
			pos += L;
		}
	}
};

int main() {
	RMQ rmq;
	int N, Q; cin >> N >> Q;
	vector<int> v(N);
	for (int i = 0; i < N; ++i) {
		cin >> v[i];
	}
	rmq.init(v);
	for (int t = 0; t < Q; ++t) {
		int x, y, z; cin >> x >> y >> z;
		switch (x) {
			case 0:
				rmq.shift(y, z);
				break;

			case 1:
				cout << rmq.get(y, z) << endl;
				break;

			case 2:
				rmq.update(y, z);
				break;
		}
		if (t % L == 0) {
			rmq.smooth();
		}
	}
}

Measured memory_bytes: 5916
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

const ll MOD = 1000000007;

map<int, int> prime_factor(int n) {
    map<int, int> ret;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }

    if (n != 1) ret[n] = 1;
    return ret;
}

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

    map <int, int> mp;
    for (int i = 2; i <= n; i++) {
        map <int, int> m = prime_factor(i);
        for (auto itr = m.begin(); itr != m.end(); ++itr) {
            mp[itr->first] += itr->second;
        }
    }

    ll ans = 1;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if (itr->first == 1) continue;
        ans = ans * (itr->second + 1) % MOD;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,k;
    scanf("%d %d",&n,&k);

    int i,now = 1;
    for (i = 0; i < n; i++)
    {
        if(now * 2 < now + k)now *= 2;
        else now += k;
    }
    printf("%d",now);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	char word[16],length,T;
};

void strcpy(char* to,char* str){
	for(int i=0;str[i] != '\0';i++){
		to[i] = str[i];
		to[i+1] = '\0';
	}
}

bool is_match(char left,char right){

	if(left >= 97)left -= 32;
	if(right >= 97)right -= 32;

	return left == right;
}

int main(){

	int N,H;
	scanf("%d %d",&N,&H);

	Info info[N];
	int tmp_length;
	for(int i = 0; i < N; i++){
		scanf("%s %d",info[i].word,&info[i].T);
		for(tmp_length = 0; info[i].word[tmp_length] != '\0'; tmp_length++);
		info[i].length = tmp_length;
	}

	char buf[16];
	strcpy(buf,info[0].word);

	int word_index = 0;
	int loc = 0;

	char resp[2];

	int true_num = 0,wrong_num = 0;

	while(true){

		printf("? %s\n", buf); fflush(stdout);
		scanf("%s",resp);

		if(is_match(buf[loc],resp[0])){
			buf[loc++] = '_';
			true_num++;
			if(loc == info[word_index].length){
				if(word_index == N-1){
					printf("! Game Clear %.1lf\n", floor((double)true_num/(true_num+wrong_num)*1000)/10); fflush(stdout);
					return 0;
				}else{
					word_index++;
					loc = 0;
					strcpy(buf,info[word_index].word);
				}
			}
		}else{
			wrong_num++;
			info[word_index].T--;
			if(info[word_index].T == -1){
				if(H == 1){
					printf("! Game Over\n"); fflush(stdout);
					return 0;
				}else{
					H--;
					if(word_index == N-1){
						printf("! Game Clear %.1lf\n", floor((double)true_num/(true_num+wrong_num)*1000)/10); fflush(stdout);
						return 0;
					}else{
						word_index++;
						loc = 0;
						strcpy(buf,info[word_index].word);
					}
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3344
import math
        
if(__name__=="__main__"):
    N, M=[int(i) for i in input().split()]
    
    n = 0
    if(max(N,M) - min(N,M) > 1):
        print(n)
    else:
        if(max(N,M) - min(N,M) == 0):
            n = pow(math.factorial(N),2) * 2
            #print(n)
        else:
            min_fact = math.factorial(min(N,M))
            n = min_fact*max(N,M) * min_fact
            #print(n)
        
        n = n % (pow(10,9) + 7)
        print(n)

Measured memory_bytes: 5172
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
  string s;cin>>s;
  
  ll count=0;
  
  char pre='A';
  for (int i=0;i<s.size();i++) {
    if (pre=='A') {
      pre=s[i];
      count++;
    }
    else {
      if (pre==s[i]) {
        pre='A';
        if (i!=s.size()-1) {
          count++;
          i=i+1;
        }
      }
      else {
        pre=s[i];
        count++;
      }
    }
  }
  
  cout<<count<<endl;
  
}


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

int main()
{
	int n;
	scanf("%d", &n);
	long long ans = 0LL;
	for (int i=1; i<=n; i++){
		if(i%3 != 0 && i%5 != 0) ans += i;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3672
S = input()
S = list(S)

tmp = [0 for i in range(len(S))]

for i in range(len(S)):
    if S[i] == '1':
        tmp[i] = 1
    elif S[i] == '0':
        tmp[i] = 0
     
flag = False
for i in range(len(S)-1):
    if S[i] != S[i+1] and flag == False:
        tmp[i] = -1
        tmp[i+1] = -1
        flag = True
    else:
        flag = False
  
count1 = 0
count0 = 0
res = 0
for i in range(len(S)):
    if tmp[i] == 1:
        count1 += 1
        
    elif tmp[i] == 0:
        count0 += 1
        
    else:
        res += 1
        
print(res + min(count0, count1) * 2)


Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S; S.reserve(300000); cin >> S;
  ll Q; cin >> Q;
  int dir = 1;
  rep(i, Q) {
    int T; cin >> T;
    if(T == 1) {
      dir *= -1;
    } else {
      int F; string c;
      cin >> F >> c;
      if(F == 1 && dir == 1) S.insert(0,c);
      else if(F == 2 && dir == -1) S.insert(0,c);
      else if(F == 1 && dir == -1) S += c;
      else if(F == 2 && dir == 1) S += c;
      else cerr << "Error" << endl;
    }
  }
  if(dir == -1) {
    for(ll i=S.size()-1; i>=0; --i) cout << S[i];
  } else {
    cout << S;
  }
  cout << endl;
}


Measured memory_bytes: 896
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#pragma endregion

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    int maxi = -1;
    int ind = -1;
    for (int i=0; i<n; i++) {
        if (chmax(maxi, abs(a.at(i)))) ind = i;
    }
    maxi = a.at(ind);
    cout << 2*n-1 << endl;
    for (int i=1; i<n+1; i++) {
        cout << ind+1 << " " << i << "\n";
    }
    if (maxi > 0) {
        for (int i=2; i<n+1; i++) {
            cout << i-1 << " " << i << "\n";
        }
    } else {
        for (int i=n; i>1; i--) {
            cout << i << " " << i-1 << "\n";
        }
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) { 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
int arr[(int) 2e5 + 5];
void solve() {
	int n, k;
	cin >> n >> k;
	int remain = max(0ll, n - k);
	for (int i = 1; i <= n; ++i)
		cin >> arr[i];
	sort(arr + 1, arr + n + 1);
	int ans = 0;
	for (int i = 1; i <= remain; ++i)
		ans += arr[i];
	cout << ans;
}   

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

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

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int p[200005];

int main(){
  int n, k;
  cin >> n >> k;
  REP(i, n) cin >> p[i];
  int res = 0;
  REP(i, k) res += p[i];
  int tmp = res;
  REP(i, n-k) {
    tmp += p[k+i];
    tmp -= p[i];
    chmax(res, tmp);
  }
  cout << setprecision(10) << (res+k)/2.0 << endl;

  return 0;
}

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

using namespace std;

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)
#define sz(x) int32_t(x.size())

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
// --------------------------------------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9 + 7;
const int inf = 2e18;
const ld eps = 1e-9;
const int NN = 2e5 + 2;

vvi g(NN);

void solve() {
      int i = 0, j = 0, k = 0, n = 0, m = 0; 
      cin >> n;
      fr(i, 2, n+1){
            cin >> k;
            g[i].pb(k);
            g[k].pb(i);
      }

      fr(i, 1, n + 1) {
            cout << (g[i].size() - (i != 1)) << el;
      }
      // cout << el;
}

int32_t main() {
      ios::sync_with_stdio(false); cin.tie(0); 
      int T = 1; 
      // cin >> T;
      for(int tc = 1; tc <= T; tc++) {
            solve();
       }

      return 0;
}

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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int N = 42;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

char ss[N][N];
int s[N][N], f[N][N][N][N];

I int S(cr a, cr b, cr c, cr d) {return s[c][d] - s[a - 1][d] - s[c][b - 1] + s[a - 1][b - 1];}
I void upd(int &x, int c) {x = _min(x, c);}

int main() {
	reg n = read(), m = read(), px, py;
	fo(i, 1, n) {
		scanf("%s", ss[i] + 1);
		fo(j, 1, m) {
			if(ss[i][j] == 'P') px = i, py = j;
			else if(ss[i][j] == '#') s[i][j] = 1;
			s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
		}
	} memset(f, 63, sizeof(f)); reg ans = f[0][0][0][0];
	f[1][1][n][m] = 0;
	fo(i, 1, n) fo(j, 1, m) fd(k, n, i) fd(h, m, j) if(i <= px && j <= py && k >= px && h >= py){
		reg c = f[i][j][k][h];
		fo(u, i, k) fo(v, j, h) {
			reg s1 = S(i, j, u, v) + S(u + 1, v + 1, k, h);
			reg s2 = S(i, v + 1, u, h) + S(u + 1, j, k, v);
			upd(f[i][j][u][v], c + s2), upd(f[u + 1][v + 1][k][h], c + s2);
			upd(f[i][v + 1][u][h], c + s1), upd(f[u + 1][j][k][v], c + s1);
		} ans = _min(ans, c + _min(_min(S(i, j, px, py), S(i, py, px, h)), _min(S(px, j, k, py), S(px, py, k, h))));
	} pr2(ans);
	return 0;
}



Measured memory_bytes: 12416
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<lint> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
lint GCD(lint x, lint y)
{
    return x ? GCD(y % x, x) : y;
}
lint LCM(lint x, lint y)
{
    return x / GCD(x, y) * y;
}
int main()
{
    int n;
    cin >> n;
    vi v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    lint lcm = v[0];
    rep(i, n)
    {
        lcm = LCM(lcm, v[i]);
    }
    cout << lcm << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,a[N];
int main()
{
    cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++) cin>>a[i],sum^=a[i];
    for(int i=1;i<=n;i++)
        cout<<(a[i]^sum)<<' ';
}


Measured memory_bytes: 4400
#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define all(c) (c).begin(), (c).end()

using namespace std;
template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }


int main() {
	int T;
	int num=0,back_number;
	int index_tok=-1;
	int len_tokens[10] = {0,5,3,3,3,3,3,4,3,4};
	int tokens[10][5] = {
		{'#','#','#','#','#'},
		{'.',',','!','?',' '},
		{'a','b','c','#','#'},
		{'d','e','f','#','#'},
		{'g','h','i','#','#'},
		{'j','k','l','#','#'},
		{'m','n','o','#','#'},
		{'p','q','r','s','#'},
		{'t','u','v','#','#'},
		{'w','x','y','z','#'}
	};

	cin >> T;
	string a_str;
	rep(t,T) {
		cin >> a_str;
		back_number = 0;
		rep(i,a_str.size()) 
		{
			num = a_str[i] - '0';
			if (num == 0) {
				if (back_number != 0) {
					char a_char = tokens[back_number][index_tok];
					cout << a_char;
					index_tok = -1; //Enterしたら、一番先頭へ
				}
			}
			else {
				index_tok = (index_tok+1) % len_tokens[num];
			}
			back_number=num;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(){
	int n;
	while(cin >> n, n){
		/*n++;
		vector<int> t(n), v(n);
		t[0] = 0;
		for(int i = 1;i < n;i++){
			cin >> v[i];
			t[i] = max(t[i-1]+v[i], v[i]);
		}*/
		n++;
		vector<int> vec(n),dp(n);
		for(int i=1;i<n;i++)cin >> vec[i];
		//for(int i = 1;i < n;i++)cout << vec[i] << " ";
		dp[0]=0;
		for(int i=1;i<n;i++)dp[i]=max(dp[i-1]+vec[i],vec[i]);
		cout << *max_element(dp.begin()+1, dp.end()) << endl;
	}
	return 0; 
}

/*
7
-5
-1
6
4
9
-6
-7
*/

Measured memory_bytes: 3116
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7


a, b, x = rm()
print(b//x - (a-1)//x)







Measured memory_bytes: 27204
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  string S;
  int N=0,L=0,O;
  cin>>S;
  for(int i;S[i]!='\0';i++){
    if(S[i]=='1'){
      N++;
    }else{
      L++;
    }
  }
  N=(N+L)-abs(N-L);
  cout<<N;
  return 0;
}


Measured memory_bytes: 512
n = int(input())
L = list(map(int,input().split()))
ans = 0
for i in range(n-2):
  a = L[i]
  b = L[i+1]
  c = L[i+2]
  T = [a,b,c]
  T.sort()
  if T[1] == b:
    ans += 1
print(ans)

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var ans = 0;
        for (int i = 1; i <= N; i++) {
            var len = i.ToString().Length;
            if (len % 2 == 1) ans++;
        }
        WriteLine(ans);
    }
    
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;

int main(){
  ll L, R;
  cin >> L >> R;
  
  ll tmp_minimum = 9999;
  for( ll i=L; i<=min(R-1,L+2018); i++ ){
    for( ll j=i+1; j<=min(R,i+1+2018); j++ ){
      tmp_minimum = min( (i*j)%2019, tmp_minimum );
    }
  }
   
  cout << tmp_minimum;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8101145141919364364,LMOD=998244353;
// const int dx[]={1,1,0,-1,-1,-1,0,1},dy[]={0,-1,-1,-1,0,1,1,1};

int main(){
    int n; cin>>n;
    int p[n]; rep(i,n){int x; cin>>x; p[x-1]=i;}
    reverse(p,p+n);
    int cnt=1,ans=INF;
    for(int i=1;i<n;i++){
        if(p[i-1]>p[i]) cnt++;
        else{
            ans=min(ans,n-cnt);
            cnt=1;
        }
    }
    ans=min(ans,n-cnt);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}
template < typename T, typename U >
ostream &operator<<(ostream &os, const pair< T, U > &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

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

struct edge {
	int from, to, d, c, i;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

template < typename A, size_t N, typename T >
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	int ans = 0;
	vector< int > count(N + 10, 0);
	for (int i = 1; i <= N; i++) {
		for (int j = i; j <= N; j += i) {
			count[j]++;
		}
	}
	for (int C = 1; C <= N - 1; C++) {
		M = N - C;
		ans += count[M];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11104
import java.math.BigDecimal;
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        BigDecimal a = new BigDecimal(Long.toString(scan.nextLong()));
        BigDecimal b = new BigDecimal(Double.toString(scan.nextDouble()));
        System.out.println(a.multiply(b).setScale(0, BigDecimal.ROUND_DOWN));
        scan.close();
    }
}

Measured memory_bytes: 29216
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()

	m := make(map[int]bool, n)
	for a := 1; a <= n; a++ {
		m[a] = false
	}

	for i := 1; i <= k; i++ {
		d := nextInt()

		for j := 1; j <= d; j++ {
			k := nextInt()
			m[k] = true
		}
	}

	var c int
	for _, v := range m {
		if !v {
			c++
		}
	}

	fmt.Println(c)
}

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

Measured memory_bytes: 1764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;

///#define mod             1000000007
#define what_is(x)      cerr<<#x<<" is "<<x<<"\n";
#define read(x)         freopen("in.txt","r",stdin);
#define write(x)        freopen("out.txt","w",stdout);
#define Fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define sz              3000005

string s;

int fastpow(ll b, ll p, ll mod){
    if(p==0)return 1;
    ll res=fastpow(b,p/2,mod)%mod;
    res=(res*res)%mod;
    if(p%2)res=(res*b)%mod;
    return res;
}

int f(int n){
    if(n==0)return 1;
    int pc=__builtin_popcount(n);
    return f(n%pc)+1;
}

int main(){
    Fast;///using Fast I/O
    int a,b,c, i,j,k, t,n,m;

    cin>>n>>s;

    int onbits=0;
    for(i=0; i<n; i++){
        onbits+=(s[i]=='1');
    }
    if(onbits==0){
        for(i=1; i<=n; i++){
            cout<<1<<endl;
        }
        return 0;
    }
    if(onbits==1){
        if(s[n-1]=='1'){
            for(i=0; i<n; i++){
                cout<<(i==n-1?0:2)<<endl;
            }
        }
        else{
            for(i=0; i<n; i++){
                if(s[i]=='0' && i==n-1)cout<<2<<endl;
                else if(s[i]=='0')cout<<1<<endl;
                else cout<<0<<endl;

            }
        }
        return 0;
    }


    int tot1=0;
    int tot2=0;
    int o=onbits+1;
    int p=onbits-1;

    for(i=1; i<=n; i++){
        if(s[i-1]=='1'){
            tot1+=fastpow(2,n-i,o);
            tot1=tot1%o;
        }
    }
    for(i=1; i<=n; i++){
        if(s[i-1]=='1'){
            tot2+=fastpow(2,n-i,onbits-1);
            tot2=tot2%p;
        }
    }

    for(i=0; i<n; i++){
        if(s[i]=='1'){
           ///subtract
          int temp=(p+(tot2-fastpow(2,n-1-i,p)))%p;
          cout<<f(temp)<<endl;
        }
        else{
          ///add
          int temp=(tot1+fastpow(2,n-1-i,o))%o;
          cout<<f(temp)<<endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3700
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;

class Main {
     public static void main(String[] args) throws IOException {
         StringBuilder sb = new StringBuilder();
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

         while(true) {
             String str[] = br.readLine().split(" ");
             int h = Integer.parseInt(str[0]);
             int w = Integer.parseInt(str[1]);
             
             if (h==0&&w==0) break;
             
             for (int i=0; i<h; i++) {
                 for (int j=0; j<w; j++) {
                     if (i==0 || i==h-1 || j==0 || j==w-1) sb.append("#");
                     else sb.append (".");
                 }
                 sb.append("\n");
             }
             sb.append("\n");
         }
         System.out.print(sb);
     }
}

Measured memory_bytes: 25440
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
const int maxn=110;

int a[5][maxn];
int dp[5][maxn];

int main()
{
    int n;
    cin>>n;
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=2;i++)
        for(int j=1;j<=n;j++)
        cin>>a[i][j];
    for(int i=1;i<=2;i++)
    for(int j=1;j<=n;j++){
        a[i][j]+=max(a[i-1][j],a[i][j-1]);
    }
    cout<<a[2][n]<<endl;
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc129/tasks/abc129_a

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> n(3);
    cin >> n[0] >> n[1] >> n[2];
    sort(ALL(n));
    cout << n[0] + n[1] << endl;

    return 0;
}


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

void chmax (int &x, int a) {
	x = max(x, a);
}

signed main () {
	int n;
	cin >> n;
	vector < int > a(n);
	for (int &x: a)
		cin >> x;
	vector < int > pref(n + 1, 0), suff(n + 1, 0);
	for (int i = 0; i < n; ++i)
		pref[i + 1] = __gcd(pref[i], a[i]);
	for (int i = n - 1; i >= 0; --i)
		suff[i] = __gcd(suff[i + 1], a[i]);
	int ans = 1;
	for (int i = 0; i < n; ++i)
		chmax(ans, __gcd(pref[i], suff[i + 1]));
	cout << ans << '\n';
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

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

        long sum = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= i; j++) {
                for (int k = 1; k <= j; k++) {
                    int count = Math.max(Math.max(i, j), k);
                    while (count > 0) {
                        if (i == j && j == k) {
                            sum += count;
                            break;
                        } else {
                            if (i % count == 0 && j % count == 0 && k % count == 0) {
                                if (i != j && i != k && j != k) {
                                    sum += 6 * count;
                                } else {
                                    sum += 3 * count;
                                }
                                break;
                            }
                        }
                        count--;
                    }
                }
            }
        }

        System.out.printf("%d\n", sum);
        sc.close();
    }
}

Measured memory_bytes: 36392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N;cin>>N;
    vector<ll> a(3*N);
    REP(i,3*N)cin>>a[i];
    sort(a.begin(),a.end());
    ll res=0;
    REP(i,N){
        res+=a[3*N-2-2*i];
    }
    cout<<res<<endl;
    return 0;

}

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

int main(){
    int n, k;
    cin >> n >> k;
    double ret = 0;
    for (int i = 1; i <= n; i++){
        double tmp = 1.0 / n;
        int now = i;
        while (now < k){
            now *= 2;
            tmp /= 2;
        }
    ret += tmp;
    }
    cout << fixed << setprecision(15) << ret << endl;
}


Measured memory_bytes: 3744
/// I won't go back on my word, that's my ninja way!
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5 ;
long long n ,a ,b ,h[N] ;
bool ok(long long c){
    long long need = 0 ;
    for(int i=0;i<n;++i)if(h[i]>c*b){
        long long x = h[i]-c*b;
        need += x/a + (x%a!=0) ;
        if(need>c)return 0;
    }
    return need<=c;
}
int main(){
    cin >> n >> a >> b ;
    a -= b ;
    for(int i=0;i<n;++i)cin >> h[i] ;
    long long st = 0 ,en = 1e18/b ;
    while(st<en){
        long long mid = (st+en)/2 ;
        if(ok(mid))en=mid;
        else st=mid+1;
    }
    cout << st ;
    return 0 ;
}


Measured memory_bytes: 1024
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
map<string , int > mp;
int main()
{



mp["SUN"]=1 ;mp["MON"]=2;mp["TUE"]=3; mp["WED"]=4;mp["THU"]=5; mp["FRI"]=6; mp["SAT"]=7;
string s;
cin>>s;
for(auto it=mp.begin();it!=mp.end();it++){
    if(it->first==s) if(it->second<=6) cout<<7-it->second+1;


                              else cout<<(it->second)-6;

}

    return 0;
}


Measured memory_bytes: 256
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    s = list(input())

    characters = []
    cnt = []
    counter = 0
    for si in s:
        if si != "x":
            characters.append(si)
            cnt.append(counter)
            counter = 0
        else:
            counter += 1
    cnt.append(counter)

    flg = True
    odd = len(characters) % 2
    for i in range(len(characters) // 2):
        if characters[i] != characters[-i - 1]:
            flg = False

    if not flg:
        print(-1)
        exit(0)

    ans = 0
    for i in range(len(cnt) // 2):
        ans += abs(cnt[i] - cnt[-i - 1])
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

const long long mod=1000000007;
const int N=100001;
long long f[N];
long long finv[N];

long long fastpow(long long b,long long e)
{
    long long res=1;
    while(e)
    {
        if(e&1) res=(res*b)%mod;
        b=(b*b)%mod;
        e/=2;
    }
    return res;
}

long long inv(long long a)
{
    return fastpow(a,mod-2);
}

void ini(long long n)
{
    f[0]=1;
    for(long long i=1;i<=n;i++) f[i]=(f[i-1]*i)%mod;
    finv[n]=inv(f[n]);
    for(long long i=n-1;i>=0;i--) finv[i]=(finv[i+1]*(i+1))%mod;
}

long long c(long long n,long long k)
{
    if(n<k||k<0||n<0) return 0;
    long long res=f[n];
    res=(res*finv[k])%mod;
    res=(res*finv[n-k])%mod;
    return res;
}


int main()
{
    int n,k;
    cin >> n >> k;
    vector<long long> v(n);
    for(int i=0;i<n;i++) cin >> v[i];
    sort(v.begin(),v.end());
    ini(n);
    long long res=0;
    for(int i=0;i<n;i++) res=(res+v[i]*c(i,k-1))%mod;
    for(int i=0;i<n;i++)
    {
        res=(res-(v[i]*c(n-i-1,k-1))%mod)%mod;
        if(res<0) res+=mod;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2560
d = {}


def func(n):
    if n == 0:
        return 2
    if n == 1:
        return 1

    if d.get(n - 1):
        r1 = d.get(n - 1)
    else:
        r1 = func(n - 1)
        d[n - 1] = r1

    if d.get(n - 2):
        r2 = d.get(n - 2)
    else:
        r2 = func(n - 2)
        d[n - 2] = r2
    return r1 + r2


def main():
    n = int(input())
    print(func(n))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
int main (void){
    int i,box,W,K,W1=0,W2=0,W3=0,K1=0,K2=0,K3=0,ten;
    for(i=0;i<20;i++){
        scanf("%d",&ten);
        if(i<10){
            if(W3<ten){
                W3=ten;
                if(W2<ten){
                    W3=W2;
                    W2=ten;
                    if(W1<ten){
                        W2=W1;
                        W1=ten;
                    }
                }
            }
        }
        else if(i>9){
            if(K3<ten){
                K3=ten;
                if(K2<ten){
                    K3=K2;
                    K2=ten;
                    if(K1<ten){
                        K2=K1;
                        K1=ten;
                    }
                }
            }
        }
    }
    W=W1+W2+W3;
    K=K1+K2+K3;
    printf("%d %d\n",W,K);
return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)
int main(){
    string S;
    string c;
    int Q;
    cin>>S;
    cin>>Q;
    int type,f;
    bool rev = false;
    rep(_,Q){
        cin>>type;
        if(type==1){
            rev = !rev;
        }else{
            cin>>f;
            cin>>c;
            if(f==1){
                if(!rev){
                    S.insert(0,c);
                }else{
                    S.append(c);
                }
            }else{
                if(!rev){
                    S.append(c);
                }else{
                    S.insert(0,c);
                }
            }
        }
    }
    if(rev){
        reverse(S.begin(),S.end());
    }
    cout<<S<<endl;
    return 0;
}

Measured memory_bytes: 1028
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s;
    getline(cin,s);
    int i;
    for(i=0;i<s.length();i++){
        if(s.at(i)>='a'&&s.at(i)<='z'){
            cout << char(s.at(i)+'A'-'a');
        }
        else if(s.at(i)>='A' &&s.at(i)<='Z'){
            cout << char(s.at(i)+'a'-'A');
        }
        else cout << s.at(i);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3152
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = sc.nextInt();
        
        for (int i = 0; i <= 10000; i++) {
            int j = n - i;
            
            if (j < 0) continue;
            
            int tmp = 2 * i + 4 * j;
            
            if (tmp == sum) {
                // System.out.println(i + " " + j);
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 35768
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

if A[0]==1:
    if N==0:
        pass
    else:
        print(-1)
        exit()
elif A[0]>1:
    print(-1)
    exit()

limit=[1]

for a in A[1:]:
    limit.append(limit[-1]*2-a)

A=A[::-1]
limit=limit[::-1]

ans=A[0]
temp=A[0]


for i in range(len(limit)-1):
    a=limit[i+1]
    b=temp
    x=b-a
    y=a-x
    
    if x<0:
        x=0
        y=temp
    elif y<0:
        print(-1)
        exit()
    
    temp=x+y+A[i+1]
    ans+=temp
        

print(ans)

Measured memory_bytes: 669424
#include <iostream>

using namespace std;

int main(){
    int n, x, third, ans;
    while(1){
        cin >> n;
        cin >> x;
        //終了判定
        if ( n == 0 && x == 0 ) {
            break;
        }
        ans = 0;
        //全探索
        for ( int first = 1; first <= n; first++ ) {
            for ( int second = 1; second <= n; second++ ) {
                third = x - first - second;
                if ( (first == second) || (second == third) || (third == first) ) {
                    
                } else if (third > 0 && third <= n) {
                    ans++;
                }
            }
        }
        cout << ans / 3 / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    d = defaultdict(lambda : 0)
    for i in a:
        d[i] += 1
    d = list(d.values())
    q = []
    for i in d:
        heappush(q,i)
    ans = []
    for k in range(n):
        if not q:
            break
        else:
            x = heappop(q)
            ans.append(x)
            while q and x:
                y = heappop(q)
                y += 1
                x -= 1
                heappush(q,y)
    for i in ans[::-1]+[0]*(n-len(ans)):
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 120804
import java.util.*;
import static java.lang.System.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();

	public void run() {
		while(true){
			int e=sc.nextInt();
			if(e==0)return;

			int min=Integer.MAX_VALUE;
			for(int z=0;z*z*z<=e;z++)
				for(int y=0;y*y<=e;y++){
				int x=e-y*y-z*z*z;
				if(x>=0)
					min=Math.min(min,x+y+z);
			}
			ln(min);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

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

struct Vertex{
		int parent;
		int depth;
	};

void treeMake(int vertex,int depth,vector< vector<int> > &T, vector<Vertex> &V){
	if(depth==0){
		V[vertex].parent=-1;
	}
	V[vertex].depth=depth;
	if(T[vertex].size()==0){
		return;
	}
	int i;
	for(i=0;i<T[vertex].size();i++){
		V[T[vertex][i]].parent=vertex;
		treeMake(T[vertex][i],depth+1,T,V);
	}
}

int main(){
	int n,i,j,k,d,e;
	cin >> n;
	
	vector< vector<int> > T(n);
	vector<int> check(n,0); 
	
	for (i=0;i<n;i++){
		cin >> k >> d;
		for (j=0;j<d;j++){
			cin >> e;
			T[k].push_back(e);
			check[e]=1;
		}
	}
	
	int r;
	for (i=0;i<n;i++){
		if(check[i]==0){
			r=i;
			break;
		}
	}
	
	vector<Vertex> V(n);
	
	treeMake(r,0,T,V);
	
	for (i=0;i<n;i++){
		cout << "node "<<i<<": parent = "<< V[i].parent <<", depth = "<<V[i].depth<<", ";
		if(V[i].parent==-1){
			cout << "root, ";
		}else if(T[i].size()==0){
			cout << "leaf, ";
		}else{
			cout << "internal node, ";
		}
		
		cout << "[";
		for (j=0;j<T[i].size();j++){
			if(j==T[i].size()-1){
				cout << T[i][j] ;
			}else{
				cout << T[i][j] << ", ";
			}
		}
		cout << "]"<<endl;
	}
}

Measured memory_bytes: 5492
N = int(input())

lst = []
for _ in range(N):
    A, B = map(int, input().split())
    lst += [[B, A]]

lst.sort()
t = 0
for i in range(N):
    t += lst[i][1] #仕事に使う時間をプラス
    if t > lst[i][0]: #制限時間と比較
        print ('No')
        exit()

print ('Yes')


Measured memory_bytes: 78296