akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  ll n,m,inf=INF;
  cin >> n >> m;
  ll xsum = 0,ysum = 0,x,y;
  FOR(i,0,n){
    cin >> x;
    xsum += (2*i+1-n)*x;
    xsum %= inf;
  }
  FOR(i,0,m){
    cin >> y;
    ysum += (2*i+1-m)*y;
    ysum %= inf;
  }
  cout << xsum*ysum%inf << endl;
}


Measured memory_bytes: 256
N = input()
S = raw_input()
ans = 0
for _ in range(N):
    T = raw_input()
    for s in range(1,len(T)):
        for i in range(len(T)):
            ok = True
            x = 0
            for j in range(len(S)):
                if i+j*s >= len(T) or T[i+j*s]!=S[j]:
                    ok = False
                    break
            if ok:
                break
        if ok:
            break
    if ok:
        ans += 1
print ans

Measured memory_bytes: 6452
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=200005;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
ll x;
int main()
{
    std::ios::sync_with_stdio(false);
    while(cin>>x)
    {
        ll sum=0;
        for(ll i=1;;i++)
        {
            sum+=i;
            if(sum>=x)
            {
                cout<<i<<endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
n,m = map(int,input().split())
jobs = [[] for i in range(100001)]
for i in range(n):
    a1,b1 = map(int,input().split())
    jobs[a1].append(b1)

reward = 0
heapsort = []
for daysLeft in range(1,m+1):
    if len(jobs[daysLeft]) != 0:
        for i in jobs[daysLeft]:
            heappush(heapsort,-i)
    if len(heapsort) > 0:
        reward += -heappop(heapsort)
print(reward)

Measured memory_bytes: 72480
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int c[1000005];

int main(){
    FastIO;
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        int ai;
        cin >> ai;
        c[ai]++;
        a[i] = ai;
    }

    if (c[1] != 0){
        if (c[1] == 1){
            cout << 1 << endl;
            return 0;
        }
        else{
            cout << 0 << endl;
            return 0;
        }
    }
    int ans = 0;
    rep(i, n){
        int ai = a[i];
        if (c[ai] > 1) continue;
        bool ok = true;
        for(int j = 2; j <= sqrt(ai); j++){
            if (ai % j == 0){
                if (c[j] != 0){
                    ok = false;
                    break;
                }
                if (c[ai/j] != 0){
                    ok = false;
                    break;
                }
            }
        }
        if (ok) ans++;
    }
    cout << ans << endl;
}

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

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

    if (N % 2 == 0){
        cout << fixed << setprecision(10) << 1.0 / 2 << endl; 
    }

    else{
        cout << fixed << setprecision(10) << (1.0 / 2) + (0.5 / N) << endl; 
    }
}

Measured memory_bytes: 256
s=int(input())
nums=[]
nums.append(s)
i=2
while(1):
  if nums[i-2]%2==0:
    new=int(nums[i-2]/2)
    if new in nums:
      print(i)
      break
    nums.append(new)
  else:
    new=3*nums[i-2]+1
    if new in nums:
      print(i)
      break
    nums.append(new)
  i+=1

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

const int nil = -1;

struct Node
{
  int p;
  int lc;
  int rc;
};
  
class TreeWalk
{
public:
  int n;
  Node nds[25];
  int root;
  int solve();
  int preorder( int id );
  int inorder( int id );
  int postorder( int id );
};

int TreeWalk::solve()
{
  cin >> n;

  for ( int i = 0; i < n; ++i )
    {
      nds[i].p = nil;
      nds[i].lc = nil;
      nds[i].rc = nil;
    }

  int id, left, right;
  
  for ( int i = 0; i < n; ++i )
    {
      cin >> id >> left >> right;
      nds[id].lc = left;
      nds[id].rc = right;
      if ( left != nil )
        nds[left].p = id;
      if ( right != nil )
        nds[right].p = id;
    }

  for ( int i = 0; i < n; ++i )
    {
      if ( nds[i].p == nil )
        {
          root = i;
        }
    }
  
  cout << "Preorder" << endl;
  preorder( root );
  cout << endl;
  cout << "Inorder" << endl;
  inorder( root );
  cout << endl;
  cout << "Postorder" << endl;
  postorder( root );
  cout << endl;
  return 0;
}

int TreeWalk::preorder( int id )
{
  if ( id != nil )
    {
      cout << " " << id;

      preorder( nds[id].lc );

      preorder( nds[id].rc );
    }

  return 0;
  
}

int TreeWalk::inorder( int id )
{
  if ( id != nil )
    {
      inorder( nds[id].lc );

      cout << " " << id;

      inorder( nds[id].rc );
    }

  return 0;
}

int TreeWalk::postorder( int id )
{
  if ( id != nil )
    {
      postorder( nds[id].lc );

      postorder( nds[id].rc );

      cout << " " << id;
    }

  return 0;
}

int main()
{

  TreeWalk tw;

  tw.solve();

  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int m=a[0];
    long long ans=0;
    for(int i=1;i<n;i++){
        if(a[i]>m)m=a[i];
        else ans+=m-a[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  vector<int> a(3);
  rep(i,3) cin >> a[i];
  int sum = 0;
  sort(a.begin(), a.end());
  rep(i,2) sum += a[i+1] - a[i];
  cout << sum << endl;
  return 0;
}


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

int t[100010];
int main()
{
    cin.sync_with_stdio(0);

    int n, c, k; cin>>n>>c>>k;
    for(int i=0; i<n; ++i) cin>>t[i];
    sort(t, t+n);

    int res=0, cnt=0;
    long p=0;
    for(int i=0; i<n; ++i) {
        if (t[i]<=p) {
            ++cnt;
            if (cnt>c) { ++res; cnt=1; p=t[i]+k; }
        }
        else {
            ++res; cnt=1; p=t[i]+k;
        }
    }
    cout<<res<<endl;
}


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

using namespace std;

#define rep(x,a,b)         for(int x = a; x < b; x++)
#define per(x,a,b)         for(int x = a; x >= b; x--)
#define all(container)     (container).begin(), container.end()
#define rall(container)    (container).rbegin(), container.rend()
#define sz(container)      (int) (container).size()
#define pb                 push_back
#define eb                 emplace_back
#define fi                 first
#define sc                 second

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

#ifdef LOCAL_DEFINE
    #include "DEBUG.hpp"
#else
    #define debug(...) 0
#endif
const ll mod = 1e9 + 7;
const int maxn = 200010;
ll arr[maxn], suff[maxn];
int main(void)
{
    int n;
    scanf("%d", &n);
    rep(i,0,n) scanf("%lld", &arr[i]);
    suff[n-1] = arr[n-1];
    per(i,n-2,0) suff[i] = (arr[i] + suff[i + 1]) % mod;
    ll ans = 0;
    rep(i,0,n-1) ans = (ans + arr[i] * suff[i + 1] % mod) % mod;
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<P> p(m);
    rep(i, m) cin >> p[i].first >> p[i].second;
    rep(x, 1000) {
    	int digit = 1;
    	int nx = x/10;
    	vector<int> rev(1, x%10);
    	while (nx) {
    		++digit;
    		rev.push_back(nx%10);
    		nx /= 10;
    	}
    	if (digit != n) continue;
    	bool flag = true;
    	reverse(rev.begin(), rev.end());
    	rep(i, m) {
    		if (rev[p[i].first-1] != p[i].second) flag = false;
    	}
    	if (flag) {
    		cout << x << endl;
    		return 0;
    	}
    }
    cout << -1 << endl;
    return 0;
}


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

#define PLUS '+'
#define MINUS '-'
#define TIMES '*'

int main(int argc, char *argv[]) {
	stack<int> stack01;
	string input, num;
	stringstream ss;
	getline(cin, input);
	
	for(int i = 0; i<input.length(); i++)
	{
		if(input[i] == ' ')
		{
			if(!num.empty())
			{
				int num_for_push;
//				ss << num;
//				ss >> num_for_push;
				num_for_push = stoi(num);
//				cout<<"push the num "<<num_for_push<<endl;	
				stack01.push(num_for_push);
				num.erase();
			}
			
		}
		else
		{
			switch(input[i])
			{
				case PLUS:
					{
//					cout<<"this is mark "<<input[i]<<endl;	
					int x = stack01.top();
//					cout<<x<<"=x is poped"<<endl;
					stack01.pop();
					int y = stack01.top();
//					cout<<y<<"=y is poped"<<endl;
					stack01.pop();
					int z = y+x;
//					cout<<"push the num "<<z<<endl;	
					stack01.push(z);
					}
					break;
				case MINUS:
					{
//					cout<<"this is mark "<<input[i]<<endl;
					int x = stack01.top();
//					cout<<x<<"=x is poped"<<endl;
					stack01.pop();
					int y = stack01.top();
//					cout<<y<<"=y is poped"<<endl;
					stack01.pop();
					int z = y-x;
//					cout<<"push the num "<<z<<endl;	
					stack01.push(z);
					}
					break;
				case TIMES:
					{
//					cout<<"this is mark "<<input[i]<<endl;
					int x = stack01.top();
//					cout<<x<<"=x is poped"<<endl;
					stack01.pop();
					int y = stack01.top();
//					cout<<y<<"=y is poped"<<endl;
					stack01.pop();
					int z = y*x;
//					cout<<"push the num "<<z<<endl;	
					stack01.push(z);
					}
					break;
				default:
					num.push_back(input[i]);
					break; 
			}
		}
	}
	cout<<stack01.top()<<endl;
	
	return 0;
}

Measured memory_bytes: 3184
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
typedef long long ll;
using namespace std;
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int maxn=1e6+5;


int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    swap(a,b);
    swap(a,c);
    printf("%d %d %d\n",a,b,c);
}


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

using namespace std;

int main(){
	vector<int> mountain;
	for(int i = 0;i < 10;i++){
		int x = 0;
		cin >> x;
		mountain.push_back(x);
	}
	sort(mountain.begin(),mountain.end(),greater<int>());
	vector<int>::iterator it = mountain.begin();
	cout << *it << endl;
	it++;
	cout << *it << endl;
	it++;
	cout << *it << endl;

	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  if (n == m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
let n = read_int ()
let f m = let cs = Array.make 8 0 in let rec f n =
  if n = 0 then cs.(3) + cs.(5) + cs.(7) = 3 else (cs.(n mod 10) <- 1; f (n / 10)) in m <= n && f m
let h m k = if f @@ 10 * m + k then 1 else 0
let rec g m = if m > n then 0 else h m 3 + h m 5 + h m 7 + g (10 * m + 3) + g (10 * m + 5) + g (10 * m + 7)
let _ = g 0 |> Printf.printf "%d\n"

Measured memory_bytes: 2560
function main(input) {
  const K = parseInt(input, 10);
  let ans = 0;
  
  if (K % 2 === 0) {
    n = K / 2;
    ans = n * n;
  } else {
    n = Math.floor(K / 2);
    ans = n * (n + 1);
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29672
N,M = map(int,input().split())
par = [0]+[-1 for i in range(N)]

def find(x):
    if par[x] == -1:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]

def same(x,y):
    return find(x) == find(y)
  
def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    par[x] = y
    
for i in range(M):
    a,b = map(int,input().split())
    unite(a,b)
print(len([i for i in par if i == -1])-1)

Measured memory_bytes: 11004
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

using namespace std;

LL  memo[100]={0};

LL Lucas(LL );

int main(void){
  int N;
  memo[0]=2;
  memo[1]=1;
  cin>>N;
  cout<<Lucas(N)<<endl;
  return 0;
}

LL Lucas(LL n){
  if(memo[n]!=0) return memo[n];
  
  if(n>=2){
    memo[n]= Lucas(n-1) + Lucas(n-2);
    return memo[n];
  }
  
}


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

const long long N = 3e6 + 17;
ll a[N], b[N], cnt = 1, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> m;
    cout << (m % n == 0 ? m + n : m - n);
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int N;
    cin >> N;
    int x = 0, y = 0, z = 0;
    REP(i, N)
    {
        ll a;
        cin >> a;
        if (a % 4 == 0)
            x++;
        else if (a % 2 == 0)
            y++;
        else
            z++;
    }
    if (z + (y % 2) <= x + 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

int main(){
  string s;
  cin>>s;
  int w;
  cin>>w;
  for(int i=0;i<(int)s.size();i++){
    if(i%w==0)cout<<s[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define int long long int
using namespace std;
#define pii pair <int, int>
#define mii map<int, int>
#define pb push_back
#define deb(x) cout << #x << " " << x << endl
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl
#define Loop(s, e, itr) for (int itr = s; itr < e; itr++)
#define loop(n) for(int i = 0; i < n; i++)
#define vin vector<int>
#define w(t) int tc; cin >> tc; for(int t = 1; t <= tc; t++)
#define vec vector
#define mod 1000000007
#define all(x) x.begin(), x.end()

int n;
vec<vin> table;

class segment_tree{
    int base = 1;
    int *tree;
    int *low;
    int *high;
    int def;

    // uncomment required line
    int fun(int a, int b){
        return max(a, b);
        // return min(a, b);
        // return a+b;
    }

    public: 
    

    segment_tree(vin heights){

        // set default return value

        def = 0; // for max
        // def = INT64_MAX; // for min
        // def = 0; // for sum


        int size = heights.size();
        while(size > base) base <<= 1;
        tree = new int[2*base];
        loop(size) tree[base+i] = heights[i];
        for(int i = base-1; i > 0; i--) tree[i] = fun(tree[2*i], tree[2*i+1]);

        low = new int[2*base];
        high = new int[2*base];

        loop(base) high[base+i] = low[base+i] = i;

        for(int i = base-1; i > 0; i--){
            low[i] = low[2*i];
            high[i] = high[2*i+1];
        }
    }

    void update(int index, int value){
        tree[base + index] = value;
        int i = (base+index)/2;
        while(i > 0) tree[i] = fun(tree[2*i], tree[2*i+1]), i >>= 1;
    }

    int query(int a, int b, int i = 1){
        int ans;
        if(a <= low[i] and b >= high[i]) ans = tree[i];
        else if(a > high[i] or b < low[i]) ans = def;
        else ans = fun(query(a, b, 2*i+1), query(a, b, 2*i));
        return ans;
    }
};

bool fun(vin a, vin b){
    return a[1] > b[1];
}

int32_t main(){
    
    cin >> n;
    table = vec<vin>(n, vin(3));// i height, buties
    loop(n){
        table[i][0] = i;
        cin >> table[i][1];
    }
    loop(n) cin >> table[i][2];

    vin ans(n, 0);
    segment_tree st(ans);

    sort(all(table), fun);    
    
    loop(n){
        int temp = st.query(table[i][0], n-1);
        st.update(table[i][0], temp+table[i][2]);
    }
    cout << st.query(0, n-1) << endl;
}

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

constexpr int N = 100009;
int n, h[N], dp[N];

int min_cost(int i) {
    // minimum from i to n
    if(i == n) return 0;
    if(i == n - 1) return abs(h[n] - h[n - 1]);
    if(dp[i] != -1) return dp[i];
    // i + 1
    int hazine1 = abs(h[i + 1] - h[i]);
    int best1 = min_cost(i + 1);
    
    // i + 2
    int hazine2 = abs(h[i + 2] - h[i]);
    int best2 = min_cost(i + 2);
    dp[i] = min(hazine1 + best1, hazine2 + best2); 
    return dp[i];
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    for(int i = 0; i < N; ++i) dp[i] = -1;
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> h[i];
    }

    cout << min_cost(1) << '\n';
}


Measured memory_bytes: 5760
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}
ll combi(ll a, ll b)
{
    if (a < b)
        return 0;
    ll res = 1;
    for (ll i = a; i >= a - b + 1; i--)
    {
        res *= i;
        res %= MOD;
    }
    rep3(i, 1, b + 1)
    {
        res *= modinv(i, MOD);
        res %= MOD;
    }
    return res;
}
//a,m=MOD MOD逆元
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int dx[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
    int n;
    cin >> n;
    V reg(25);
    rep3(i, 2, n + 1)
    {
        ll temp = i;
        rep(j, 25)
        {
            while (temp % dx[j] == 0)
            {
                temp /= dx[j];
                reg[j]++;
            }
        }
    }
    sort(all(reg));
    ll sum = 0;
    ll a = 25-(lower_bound(all(reg), 2) - reg.begin());
    ll b = 25-(lower_bound(all(reg), 4) - reg.begin());
    ll c = 25-(lower_bound(all(reg), 24) - reg.begin());
    ll d = 25-(lower_bound(all(reg), 14) - reg.begin());
    ll e = 25-(lower_bound(all(reg), 74) - reg.begin());
    if (a >= 3 && b >= 2)
    {
        sum += combi(b, 2) * (a - 2);
    }
    
    if(c>=1&&a>=2){
        sum += c * (a - 1);
    }
    if(d>=1&&b>=2){
        sum += d * (b - 1);
    }
    sum+=e;
    cout << sum << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, a int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := range arr {
		fmt.Scan(&a)
		arr[i] = a
	}
	sort.Sort(sort.Reverse(sort.IntSlice(arr)))

	var alice, bob int
	for i := range arr {
		if i%2 == 0 {
			alice += arr[i]
		} else {
			bob += arr[i]
		}
	}
	fmt.Println(alice-bob)
}


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

#define int long long

const int N = 1e7 + 1;


int32_t main() {
	int ans = 0, n; cin >> n;
	for(int i = 1; i <= n; i++) {
		for(int j = i; j <= n; j += i) {
			ans += j;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        
        //ArrayList<Long> cd_A = new ArrayList<Long>();
        Map<Long,Integer> cd_A = new HashMap();
        for(long i=1; i*i <= A; i++){
    		if( A % i == 0){
    			cd_A.put(i,1);
    			if( i != A/i ) cd_A.put(A/i,1); 
    		}
    	}
        
        Map<Long,Integer> cd_AB = new HashMap();
        for(long i=1; i*i <= B; i++){
    		if( B % i == 0){
    		    if(cd_A.containsKey(i)) cd_AB.put(i,1);
    			if( i != B/i ){
    			    if(cd_A.containsKey(B/i)) cd_AB.put(B/i,1);
    			}
    		}
    	}
        
        Set<Long> keys_set = cd_AB.keySet();
        List<Long> keys = new ArrayList<Long>(keys_set);
        Collections.sort(keys);
        
        int ans = 0;
        for(long key : keys){
            for(long key2 : keys){
                if(key <= key2){
                    ans ++;
                    break;
                } else if(key%key2 == 0 && key2 != 1){
                    break;
                }
            }
        }
        System.out.println(ans);
        
    }
    
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

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

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

static const int INF = 1001001001;

int main() {
  int n, m;
  cin >> n >> m;
  vector<PI> key;
  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    int s = 0; // s: 集合
    rep(j, 0, b) {
      int c;
      cin >> c;
      --c;
      s |= 1 << c;
    }
    key.eb(s, a);
  }

  vector<int> dp(1 << n, INF); // 2^n
  dp[0] = 0;
  rep(s, 0, 1 << n) {
    rep(i, 0, m) {
      int t = s | key[i].first; // 遷移先
      int cost = dp[s] + key[i].second;
      dp[t] = min(dp[t], cost);
    }
  }

  int ans = dp.back();
  if (ans == INF) ans = -1;
  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
//#include <unordered_map>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 2010


template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
 
//inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}


int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

vi g[N];
int r;
int dfs(int u,int fa,int h=0){
    int ans=1;
    if(h==r)return ans;
    FOREACH(it,g[u]){
        int j=*it;
        if(j==fa)continue;
        ans+=dfs(j,u,h+1);
    }
    return ans;
}
int main(){
    //freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);
    //freopen("1.txt","w",stdout);
    //srand(time(0));
    int T=30,j,k,i,ca=0,n,m;
    int K;
    scanf("%d%d",&n,&K);
    rep(i,1,n){
        scanf("%d%d",&j,&k),j--,k--;
        g[j].pb(k),g[k].pb(j);
    }
    int ans=n-1;
    if(K&1){
        r=(K-1)/2;
        rep(i,0,n){
            FOREACH(it,g[i]){
                j=*it;
                if(j<i)continue;
                k=dfs(i,j);
                k+=dfs(j,i);
                Min(ans,n-k);
            }
        }
    }
    else{
        r=K/2;
        rep(i,0,n){
            k=dfs(i,i);
            Min(ans,n-k);
        }
    }
    printf("%d\n",ans);
    //cerr<<1.*clock()/CLOCKS_PER_SEC<<"s\n";
    return 0;
}

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

int main() {
    int n, temp;
    cin >> n;
    vector<int> ans(n, 0);
    rep(i, n - 1) {
        cin >> temp;
        ans.at(temp - 1)++;
    }
    rep(i, n) cout << ans.at(i) << endl;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define ll long long
#define N 300020
#define S 100000
#define M 308
using namespace std;
int n, m, sz[N], K[N], res, ms[200002];
int od[N], ans;
ll s[N], prime[N], t[N];
bool p[N];
bool cmp(int x, int y) { return t[x] < t[y]; }
void Prepare() {
    memset(p, true, sizeof(p));
    for (int i = 2; i < S; i++) {
        if (!p[i]) continue;
        prime[++m] = i;
        for (int j = (i << 1); j < S; j += i) p[j] = false;
    }
}
int main() {
    Prepare();
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &s[i]);
        K[i] = sz[i] = 0, t[i] = 1;
        for (int j = 1; j <= M; j++) {
            if (s[i] % prime[j]) continue;
            int num = 0;
            while (s[i] % prime[j] == 0) s[i] /= prime[j], num++;
            num %= 3;
            if (num) K[i] |= ((num & 1) << sz[i]), sz[i]++, t[i] *= prime[j];
        }
        if (s[i] > 1) {
            if (s[i] < S)
                K[i] |= (1 << sz[i]), sz[i]++, t[i] *= s[i];
            else {
                ll qq = sqrt(s[i]);
                if (qq * qq != s[i])
                    ans++, i--, n--;
                else
                    sz[i]++, t[i] *= qq;
            }
        }
    }
    for (int i = 1; i <= n; i++) od[i] = i;
    sort(od + 1, od + n + 1, cmp);
    for (int l = 1, r; l <= n; l = r + 1) {
        for (r = l; r < n && t[od[r]] == t[od[r + 1]]; r++)
            ;
        if (t[od[l]] == 1) {
            ans++;
            continue;
        }
        int maxn = (1 << sz[od[l]]) - 1;
        for (int i = l; i <= r; i++) ms[K[od[i]]]++;
        for (int i = l; i <= r; i++) {
            int x = K[od[i]], ot = (maxn ^ K[od[i]]);
            if (ms[x] >= ms[ot]) ans += ms[x], ms[x] = ms[ot] = 0;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 9856
#include <iostream>

using namespace std;

int main() {

  while (true) {
    int seq[10];
    for (int i = 0; i < 10; ++i) {
      char c;
      cin >> c;
      seq[i] = int(c - '0');
    }

    if (cin.fail())
      break;

    for (int i = 9; 0 <= i; --i)
      for (int j = 0; j < i; ++j)
        seq[j] = (seq[j] + seq[j+1]) % 10;

    cout << int(seq[0]) << endl;
  }

}


Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
////////////////////////////////////////

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


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

using namespace std;

int main(void) {
	int A, B;
	cin >> A >> B;
	if (A > 8 || B > 8) cout << ":(" << endl;
	else cout << "Yay!" << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
N,a,b = map(int, input().split())

i=0
souwa=0
while i<=N:
  j=i
  sum =0
  while j>0:
    sum=sum+j%10
    j=int(j/10)
  #print(i,sum)
  if sum>=a and sum<=b:
    #print(sum,i)
    souwa=souwa+i
  
  
  i=i+1
print(souwa)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


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


int main(){
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    int count = 1;
    int ans = 0;
    while(!(count >= b)){
        count += (a-1);
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;
struct Node{
    int key;
    Node *parent,*left,*right;
};
Node *root,*NIL;
void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;

    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;

    while(x!=NIL){
        y=x;
        if(z->key<x->key) x=x->left;
        else x=x->right;
    }
    z->parent=y;
    if(y==NIL) root=z;
    else{
        if(z->key<y->key) y->left=z;
        else y->right=z;
    }
}
Node * treeMinimum(Node *x){
    while(x->left!=NIL) x=x->left;
    return x;
}
Node * treeSuccessor(Node *x){
    if(x->right!=NIL) return treeMinimum(x->right);
    Node *y=x->parent;
    while(y!=NIL&&x==y->right){
        x=y;
        y=y->parent;
    }
    return y;
}
void treeDelete(Node *z){
    Node *y;
    Node *x;
    if(z->left==NIL||z->right==NIL) y=z;
    else y=treeSuccessor(z);

    if(y->left!=NIL) x=y->left;
    else x=y->right;

    if(x!=NIL) x->parent=y->parent;

    if(y->parent==NIL) root=x;
    else{
        if(y==y->parent->left) y->parent->left=x;
        else y->parent->right=x;
    }
    
    if(y!=z) z->key=y->key;
    free(y);
}
Node * find(Node *u,int k){
    while(u!=NIL&&k!=u->key){
        if(k<u->key) u=u->left;
        else u=u->right;
    }
    return u;
}
void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
int main(){
    int n,x;
    string com;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }
        else if(com=="print"){
            inorder(root);
            cout<<endl;
            preorder(root);
            cout<<endl;
        }
        else if(com=="find"){
            scanf("%d",&x);
            Node *t=find(root,x);
            if(t!=NIL) cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
        else{
            scanf("%d",&x);
            treeDelete(find(root,x));
        }
    }
    return 0;
}


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

As=[]
for i in range(N):
	As.append(int(input()))


As.sort()

l=[]
l.append(As[N//2])
#if(N%2==0):
s=0
b=0
for i in range(N-1):
	if(i%2==1):
		l.append(As[-b-1])
		b+=1
	else:
		l.append(As[s])
		s+=1
ans=0
for i in range(1,N):
	ans+=abs(l[i]-l[i-1])
#print(l)
#print(ans)

l2=[]
l2.append(As[(N-1)//2])
#if(N%2==0):
s2=0
b2=0
for i in range(N-1):
	if(i%2==0):
		l2.append(As[-b2-1])
		b2+=1
	else:
		l2.append(As[s2])
		s2+=1
ans2=0
for i in range(1,N):
	ans2+=abs(l2[i]-l2[i-1])
#print(l2)
#print(ans2)
print(max(ans,ans2))

Measured memory_bytes: 8940
#include<stdio.h>
int main(void)
{
	int n,a,b,c,k[101],i,j,max,x,m;
	scanf("%d %d %d %d",&n,&a,&b,&c);
	for(i=0;i<n;i++){
		scanf("%d",&k[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(k[i]<k[j]){
			m=k[i];
			k[i]=k[j];
			k[j]=m;
			}
		}
	}
	max=0;
	for(i=0;i<n;i++){
		x=c;
		for(j=0;j<i;j++){
			x+=k[j];
		}
		if(max<x/(a+i*b)){
			max=x/(a+i*b);
		}
	}
	printf("%d\n",max);
}

Measured memory_bytes: 2660
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
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(){
    ll N;cin>>N;
    vector<ll>A(N+2,0);
    vector<ll>Ans(N);
    for(int i=1;i<N+1;i++){
        cin>>A[i];
    }
    ll cost=0;
    rep(i,N+1){
        cost+=abs(A[i]-A[i+1]);
    }
    for(int i=1;i<=N;i++){
        Ans[i-1]=cost-abs(A[i]-A[i-1])-abs(A[i]-A[i+1])+abs(A[i+1]-A[i-1]);
    }
    rep(i,N){
        cout<<Ans[i]<<endl;
    }
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    cout << n / 3 << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int s(int n){
	int res = 0;
	while(n > 0){
		res += n%10;
		n /= 10;
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	if(n%s(n) == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int i, n, debt = 100000;
  
  scanf("%d", &n);
  for(i = 1; i <= n; ++i){
    debt *= 1.05;
    debt += 999;
    debt /= 1000;
    debt *= 1000;
  }
  printf("%d\n", debt);
  return 0;
}

Measured memory_bytes: 0
def main():
    A,B = map(int,input().split())
    a = A / 0.08
    b = B / 0.10
    ans = -1
    large = max(int(a),int(b))
    small = min(int(a),int(b))
    for num in range(large+2,small-2,-1):
        numa = int(num * 1.08)
        numb = int(num * 1.10)
        if numa == (A+num) and numb == (B+num):
            ans = num
            #print("ans:"+str(ans))

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
 int a,b[11000],c,d;
    
  cin >> a;
  
  for(int i=0;i<(2*a);i++)
    cin >> b[i];
  
  sort(b,b+(2*a));
  
  c = 0;
    
  for(int i =0 ;i<(2*a);i += 2){
    c += b[i];
  }
  
  cout << c << endl;
  
  return 0;
}


Measured memory_bytes: 256
n, k = map(int,input().split())

total = []
s_c = 0
for i in range(n):
    s = i+1
    num = 1
    if s <= (k/2) :
        while s*2 < k:
            num += 1
            s = s*2
    elif s >= k:
        break
    s_c += 1
    total.append(num)
o = 0
for j in range(s_c):
    o += (1/n) * (0.5 ** total[j])
if s_c != n:
    o += (n-s_c)/n
print(o)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  ll N, A, B, C;
  cin >> N >> A >> B >> C;
  vll l(N);
  for(int i = 0; i < N; i++){
    cin >> l.at(i);
  }

  ll result = INF;

  for(int tmp = 0; tmp < (1 << 2*N); tmp++){
    ll AA = 0, BB = 0, CC = 0;
    bitset<16> bit(tmp);
    int fusioncounter = 0;
    for(int i = 0; i < N; i++){
      if(bit.test(2*i) == 0 && bit.test(2*i+1) == 0){
        if(AA != 0) fusioncounter++;
        AA += l.at(i);
      }
      else if(bit.test(2*i) == 0 && bit.test(2*i+1) == 1){
        if(BB != 0) fusioncounter++;
        BB += l.at(i);
      }
      else if(bit.test(2*i) == 1 && bit.test(2*i+1) == 0){
        if(CC != 0) fusioncounter++;
        CC += l.at(i);
      }
    }
    if(AA == 0 || BB == 0 || CC == 0) continue;
    ll sum = (ll)fusioncounter * 10 + abs(A-AA) + abs(B-BB) + abs(C-CC);
    chmin(result, sum);
  }
  cout << result << endl;
}


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

int main(){
    ll x;
    cin>>x;
    for(ll i=1;i<=1000;i++){
        for(ll j=0;j<i;j++){
            ll a = i*i*i*i*i;
            ll b = j*j*j*j*j;
            if(a-b==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
    for(ll i=0;i<=1000;i++){
        for(ll j=0;j<=1000;j++){
            ll a= i*i*i*i*i;
            ll b = j*j*j*j*j;
            if(a+b==x){
                cout<<i<<" "<<-j<<endl;
                return 0;
            }
        }
    }

    return 0;
}

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

using namespace std;

#define gc getchar_unlocked
#define foi(i,n) for(int i=0;i<n;i++)
#define Foi(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define fol(i,n) for(ll i=0;i<n;i++)
#define Fol(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

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

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

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

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


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    vector<ll> x(n);
    for(int i=0;i<n;i++)
        cin>>x[i];
    sort(all(x));
    ll sum=0;
    for(int i=0;i<k;i++)
        sum+=x[i];
    cout<<sum;
    return 0;
}

Measured memory_bytes: 10692
#include <bits/stdc++.h>
const int INF = ~0U>>1;
using namespace std;
string S;
int main(){
	cin >> S;
	int cnt = 0;
	for(int i = 0; i < S.size(); ++i) {
		if(S[i] == 'o') ++cnt;
	}
	cout << 700 + 100 * cnt << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    int n;
    map<int, int> mp;
    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto p : mp) {
        ans += p.second;
        if(p.second >= p.first) ans -= p.first;
    }
    cout << ans << endl;

    return 0;
}

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

const int N = 3e5+5;

int n, A[N];
long d[N], d2[N];

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= 3*n; ++i) scanf("%d", A+i);
    priority_queue<int, vector<int>, greater<int> > Q;
    for(int i = 1; i <= n; ++i) d[n] += A[i], Q.emplace(A[i]);
    for(int i = n+1; i <= 2*n; ++i) Q.emplace(A[i]), d[i] = d[i-1] + A[i] - Q.top(), Q.pop();
    priority_queue<int> Q2;
    for(int i = 3*n; i > 2*n; --i) d2[n<<1|1] += A[i], Q2.emplace(A[i]);
    for(int i = 2*n; i > n; --i) Q2.emplace(A[i]), d2[i] = d2[i+1] + A[i] - Q2.top(), Q2.pop();
    long mx = -1e18;
    for(int i = n; i <= 2*n; ++i) mx = max(mx, d[i] - d2[i+1]);
    printf("%lld\n", mx);
}

Measured memory_bytes: 5112
//agc043_a.cpp
//Thu May 28 21:14:16 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int h,w;
	cin >> h >> w;

	int col[h][w];
	int visited[h][w];
	int dp[h][w];
	for (int i=0;i<h;i++){
		string s;
		cin >> s;
		for (int j=0;j<w;j++){
			if (s[j]=='.'){
				col[i][j]=0;
			}else {
				col[i][j]=1;
			}
			visited[i][j] = 0;
			dp[i][j] = 0;
		}
	}

	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			if (i==0 && j==0){
				dp[i][j] = col[i][j];
			}else if (i==0){
				dp[i][j] = dp[i][j-1];
				if (col[i][j]==1 && col[i][j-1]==0){
					dp[i][j]++;
				}
			}else if (j==0){
				dp[i][j] = dp[i-1][j];
				if (col[i][j]==1 && col[i-1][j]==0){
					dp[i][j]++;
				}
			}else {
				int tmp1 = dp[i][j-1];
				if (col[i][j]==1 && col[i][j-1]==0){
					tmp1++;
				}
				int tmp2 = dp[i-1][j];
				if (col[i][j]==1 && col[i-1][j]==0){
					tmp2++;
				}
				dp[i][j] = min(tmp1,tmp2);
			}
		}
	}
	cout << dp[h-1][w-1] << endl;

// 	queue<P> q;
// 	int flip = 0;
// 	q.push(P(0,0));
// 	int qcol[2];
// 	if (col[0][0]==0){
// 		qcol[0] = 1;
// 		qcol[1] = 0;
// 	}else {
// 		qcol[0] = 0;
// 		qcol[1] = 1;
// 	}

// 	while(!q.empty()){
// 		if (qcol[flip%2]==0){
// 			flip++;
// 		}
// 		P x = q.front();q.pop();
// 		if (visited[x.first][x.second]){
// 			qcol[col[x.first][x.second]]--;
// 		}else if (col[x.first][x.second]==flip%2){
// 			visited[x.first][x.second] = 1;
// 			qcol[col[x.first][x.second]]--;
// 			if (x.first==h-1 && x.second==w-1){
// 				break;
// 			}
// 			if (x.second!=w-1){
// 				q.push(P(x.first,x.second+1));
// 				qcol[col[x.first][x.second+1]]++;
// 			}
// 			if (x.first!=h-1){
// 				q.push(P(x.first+1,x.second));
// 				qcol[col[x.first+1][x.second]]++;
// 			}
// 		}else {
// 			q.push(x);
// 		}
// 		// cout << flip << " " << qcol[0] << " " << qcol[1] <<endl;
// 	}

// 	cout << (flip+1)/2 << endl;
// //	printf("%.4f\n",ans);
}

Measured memory_bytes: 384
import math

n = int(input())

for _ in range(n):
  x_a,y_a,r_a,x_b,y_b,r_b = map(float, input().split())
  r_ab_plus = r_a + r_b
  r_ab_minus = abs(r_a-r_b)
  dist_center = math.sqrt((x_a-x_b)**2 + (y_a-y_b)**2)
  if dist_center < r_ab_minus and r_a > r_b:
    print(2)
  elif dist_center < r_ab_minus and r_b > r_a:
    print(-2)
  elif r_ab_minus <= dist_center and dist_center <= r_ab_plus:
    print(1)
  else:
    print(0)


Measured memory_bytes: 5672
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a>b){
		swap(a,b);
	}
	if(b>c){
		swap(b,c);
	}
	if(a>b){
		swap(a,b);
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
}



Measured memory_bytes: 3076