akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll X, Y, Z, K; cin >> X >> Y >> Z >> K;
  vector<ll> a(X), b(Y), c(Z);
  rep(i, X) cin >> a[i];
  rep(i, Y) cin >> b[i];
  rep(i, Z) cin >> c[i];
  sort(a); sort(b); sort(c);

  priority_queue<ll> pq;
  for (int i = 1; i <= min(X, K); i++) {
    for (int j = 1; j <= Y; j++) {
      if (i * j > K) break;
      for (int k = 1; k <= Z; k++) {
        if (i * j * k > K) break;
        pq.push(a[X-i] + b[Y-j] + c[Z-k]);
      }
    }
  }
  rep(i, K) {
    outl(pq.top());
    pq.pop();
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 2036
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;


int main() {
  int N;cin>>N;
  vll A(N);
  vll sum(N+1,0);
  repeat(i,N){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  repeat(i,N){
    sum[i+1] = sum[i]+A[i];
  }
  ll ans = 1;
  for(int i=N-1;i>0;i--){
    if(sum[i]*2<A[i]) break;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
/*
[abc100] A - Happy Birthday!
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int A, B;

string solve() { return (A <= 8 && B <= 8) ? "Yay!" : ":("; }

int main() {
    cin >> A >> B;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define mems(x)     memset(x,0,sizeof(x))
#define all(a)      a.begin(),a.end()
 
/*---------------------------------------------------------------------------------------------------*/
int n,m;
int dp[100005][4];
int a[100005];
int b[100005];
int c[100005];
 
int maxHappy (int ind, int prev)
{
    if (ind == n) return 0;
    
    int &ret = dp[ind][prev];

    if (ret != -1) return ret;
    ret = - mod;
    if (prev != 0) ret = max (ret, maxHappy(ind + 1, 0) + a[ind]);
    if (prev != 1) ret = max (ret, maxHappy(ind + 1, 1) + b[ind]);
    if (prev != 2) ret = max (ret, maxHappy(ind + 1, 2) + c[ind]);

    return ret;
}

void solve()
{
    cin >> n;


    f (i, n)
    {
        f (j, 3) dp[i][j] = -1;
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[0][3] = -1;
    cout << maxHappy(0, 3);
} 
 
signed main()
{
  FAST
  int T=1;
//   cin >> T;
  while(T--) solve();
  return 0;
}

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

int selectionSort(int A[], int N);

int main() {
	int A[100]; //??°?????????
	int N; //??°??????????????????

	//??\???
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	//?¨????
	int count; //???????????°
	count = selectionSort(A, N);

	//??????
	for (int i = 0; i < N; i++) {
		if (i) { cout << " "; }
		cout << A[i];
	}
	cout << endl;
	cout << count << endl;
	return 0;
}

//??????????????????????????¨?????????????????????????????????????????????
int selectionSort(int A[], int N) {
	int count = 0;
	for (int i = 0; i < N - 1; i++) {
		int minj = i;
		for (int j = i + 1; j < N; j++) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
		if (i != minj) {
			swap(A[i], A[minj]);
			count++;
		}
	}

	return count;
}

Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

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

using namespace std;

typedef vector<int> vi;

vi table[5001];
int cnt[5001];
int main(){
    int n, m;
    cin >> n >> m;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--, b--;
        table[a].push_back(b);
        cnt[b] ++;
    }
    queue<int> q;
    rep(i, n) if(!cnt[i]) q.push(i);
    bool other = false;
    while(!q.empty()){
        if(q.size() > 1) other = true;
        int k = q.front(); q.pop();
        cout << k+1 << endl;
        rep(j, table[k].size()){
            cnt[table[k][j]]--;
            if(!cnt[table[k][j]]) q.push(table[k][j]);
        }
    }
    cout << other << endl;

	return 0;
}

Measured memory_bytes: 1912
N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

ans = 0
for i in range(N-1, -1, -1):
    tmp = (A[i] + ans) % B[i]
    if tmp != 0:
        tmp = B[i] - tmp
    ans += tmp
print(ans)

Measured memory_bytes: 11048
#include<iostream>
using namespace std;
int A[100005];
int main(){
  int N,M;
  cin>>N>>M;
  int sum=0;
  for(int i=0; i<M; i++){
    cin>>A[i];
    sum+=A[i];
  }
  if(sum>N){
    cout<<"-1"<<endl;
  }
  else cout<<N-sum<<endl;
  return 0;
}


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

namespace AtCoder.Abcdef
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //Input int array
            int[] inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            for (int i = 0; i < inputLongArray.Length; i++)
            {
                if (inputLongArray[i] != i + 1) 
                {
                    Console.WriteLine(i+1);
                }
            }

            //Write Code
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27972
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=110000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll gcd(ll x, ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}
template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,m;
  cin >> n >> m;
  vector<ll>a(m),b(m),c(min(n*(n-1),2000));
  
  rep(i,m){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    c[i]=-c[i];
  }
  vl dist(n,INF);
  dist[0]=0;
  rep(loop,n){
    rep(i,m){
      if(dist[a[i]]==INF)continue;
      chmin(dist[b[i]],dist[a[i]]+c[i]);
    }
  }
  ll ans=-dist[n-1];
  
  vector<bool>negative(n,false);
  rep(loop,n){
    rep(i,m){
      if(dist[a[i]]==INF)continue;
      if(dist[b[i]]>dist[a[i]]+c[i]){
        dist[b[i]]=dist[a[i]]+c[i];
        negative[b[i]]=true;
      }
      if(negative[a[i]])negative[b[i]]=true;
    }
  }
  if(negative[n-1])cout << "inf" << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
ans = 0
if k == 0:
    ans = n * n
else:
    for b in range(k+1, n+1):
        p, r = n // b, n % b
        ans += p * max(0, b - k) + max(0, r - k + 1)
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

    bool f = true;
    if (n % 2) {
        f = false;
    } else {
        string sub1 = s.substr(0, n / 2), sub2 = s.substr(n / 2, n / 2);
        if (sub1 != sub2) {
            f = false;
        }
    }

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

    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = [int(c) for c in input().split()]
l.sort()
def bin_search(l, r, f):
    while r - l > 1:
        c = (l + r) // 2
        if f(c):
            r = c
        else:
            l = c
    return r

llen = len(l)
ans = 0
for i in range(llen):
    a = l[i]
    for j in range(i + 1, llen):
        b = l[j]
        s = a + b
        upper = bin_search(j, n, lambda x: l[x] >= s)
        #print(i, j, upper)
        ans += upper - (j + 1)
print(ans)



Measured memory_bytes: 50264
n,m=map(int,input().split())
a=(1,3,5,7,8,10,12)
b=(4,6,9,11)
c=(2,)
if n in a and m in a:
  print("Yes")
elif n in b and m in b:
  print("Yes")
elif n in c and m in c:
  print("Yes")
else:
  print("No")

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

int main() {
	int n;
	int a, b, c;

	cin>>n;
	for (int i=0;i<n;i++) {
		cin>>a>>b>>c;
		if (a*a+b*b==c*c||b*b+c*c==a*a||c*c+a*a==b*b)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
A_list = list(map(int, input().split()))
times = 0
exist_odd = True

while True:
    for i in range(N):
        if A_list[i] % 2 != 0:
            exist_odd = False
            break
        else:
            A_list[i] /= 2
    if exist_odd:
        times += 1
    else:
        break
print(times)

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c),a+b+c){
		c=100-c;
		int win=0;
		int mon=0;
		for(int i=0;i<a;i++){
			int d;
			scanf("%d",&d);
			if(b==i+1)win=d;
			mon+=c*d;
		}
		printf("%d\n",win?mon/win:0);
	}
}

Measured memory_bytes: 0
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

//i番目まで見たとき,合計がjになる場合の数。
int dp[10010];

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

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

	dp[0]= 1;

	for (int i = 0; i < n; i++) {
		for (int j = 10009; j >= 0; j--) {

			if (j - a[i] >= 0) {
				dp[j] = max(dp[j],dp[j - a[i]]);
			}

		}
	}

	for (int j = 10009; j >= 0; j--) {
		if (dp[j] != 0 && j % 10 != 0) {
			cout << j << endl;
			return 0;
		}
	}	

	cout << 0 << endl;

	return 0;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const ll LINF = 1e15;
const int MOD = 1e9 + 7;

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

    vector<int> H(N);
    rep(i, N) cin >> H[i];

    if (K == N) {
        puts("0");
        return 0;
    }

    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, LINF));
    dp[0][0] = 0;

    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {
            ll res = LINF;

            int a = H[j - 1];
            rep(k, j) {
                int b = (k > 0)? H[k - 1] : 0;
                int x = max(0, a - b);
                res = min(res, dp[i - 1][k] + x);
            }

            dp[i][j] = res;
        }
    }

    ll ans = LINF;
    for (int i = 1; i <= N; ++i) {
        ans = min(ans, dp[N - K][i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};

int H;
int grid[10][5];

int vanish(int i, int j) {
	int cnt = 1;
	
	int val = grid[i][j];
	++j;
	
	while (j < 5 && grid[i][j] == val) {
		cnt++; j++;
	}
	
	return cnt;
}

int remove() {
	int res = 0;
	
	for_(i,0,H) {
		for_(j,0,3) {
			if (grid[i][j] == 0) continue;
			
			int van = vanish(i, j);
			
			if (van >= 3) {
				for_(k,j,j+van) {
					res += grid[i][k];
					grid[i][k] = 0;
				}
				
				break;
			}
		}
	}
	
	return res;
}

void fall() {
	for_(rep,0,H) {
		for_rev(i,H - 1, 1) {
			for_(j,0,5) {
				if (grid[i][j] == 0) {
					swap(grid[i][j], grid[i - 1][j]);
				}
			}
		}
	}
}

void solve() {
	int ans = 0;
	
	int pt;
	while ( (pt = remove()) != 0) {
		ans += pt;
		fall();
	}
	
	cout << ans << endl;
}

int main() {
	while (cin >> H, H) {
		for_(i,0,H) for_(j,0,5) cin >> grid[i][j];
		solve();
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
#define P pair<int,int>
int main(){
	int n,m;
while(true){
	cin>>n>>m;
if(n==0&&m==0)break;
vector<pair<P,string> >ta;//西暦、基数、名前の順番で入れる
for(int i=0;i<n;i++){
int a,b;string c;
cin>>c>>a>>b;
ta.push_back(pair<P,string>(P(b,a),c));
}
sort(ta.begin(),ta.end());
for(int izc=0;izc<m;izc++){
int tmp;
cin>>tmp;
bool f=0;
for(int i=0;i<n;i++){
int a=ta[i].first.first,b=ta[i].first.second;
string c=ta[i].second;
if(b-(a-tmp)>=1&&b>=b-(a-tmp)){
cout<<c<<" "<<b-(a-tmp)<<endl;
f=1;
}

}
if(f==0)cout<<"Unknown"<<endl;
}//for
}//while
	return 0;
}

Measured memory_bytes: 1292
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)


class UnionFind(object):

    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}


N, M, K = map(int, readline().split())

uf = UnionFind(N)
f = [0] * N
bl = [0] * N

for _ in range(M):
    a, b = map(int1, readline().split())
    f[a] += 1
    f[b] += 1
    uf.unite(a, b)

for i in range(K):
    c, d = map(int1, readline().split())
    if uf.find(c) == uf.find(d):
        bl[c] += 1
        bl[d] += 1

ans = [0] * N

for i in range(N):
    ans[i] = uf.size(i) - f[i] - bl[i] - 1

print(*ans)


Measured memory_bytes: 14952
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A= map(int, read().split())
    
    if len(set(A)) == N:
        print('YES')
    else:
        print('NO')
    
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 124660
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
using namespace std;

vector<pair<long long, int>> a;
int cnt[100005];
vector<long long> s;

int main(void){
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; i++){
        int t;
        long long d;
        cin >> t >> d;
        a.push_back({d, t});
    }
    long long ans = 0;
    long long oic = 0;
    long long various = 0;
    sort(a.begin(), a.end());
    for (int i = 0; i < K; i++){
        oic += a[N-1-i].first;
        cnt[a[N-1-i].second] += 1;
        if (cnt[a[N-1-i].second] > 1){
            s.push_back(a[N-1-i].first);
        }else{
            various++;
        }
    }
    ans = various * various + oic;
    for (int i = N-1-K; i >= 0; i--){
        if (!cnt[a[i].second] && !s.empty()){
            cnt[a[i].second]++;
            oic += a[i].first;
            oic -= s.back();
            s.pop_back();
            various++;
            ans = ans > various * various + oic ? ans : various * various + oic;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2928
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector <int> a(M);
  vector <int> b(M);
  vector <int> count(N,0);
  for(int i=0; i<M; i++){
    cin >> a.at(i) >> b.at(i);
  }
    
    for(int j=0; j<M; j++){
      for(int p=0; p<N; p++){
        if(a.at(j) == p+1 && b.at(j) != p+1){
          count.at(p)++;
        }else if(b.at(j) == p+1 && a.at(j) != p+1){
          count.at(p)++;
        }
      }
    }
  for(int i=0; i<N; i++){
    cout << count.at(i) <<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  N = 1e6 + 5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll ans;
	for(int i=1;i<=5;i++){
		ll x;cin>>x;
		if(x==0) ans=i;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 3608
N = int(input())
part_sum = 0
ans = 0
for i in range(N):
    a = int(input())
    if a == 0 or i == N - 1:
        part_sum += a
        ans += part_sum // 2
        part_sum = 0
    else:
        part_sum += a
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define REV(i, a) for (int i = (a); i >= 0; --i)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N;
int A[200005];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> N;
    REP(i, N) { cin >> A[i]; }

    if (A[0] != 0) {
        cout << -1 << endl;
        return 0;
    }

    for (int i = 1; i <= N - 2; ++i) {
        if (A[i + 1] - A[i] > 1) {
            cout << -1 << endl;
            return 0;
        }
    }

    int ans = 0;
    for (int i = N - 1; i >= 1; --i) {
        if (A[i] == A[i - 1] + 1) {
            ans++;
        } else {
            ans += A[i];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
a=gsmi
b=gsmi

cnt=0
prev=0
n.times do |i|
  bi=b[i]
  ai=a[i]
  cnt+=min(ai,prev+bi)
  
  c= ai-prev
  c=0 if c<0
  prev = bi-c
  prev=0 if prev<0
end
cnt+=min(a[n],prev)
puts cnt

Measured memory_bytes: 17564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
string a,b;
int main(){
	cin>>a>>b;
	int ans = 0;
	rep(i,a.size()) ans += (a[i] == b[i]);
	cout << ans << endl;
}

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

using namespace std;

int n, s;
long long w[101];
long long v[101];
long long dp[101][100001];

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

    cin >> n >> s;

    for (int i = 1; i <= n; i++)
        cin >> w[i] >> v[i];

    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= s; j++)
        {
            if (i == 0 || j == 0)
                dp[i][j] = 0;
            else if (j >= w[i])
                dp[i][j] = max(v[i] + dp[i - 1][j - w[i]], dp[i - 1][j]);
            else
                dp[i][j] = dp[i - 1][j];
        }
    }
    
    cout << dp[n][s];

    return 0;
}


Measured memory_bytes: 79232
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <utility>
#include <tuple>
#include <queue>

using namespace std;

int main()
{
    int n, m, a[100010], b[100010];
    long long ans=0, cnt=0;
    cin>>n>>m;
    for (int i=1; i<=n; i++) cin>>a[i];
    for (int j=1; j<=m; j++) { cin>>b[j]; cnt+=b[j]; }
    for (int i=1; i<=n; i++)
    {
        ans+=a[i]*cnt;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3888
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
vector<ll> G1[500005];
vector<ll> G2[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
 
ll mod = 1000000007;
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

 
//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,ans,a,b,c,e,g,h,w,i,j,k,q;
ll x[500005],y[500005],z[500005];
bool dp[100005];
bool dame;

int check(ll num){
    if(1 <= num && num <= 9){
        return 1;
    }else if(100 <= num && num <= 999){
        return 1;
    }else if(10000 <= num && num <= 99999){
        return 1;
    }else{
        return 0;
    }
}


int main(){
    cin >> n;
    for(i=1;i<=n;i++){
        ans += check(i);
    }
    p(ans);
    return 0;
}












Measured memory_bytes: 25216
#include <stdio.h>
#include <stdlib.h>
int main()
{
	int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b && a==c && b==c) printf("1");
    else if(a==b || a==c || b==c) printf("2");
    else if(a!=b && b!=c && c!=a) printf("3");
	system("pause");
	return 0;
}

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

using ll = long long;

#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;
const long long MOD = 1000000007;

void solve(ll N, ll K) {
  vector<ll> a(N + 1, 0);
  vector<ll> b(N + 1, 0);

  rep(i, N) a.at(i + 1) = a.at(i) + (i + 1);
  b.at(N) = N;
  repr(i, N - 1) b.at(i) = b.at(i + 1) + i;

  ll ans = 0;

  FOR(i, K, N + 2) {
    ans += b.at(N + 1 - i) - a.at(i - 1) + 1 % MOD;
    ans %= MOD;
  }

  cout << ans << endl;
}

int main() {
  ll N;
  scanf("%lld", &N);
  ll K;
  scanf("%lld", &K);
  solve(N, K);
  return 0;
}


Measured memory_bytes: 6376
n = int(input())
SP = []
for ni in range(n):
    s, p = input().split()
    SP.append([ni+1, s, int(p)])
SP.sort(key = lambda x: x[1])

sameNameList = []
s = SP[0][1]
sameNameList.append(SP[0])
for ni in range(1,n):
    if SP[ni][1] != s and sameNameList != []:
        sameNameList.sort(key = lambda x: x[2], reverse = True)
        for i in sameNameList:
            print(i[0])
        sameNameList = []
    sameNameList.append(SP[ni])
    s = SP[ni][1]
if sameNameList != []:
    sameNameList.sort(key = lambda x: x[2], reverse = True)
    for i in sameNameList:
        print(i[0])

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<int>;
using P = pair<int,int>;


int main()
{
    string s;cin >>s;
    int n=s.size();
    rep(i,n){
        cout <<'x';
    }
    cout << endl;
    return 0;
}


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

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

using namespace std;
using lint=long long;

int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<int> a(n),b(n);
	rep(i,n) scanf("%d%d",&a[i],&b[i]);

	lint ans=0;
	rep(j,n) if((a[j]&k)==a[j]) ans+=b[j];

	rep(i,30) if(k>>i&1) {
		int x=(k|(1<<i)-1)&~(1<<i);
		lint sum=0;
		rep(j,n) if((a[j]&x)==a[j]) sum+=b[j];
		ans=max(ans,sum);
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <cmath>
#define range(i, a, b) for(int i = (a); i < (b); i++)   // range(カウンタ, 初期値, 最終値)
#define rep(i, a) range(i, 0, a)    // rep(カウンタ, 回数)

using namespace std;

int main() {
    // 入力
    int N, D, X, A[100], i = 0;

    scanf("%d%d%d", &N, &D, &X);

    rep(i, N) scanf("%d", &A[i]);

    // 出力
    int sum = 0;

    rep(i, N) {
        sum += 1 + (int)floor((float)(D - 1) / (float)A[i]);
    }

    printf("%d", X + sum);

}

Measured memory_bytes: 256
'use strict';
var data = '';
process.stdin.on('end', function() {
    var inputs = data.toString().trim().split('\n');
    var params = inputs[1].split(' ').map(Number);
    var sum = params.reduce(function(a,b) {
      return a + b;
    });
    var min = params[0];
    var max = params[0];
    for (var i = 0; i < params.length; i++) {
      min = Math.min(min,params[i]);
      max = Math.max(max,params[i]);
    }
  
    console.log(min, max, sum);
  
});
  
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  data += chunk;
});

Measured memory_bytes: 17336
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        a: usize, b: usize
    };

    let a_s = std::iter::repeat(a).take(b).join("");
    let b_s = std::iter::repeat(b).take(a).join("");
    let res = if a_s <= b_s { a_s } else { b_s };
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2248
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

ll dist[100010];
ll RepeatSquaring(ll n, ll p, ll m){
    if(p==0) return 1;
    if(p%2==0){
        ll t = RepeatSquaring(n, p/2, m);
        return t*t % m;
    }
    return n * RepeatSquaring(n, p-1, m);
}

ll inv(ll x,ll power) {
	ll res = 1;
	ll k = power;
	ll y = x;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N*y%N) % N;
		k /= 2;
	}
	return res;
}

int main(void){
    ll n,m=0;
    cin>>n;
    vector<ll>d(n);
    for(ll i=0;i<100010;i++)dist[i]=0;
    for(ll i=0;i<n;i++){
        cin>>d[i];
        m=max(m,d[i]);
        dist[d[i]]++;
    }
    for(ll i=0;i<n;i++){
        if(i==0){
            if(d[i]!=0){
                cout<<0<<endl;
                return 0;
            }
        }
        else{
            if(d[i]==0){
                cout<<0<<endl;
                return 0;
            }
        }
    }
    ll ans=1;
    for(ll i=0;i<=m;i++){
        if(i==0){
            if(dist[i]==0)ans=0;
            else{
                if(dist[i]>1)ans=0;
                else ans=1;
            }
        }
        else{
            if(dist[i]==0)ans*=0;
            else{
                ans=(ans*inv(dist[i-1],dist[i]))%N;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  ll a[3*n+1]={};
  for(int i=0;i<3*n;i++){
    cin>>a[i];
  }
  sort(a,a+3*n);
  ll ans=0;
  ll lim=0;
  for(int i=3*n-2;i>=lim;i-=2){
    ans+=a[i];
    lim++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			double mbi = 0;
			String mStr = "";
			double h;
			double w;
			double t;
			String str;
			for(int i = 0;i < n;i++){
				str = scan.next();
				h = scan.nextDouble() / 100;
				w = scan.nextDouble();
				t = Math.abs(22.0 - w / h / h);
				if(mStr.equals("") || mbi > t){
					mStr = str;
					mbi = t;
				}
			}
			System.out.println(mStr);
		}
	}
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int choco[11][1001];
int main()
{
		int H, W, K;
	cin >> H >> W >> K;
	vector<string> S;
	fx(H) {
		vecps(S);
	}

	fy(W) {
		choco[1][y+1] = S[0][y] == '1' ? 1 : 0;
		fx(H - 1) {
			choco[x + 2][y+1] = choco[x+1][y+1];
			if (S[x + 1][y] == '1') {
				choco[x + 2][y+1]++;
			}
		}
	}
	int ans = INT_MAX;
	fx(2 << (H-1)) {
		vec(B);
		pb(B, 0);
		int y = x;
		int i = 0;
		while (y > 0) {
			if ((y & 1) == 1) {
				pb(B, i+1);
			}
			i++;
			y >>= 1;
		}
		pb(B, H)
		int sum = B.size() - 2;
		vector<int> SUMS(B.size() - 1);
		fw(W+1) {
			int flag = 0;
			fz(B.size() - 1) {
				SUMS[z] += choco[B[z + 1]][w] - choco[B[z]][w];
				if (w + 1 <= W && SUMS[z] + choco[B[z + 1]][w + 1] - choco[B[z]][w+1] > K) {
					flag = 1;
					if (w==0) {
						flag = 2;
					}
					break;
				}
			}
			if (flag>0) {
				sum++;
				if (flag==2) {
					sum = H*W;
				}
				SUMS = vector<int>(B.size() - 1, 0);
			}
		}

		ans = min(ans, sum);

	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//FUNCTION  


void solve(void)
{
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++)
  {
    cin >> B[i];
  }
  for (int i = 0; i < N; i++)
  {
    cin >> C[i];
  }
  sort(ALL(A));
  sort(ALL(B));
  sort(ALL(C));
  int ANS = 0;
  for (int i = 0; i < N; i++)
  {
    int X = B[i];
    auto itrA = lower_bound(ALL(A),X);
    auto itrC = upper_bound(ALL(C),X);
    ANS += distance(A.begin(),itrA)*distance(itrC,C.end());
  }
  
  cout<<ANS<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  int l = 100 * a / 8;
  for(int i = l - 10; i <= l + 10; ++i) {
    if(i > 0 && i * 8 / 100 == a && i / 10 == b) {
      cout << i << '\n';
      return 0;
    }
  }
  cout << -1 << '\n';
}

Measured memory_bytes: 256
X,K,D = map(int,input().split())

X = abs(X)
q = X // D
mod = X % D

if q > K:
    ans = abs(abs(X)-K*D)
elif q==K:
    ans = mod
else:
    ans1 = D-mod
    ans2 = mod

    if ans1<ans2:
        if (K-q-1)%2==1:
            ans = ans2
        else:
            ans = ans1
    else:
        if (K-q)%2==1:
            ans = ans1
        else:
            ans = ans2



print(ans)

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

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

struct P {
  int x,y;
  P(int x, int y) : x(x),y(y) {}
  P() {}
};
bool operator==(const P &a, const P &b) {
  return a.x==b.x&&a.y==b.y;
}
bool ok1(const P &a, const P &b) {
  return a.x==b.x||a.y==b.y;
}
bool ok2(const P &a, const P &b) {
  return abs(a.x-b.x) == abs(a.y-b.y);
}
bool ok3(const P &a, const P &b) {
  return ok1(a,b)||ok2(a,b);
}
vector<P> candidate(const P &a, const P &b) {
  vector<P> v;
  v.push_back(P(a.x,b.y));
  v.push_back(P(b.x,a.y));
  int dx = abs(a.x-b.x);
  int dy = abs(a.y-b.y);
  v.push_back(P(a.x+dy,b.y));
  v.push_back(P(a.x-dy,b.y));
  v.push_back(P(b.x+dy,a.y));
  v.push_back(P(b.x-dy,a.y));
  v.push_back(P(a.x,b.y+dx));
  v.push_back(P(a.x,b.y-dx));
  v.push_back(P(b.x,a.y+dx));
  v.push_back(P(b.x,a.y-dx));
  int t = a.x-a.y+b.x+b.y;
  //if (t%2 == 0)
    v.push_back(P(t/2,(-a.x+a.y+b.x+b.y)/2));
  t = b.x-b.y+a.x+a.y;
  //if (t%2 == 0)
    v.push_back(P(t/2,(-b.x+b.y+a.x+a.y)/2));
  return v;
}
vector<P> base;
P p1,p2,p;
bool canBuild(const P &a) {
  int cnt = 0;
  FOR(it, base) if (ok3(*it, a)) cnt++;
  return cnt>=2;
}
bool same(const P &a) {
  FOR(it, base) if (*it==a) return 1;
  return 0;
}

bool solve2() {
  vector<P> v;
  REP(i, base.size()) {
    REP(j, i) {
      vector<P> tmp = candidate(base[i], base[j]);
      FOR(jt, tmp) v.push_back(*jt);
    }
  }
  FOR(it, v) {
    //cout << it->x << ", " << it->y << endl;
    if (!same(*it) && canBuild(*it)) {
      base.push_back(*it);
      if (canBuild(p)) return 1;
      base.pop_back();
    }
  }
  return 0;
}
bool solve3() {
  vector<P> v = candidate(p1,p2);
  FOR(it, v) {
    if (!same(*it) && canBuild(*it)) {
      base.push_back(*it);
      if (solve2()) return 1;
      base.pop_back();
    }
  }
  return 0;
}

int main() {
  int T;cin>>T;
  REP(t,T) {
    cin>>p1.x>>p1.y>>p2.x>>p2.y>>p.x>>p.y;
    base.clear();
    base.push_back(p1); base.push_back(p2);
    bool f1 = ok3(p1,p);
    bool f2 = ok3(p2,p);
    if (p1==p||p2==p) cout << 0 << endl;
    else if (f1 && f2) cout << 1 << endl;
    else if (solve2()) cout << 2 << endl;
    else if (ok3(p1,p2)||solve3()) cout << 3 << endl;
    else cout << 4 << endl;
  }
}

Measured memory_bytes: 0
n = int(input())

a = list(map(int, input().strip().split()))

c = 0


def func(num: int, array: [int], count) -> int:
    for i in range(num):
        if i + 1 != num:
            if array[i] % 2 == 0:
                array[i] = array[i] / 2
                continue
            else:
                break
        else:
            if array[i] % 2 == 0:
                count += 1
                array[i] = array[i] / 2
                count = func(num, array, count)
    return count


print(func(n, a, c))


Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a * b) % 2 == 0)
            System.out.println("Even");
        else
            System.out.println("Odd");
    }

}



Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define MAX_N 100000

using namespace std;
typedef pair<int, int> ipair;

int main(int argc, char **argv) {
    int W, H, x, y;
    cin >> W >> H >> x >> y;

    double res1 = (double)W * H / 2.0;
    bool res2 = x * 2 == W && y * 2 == H;
    
    printf("%.10lf %d\n", res1, res2);
}

Measured memory_bytes: 256