akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define max(a, b) ((a)>(b) ? (a) : (b))
int main(){
  int n;  scanf("%d", &n);
  int table[100005] = {0};
  int ans = 0;
  for(int i=0; i<n; i++){
    int tmp;  scanf("%d", &tmp);
    for(int j=-1; j<=1; j++){
      table[tmp+j]++;
      ans = max(ans, table[tmp+j]);
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 512
#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>
using namespace std;
#define i64  long long
#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

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
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); }

void solve(void)
{
 int H,W;
 cin>>H>>W;
 if(H%3 == 0 || W%3 == 0)
 {
   cout<<0<<endl;
   return;
 }

  int ANS = INF;
  for (int i = 1; i < W; i++)
  {
    int A = i * H;
    int B = (W - i)*(H/2 + H%2);
    int C = (W - i)*(H/2) ;

    if(chmin(ANS,max(A,max(B,C)) - min(A,min(B,C))))
    {
      // cout<<A<<" "<<B<<" "<<C<<endl;
    }
  }

  swap(W,H);
    for (int i = 1; i < W; i++)
  {
    int A = i * H;
    int B = (W - i)*(H/2 + H%2);
    int C = (W - i)*(H/2) ;

    if(chmin(ANS,max(A,max(B,C)) - min(A,min(B,C))))
    {
      // cout<<A<<" "<<B<<" "<<C<<endl;
    }
  }
  if( W > 2 && H > 2)
  ANS = min(ANS,min(H,W));
  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: 384
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

long long floor_sum(long long n, long long m, long long a, long long b) {
	long long ans = 0;
	if (a >= m) {
		ans += (n - 1) * n * (a / m) / 2;
		a %= m;
	}
	if (b >= m) {
		ans += n * (b / m);
		b %= m;
	}

	long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
	if (y_max == 0) return ans;
	ans += (n - (x_max + a - 1) / a) * y_max;
	ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
	return ans;
}

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

	int T;
	cin >> T;
	while (T--)
	{
		int n, m, a, b;
		cin >> n >> m >> a >> b;
		cout << floor_sum(n, m, a, b) << endl;
	}

	return 0;
}

Measured memory_bytes: 3544
inf = float('inf')

N = int(input())

dp = [inf] * (N+1)
dp[0] = 0

for i in range(N):
    if i+1 < N+1:
        dp[i+1] = min(dp[i+1], dp[i] + 1)
    j = 6
    while i+j < N+1:
        dp[i+j] = min(dp[i+j], dp[i] + 1)
        j *= 6
    j = 9
    while i+j < N+1:
        dp[i+j] = min(dp[i+j], dp[i] + 1)
        j *= 9
    
ans = dp[N]
print(ans)

Measured memory_bytes: 3828
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n;
    cin>>n;
    vector<ll> c(n);
    for(auto &I:c){cin>>I;}
    ll q;
    cin>>q;
    vector<ll> a(n,0);
    while(q--){
        ll t,x,d;
        cin>>t>>x>>d;
        t--; x--;
        if(t){
            if(a[x]<d){cout<<x+1<<endl; return 0;}
            a[x]-=d;
        }
        else{
            if(a[x]+d>c[x]){cout<<x+1<<endl; return 0;}
            a[x]+=d;
        }
    }
    cout<<0<<endl;
    
    return 0;
}



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

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

    if(N>10)
    {
        cout<<R<<endl;
    }
    else
    {
        cout<<R+(100*(10-N))<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
static const int Max = 100000;
static const int Nil = -1;

int n;
vector<int> G[Max];
int color[Max];

void dfs(int r, int c) {
	stack<int> S;
	S.push(r);
	color[r] = c;
	while (!S.empty()) {
		int u = S.top(); S.pop();
		for (int i = 0; i < G[u].size(); i++) {
			int v = G[u][i];
			if (color[v] == Nil) {
				color[v] = c;
				S.push(v);
			}
		}
	}
	return;
}

void assignColor() {
	int id = 1;
	for (int i = 0; i < n; i++) color[i] = Nil;
	for (int u = 0; u < n; u++) {
		if (color[u] == Nil) dfs(u, id++);
	}
	return;
}

int main() {
	int m;
	cin >> n >> m;
	int s, t;
	for (int i = 0; i < m; i++) {
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	assignColor();
	int q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> s >> t;
		if (color[s] == color[t]) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 8924
#include<math.h>
#include<stdio.h>
  int a[10],n;
  
  int nextperm(void){
    int i,j,t;
    i=n-1;
    a[0]=0;
    while(a[i]>=a[i+1])i--;
    if(i==0)return 0;
    j=n;
    while(a[i] >= a[j])j--;
    t=a[i];a[i]=a[j];a[j]=t;
    i++;j=n;
    while(i<j){
      t=a[i];a[i]=a[j];a[j]=t;i++,j--;
    }
    return 1;
  }
int main(){
  int x[10],y[10],i,z=1;
  double t,sum=0,ans,o,p,q,r;
  scanf("%d\n",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&x[i],&y[i]);
  }
  for(i=1;i<=n;i++)a[i]=i;
  do{
  for(i=2;i<=n;i++){
    o=x[a[i-1]],p=y[a[i-1]],q=x[a[i]],r=y[a[i]];
    ans=(o-q)*(o-q)+(p-r)*(p-r);
    ans=sqrt(ans);
    sum=sum+ans;
  }
  }while(nextperm()==1);
    for(i=1;i<=n;i++){
      z=z*i;
    }
  t=z;
    printf("%lf\n",sum/t);
    return 0;
  }

Measured memory_bytes: 128
/* Hardwork allways pays off */
//You never know how close to the solution you are ,so keep practicing
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define mod 1000000007
#define REP(i,n) for(ll i=1;i<=n;i++)
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(), (x).end()
void make_unique(vector<ll> vec)
{
sort(all(vec));
vec.resize(unique(all(vec)) - vec.begin());
}

int main() 
 {   ios;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t; 
    while(t--)
      {ll l,k,p,a,b,c,n,m,i,j,flag=0,count=0,move=0;
      ll x;
      cin>>x;
      // ll A[n];
      // for(i=0;i<n;i++)
      // cin>>A[i];
      if(x==1)
      cout<<0<<endl;
      else
      cout<<1<<endl;
     
      
      

        
     }
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h> 
#define ll long long
using namespace std;
int n,a,b,cnt;
int main(){
	scanf("%d",&n);
	for (int i=1; i<=n; i++){
		scanf("%d%d",&a,&b);
		if (a==b) cnt++;
			else cnt=0;
		if (cnt==3){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 a, b, t;
int main() {
  cin >> a >> b >> t;
  i64 y = t / a * b;
  cout << y << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int a=0,b=0;
  for(int i=0;i<n;i+=2){
    a+=vec.at(i);
  }
  for(int i=1;i<n;i+=2){
    b+=vec.at(i);
  }
  if(a<=b){
    cout <<b-a<<endl;
  }
  else{
    cout <<a-b<<endl;
  }
}


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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

using ll  = long long int;
using vl  = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vll = vector<pll>;

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int inf = (1<<28);
const ll infl = (1LL<<60);

int main() {
    int N, L, Q; cin >> N;
    vl x(N); ina(x, N);
    vvl dp(N, vl(50));
    cin >> L >> Q;
    rep(i,N) {
        dp[i][0] = upper_bound(all(x), x[i]+L)-x.begin() - 1;
    }
    rep(k,40) rep(i,N) {
        dp[i][k+1] = dp[dp[i][k]][k];
    }

    rep(i,Q) {
        int a, b; cin >> a >> b;
        a--; b--;
        if (a > b) swap(a, b);
        ll ans = 1;
        while (dp[a][0] < b) {
            int k = 0;
            while (dp[a][k+1] < b) k++;
            a = dp[a][k];
            ans += pow(2, k);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 44544
S = list(input())
N = len(S)
v = 0

for i in range(2**(N-1)):
    i = str(bin(i))[2:].zfill(N-1)
    op = ["+" if int(i[j]) else "" for j in range(N-1)]
    q = [S[j//2] if j%2==0 else op[(j-1)//2] for j in range(2*N-1)]
    v += eval("".join(q))


print(v)

Measured memory_bytes: 3060
#include <cstdio>
#define MAX 15
using namespace std;

int main(){
	int n;
	
	while(scanf("%d", &n) != EOF){
		int array[MAX][MAX];
		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)
				array[i][j] = 0;
	
		int j = n / 2 + 1, k = n / 2;
		for(int i = 1; i <= n * n; i++){
			if(j >= n) j = 0;
			if(k >= n) k = 0;
			if(array[j][k] > 0){
				j++;
				k--;
				if(j >= n) j = 0;
				if(k >= n) k = 0;
				if(j < 0)  j = n - 1;
				if(k < 0)  k = n - 1;
				array[j][k] = i;
				j++;
				k++;
				continue;
			}
			array[j][k] = i;
			j++;
			k++;
		}
	
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				printf("%4d", array[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1040
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
    long long n,k,i,s=0,s1=0;
    cin>>n>>k;
    vector<int>v;
    for(i=0;i<n;i++)
    {
        cin>>s;
        v.push_back(s);
    }
    s=0;
    sort(v.begin(),v.end());
    if(k>=n)
    {
        cout<<"0"<<endl;
    }
    else
    {
        for(i=0;i<n;i++)
        {
            s=s+v[i];
        }
        i=n-1;
        while(k--)
        {
            s1=s1+v[i];
            i--;
        }
        cout<<s-s1<<endl;
    }
    return 0;
}


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

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();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

void Main(){
    int D; cin >> D;
    VI c(26); REP(i,26) cin >> c[i];
    int s[D][26]; REP(i,D)REP(j,26) cin >> s[i][j];
    VI last(26,0);
    VI ans(D);

    REP(i,D){
        int type = -1, maxscore = -INF;
        REP(j,26){
            int tmp = 0, prev_last = last[j];
            tmp += s[i][j];
            last[j] = i+1;
            REP(k,26) tmp -= c[k]*(i+1-last[k]);
            if(chmax(maxscore, tmp)) type = j+1;
            last[j] = prev_last;
        }
        ans[i] = type;
        last[type-1] = i+1;
    }

    REP(i,D) cout << ans[i] << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3700
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

typedef  long long ll;

#define rep(i,a,n) for(ll (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(ll (i)=(a);(i)>=(n);(i)--)

#define INF ll 1 << 60
#define MOD 1000000007


using namespace std;

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

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

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}


void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int dig(int d){
    int ans = 1;
    if(d == 0) return ans;
    while(d != 0){
        d--;
        ans*=100;
    }
    return ans;
}

ll divisors(ll n) {
    vector<ll> res;

    for(ll i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i-1);
        if(n/i == i) continue;
        res.push_back((n/i)-1);
    }

    ll ans = 0;

    rep(i,0,res.size()){
        if(res[i] != 0)
        if(n/res[i] == n%res[i]) ans += res[i];
    } 
    return ans;
}

void solve(void){
   int x;
   cin >> x;
   int a,b;
   if(x == 2){
       cin >> a >> b;
       cout << a+b<<endl;
   }else{
       cout << "Hello World"<<endl;
   }

}

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

Measured memory_bytes: 256
import collections

N = int(input())
s_hist = collections.Counter()

for n in range(N):
    s = input().strip()
    s_hist[" ".join(sorted(s))] += 1

ans = 0
for pair in s_hist.most_common():
    ans += s_hist[pair[0]]*(s_hist[pair[0]]-1)/2
    if(pair[1] == 1):
        break
print(int(ans))

Measured memory_bytes: 24416
s = gets.chomp.split("").map(&:to_i)
ops = [0,1].repeated_permutation(3).to_a
ops.each do |o|
  sum = s[0]
  @ans = [s[0]]
  (0..2).each do |i|
    if o[i] == 0
      @ans << "-"
      @ans << s[i+1]
      sum -= s[i+1]
    else
      @ans << "+"
      @ans << s[i+1]
      sum += s[i+1]
    end
  end
  break if sum == 7
end
@ans << "=7"
puts @ans.join


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

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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>>s(m);
  vector<int>p(m);
  rep(i, 0, m){
      int k;
      cin >> k;
      rep(j, 0, k){
          int s2;
          cin >> s2;
          s2--;
          s[i].push_back(s2);
      }
  }
  rep(i, 0, m)cin >> p[i];

  ll cnt=0;
  for(int bit=0; bit<(1<<n); bit++){
      bool flag = true;
      rep(i, 0, m){
          int temp = 0;
          rep(j, 0, s[i].size()){
              if(bit & (1<<s[i][j]))temp++;
          }
          if(temp%2!=p[i])flag = false;
      }
      if(flag)cnt++;
  }
  cout << cnt << endl; 
}

Measured memory_bytes: 256
import bisect
n,m,k=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
ds=[0]
for i in range(n):
    ds.append(ds[-1]+s[i])
ans=0
p=0
for i in range(m+1):
    if i>0:
        p+=t[i-1]
    if p>k:
        break
    si=bisect.bisect_left(ds,k-p+1)
    ans=max(ans,si+i-1)
print(ans)

Measured memory_bytes: 40448
import java.util.HashMap;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		HashMap<Integer,Integer> map = new HashMap<>();

		int n = stdIn.nextInt();

		long cnt = 0;

		for(int i = 0; i < n; i++) {
			int num = stdIn.nextInt();
			cnt += num;

			if(!map.containsKey(num)) {
				map.put(num,0);
			}
			map.put(num,map.get(num)+1);

		}

		int q = stdIn.nextInt();

		for(int i = 0; i < q; i++) {
			int b = stdIn.nextInt();
			int c = stdIn.nextInt();

			if(!map.containsKey(b)) {
				System.out.println(cnt);
				continue;
			}

			if(!map.containsKey(c)) {
				map.put(c,map.get(b));
				cnt += (c-b)*map.get(b);
				map.put(b,0);
				System.out.println(cnt);
				continue;
			}

			cnt += (c-b)*map.get(b);

			map.put(c,map.get(c)+map.get(b));

			map.put(b,0);

			System.out.println(cnt);
		}



	}

}


Measured memory_bytes: 71132
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 25, M = 1e6 + 25, oo = 1e9, mod = 1e9 + 7;
const long long OO = 1e18+25;

int n, a[3][N],mem[N][3];

int dp(int idx, int pre)
{
    if(idx == n) return 0;
    int &ret = mem[idx][pre];
    if(ret != 0) return ret;
    for(int i=0; i<3 ; i++)
    {
        if(i == pre) continue;
        ret = max(ret, dp(idx+1, i)+a[i][idx]);
    }
    return ret;
}

int main()
{
    //fill(mem, mem+(N*3), -1);
    scanf("%d",&n);
    for(int i=0; i<n; i++) scanf("%d%d%d",&a[0][i],&a[1][i],&a[2][i]);
    printf("%d",max(dp(1,0)+a[0][0],max(dp(1,1)+a[1][0],dp(1,2)+a[2][0])));
    return 0;
}
	     		 					   	 	 								 	

Measured memory_bytes: 10368
fib = [1, 1, 2, 3, 5, 8, 13, 21]
mod = 1000000007
h, w, k = map(int, input().split())
k -= 1
p = [0] * w
p[0] = 1
for i in range(h):
  q = [0] * w
  for j in range(w):
    if j > 0:
      q[j] += p[j - 1] * fib[j - 1] * fib[w - 1 - j]
    if j < w - 1:
      q[j] += p[j + 1] * fib[j] * fib[w - j - 2]
    if 0 < j < w - 1:
      q[j] += p[j] * fib[j] * fib[w - j - 1]
    elif j > 0:
      q[j] += p[j] * fib[j]
    elif j < w - 1:
      q[j] += p[j] * fib[w - j - 1]
    else:
      q[j] += p[j]
    q[j] %= mod
  p = q
print(p[k])


Measured memory_bytes: 3064
/**
        Bismilla- hir rahma-nir rahi-m
    @uthor Md Hasibur Rahman (Evan)
                JKKNIU
*/


#include<bits/stdc++.h>
#define         ll              long long
#define         FI              freopen("input.txt","r",stdin)
#define         FO              freopen("output.txt","w",stdout)
#define         PrintCase(i)    printf("Case %d: ",i)
#define         sc(a)           scanf("%d",&a)
#define         scl(a)          scanf("%lld",&a)
#define         rep(i,n)        for(int i=0;i<n;i++)
#define         pb              push_back
#define         MAX             1000000
#define         fast            ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define			endl			"\n"


using namespace std;

bool isPrime(ll a)
{
    for(ll i=2;i*i<=a;i++)
        if(a%i==0)
            return false;
    return true;
}






bool isPowerOfTwo(ll a)
{
    if(a==1)
        return true;
    if(a&1)
        return false;
    while(a)
    {
        a/=2;
        if(a!=1 && a&1)
            return false;
        if(a==1)
            return true;
    }
    return true;
}




ll gcd(ll a, ll b)
{
    if(a<0 || b<0)
    {
        a = abs(a);
        b = abs(b);
    }
    if(a<b)
        swap(a,b);
    if(a%b==0 || b==0)
        return b;
    else
        return gcd(b,a%b);
}



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



ll power(ll base, ll exponent)
{
    ll ans = 1;
    for(ll i=1;i<=exponent;i++)
        ans*=base;
    return ans;
}




bool isPowerOfX(ll x, ll value)
{
    if(value==1)
        return true;
    while(value)
    {
        value/=x;
        if(value%x && value!=1)
            return false;
    }
    return true;
}





int main()
{
    fast;
    ll n;
    cin>>n;
    vector<ll>v(n);
    rep(i,n) cin>>v[i];
    //reverse(v.begin(),v.end());
    ll cnt = 0;
    rep(i,n-1)
    {
    	if(v[i]>v[i+1])
    	{
    		cnt+=abs(v[i]-v[i+1]);
    		v[i+1] = v[i];
		}
	}
	cout<<cnt<<endl;
    return 0;
}


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

using namespace std;

double ans, x, d0;
int n;

int main()
{
    cin.sync_with_stdio(false);
    cin >> n >> d0 >> x;
    d0 -= x;

    while(n)
    {
        ans += d0 + x*(2*n+1) / 2;
        d0 = ((2*n+2) * d0 + 3*x) / (2*n);
        x = x * (2*n+4) / (2*n);

        --n;
    }

    cout << setprecision(10) << fixed;
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ls = Console.ReadLine().Split(' ');
            Stack<int> stack = new Stack<int>(); 
            foreach(string temp in ls)
            {
                if (temp == "+" || temp == "-" || temp == "/" || temp == "*")
                {
                    int sum = 0;
                    if (temp == "+")
                    {
                        sum += stack.Pop(); 
                        sum += stack.Pop();
                        stack.Push(sum);
                    }
                    if (temp == "-")
                    {
                        sum += stack.Pop();
                        sum = stack.Pop() - sum;
                        stack.Push(sum);
                    }
                    if (temp == "*")
                    {
                        sum += stack.Pop();
                        sum *= stack.Pop();
                        stack.Push(sum);
                    }
                    if (temp == "/")
                    {
                        sum += stack.Pop(); 
                        sum = stack.Pop() / sum;
                        stack.Push(sum);
                    }
                }
                else
                {
                    stack.Push(int.Parse(temp));
                }
            }
            Console.WriteLine(stack.Pop());
        }
    }
}



Measured memory_bytes: 18420
#include "bits/stdc++.h"
 
using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    string S;
    cin >> S;

    ll sum = 0;
    for(ll i = 0; i < S.length(); i++){
        if(S[i] == 'o') sum++;
    }

    if(15 - S.length() >= (8 - sum)) cout << "YES" << endl;
    else cout << "NO" << endl;

}

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    bool can = true;
    for (int i = 1; i < n; i++)
    {
        if (a[i] == a[i - 1])
        {
            can = false;
            break;
        }
    }

    cout << (can ? "YES" : "NO") << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] string = line.split(" ");

		int a = Integer.parseInt(string[0]);
		int b = Integer.parseInt(string[1]);

		// ??¢?????¨??¨??????????±???????
		int S = a * b;
		int L = 2 * (a + b);

		System.out.println(S + " " + L);

	}

}

Measured memory_bytes: 25952
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#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 <ctime>
#include <string>
#define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)

typedef long long ll;


using namespace std;


int main(){
    int H,W;
    vector<vector<bool>> a,r,b;
    cin>>H>>W;
    rp(i,0,H)  {
        string s;
        cin>>s;
        vector<bool> tmp;
        rp(j,0,W) {
            if(s[j]=='#') tmp.push_back(true);
            else tmp.push_back(false);
        }
        a.push_back(tmp);
    }

    
    rp(i,0,H){
        vector<bool> tmp_r,tmp_b;
        if( i%2 == 0 ) {rp(k,0,W) {tmp_r.push_back(true);tmp_b.push_back(false);}tmp_b[W-1] = true;}
        else rp(k,0,W) {{tmp_r.push_back(false);tmp_b.push_back(true);}tmp_r[0] = true;}
        tmp_r[W-1] = false;
        tmp_b[0] = false;
        rp(j,0,W){
            if(a[i][j] == true){
            tmp_r[j] = true;
            tmp_b[j] = true;
            }
        }
        r.push_back(tmp_r);
        b.push_back(tmp_b);
    }
    rp(i,0,H) {
        rp(j,0,W) {
            if(r[i][j]) cout<<'#';
            else cout<<'.';
        }
        cout<<endl;
    }
    cout<<endl;
    rp(i,0,H) {
        rp(j,0,W) {
            if(b[i][j]) cout<<'#';
            else cout<<'.';
        }
        cout<<endl;
    }



    return 0;
};



Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;

long long powmod(long long a, int n)
{
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return a * powmod(a, n - 1) % MOD;
	}
	else {
		return powmod(a * a % MOD, n / 2) % MOD;
	}
}

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

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

vector<int> prime_table(int n)
{
	vector<int> p(n, 0);
	iota(p.begin(), p.end(), 0);

	p[0] = p[1] = 0;
	for (int i = 2; i * i < n; ++i) {
		for (int j = i * i; j < n; j += i) {
			p[j] = 0;
		}
	}
	return p;
}

vector<pair<int, int>> prime_factorize(int n, const vector<int>& p)
{
	vector<pair<int, int>> m;
	for (auto x : p) {
		if (n < x * x) {
			break;
		}
		if (n % x == 0) {
			m.emplace_back(x, 0);
		}
		while (n % x == 0) {
			n /= x;
			++m.back().second;
		}
	}
	if (n != 1) {
		m.emplace_back(n, 1);
	}
	return m;
}

vector<int> v(1000000, 0);

int main()
{
	auto p = prime_table(1000 * 1000 + 10);
	p.erase(remove(p.begin(), p.end(), 0), p.end());

	int N;
	cin >> N;
	vector<int> A(N);
	
	for (auto& x : A) {
		cin >> x;
	}

	for (auto x : A) {
		auto f = prime_factorize(x, p);
		for (const auto& e : f) {
			v[e.first] = max(v[e.first], e.second);
		}
	}

	long long l = 1;
	for (int i = 0; i < 1000000; ++i) {
		for (int k = 0; k < v[i]; ++k) {
			l = l * i % MOD;
		}
	}

	long long ans = 0;
	for (auto x : A) {
		long long t = (l * powmod(x, MOD - 2)) % MOD;
		ans = (ans + t) % MOD;
	}

	cout << ans << endl;

}


Measured memory_bytes: 8064
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b){
    cout<<c<<endl;
    return 0;
  }
  if(a==c){
    cout<<b<<endl;
    return 0;
  }
 
    cout<<a<<endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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 main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int X,N;
    cin >> X >> N;
    set<int> se;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        se.insert(a);
    }
    int id = -1;
    int mn = inf;
    for(int i=-1; i<=101; i++){
        if(se.count(i)) continue;
        if(chmin(mn,abs(X-i))){
            id = i;
        }
    }
    cout << id << "\n";
    return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>

int main(void){
    int i,j,count=0,m,d,num1,num2;
    scanf("%d%d",&m,&d);
    for(i=4;i<=m;i++){
        for(j=22;j<=d;j++){
            num1=j%10;
            num2=(j-num1)/10;
            if(num1!=1 && num2 !=1 && i==num1*num2){
                count++;
                //printf("%d %d %d\n",i,num2,num1);
            }
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<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; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    vll a(35);
    rep(i,35) a[i]=5000;
    
    ll n;
    cin>>n;

    vec<string> s(n);

    rep(i,n)cin>>s[i];

    rep(i,26){
        ll cnt=0;
        rep(j,n){
            rep(k,s[j].size()){
                if(s[j][k]=='a'+i)cnt++;
            }
            
            if(cnt<a[i]){a[i]=cnt;}
            cnt=0;
        }

        char nn='a'+i;
        rep(h,a[i]){cout<<nn;}
    }

    cout<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;

void calc(const string& a, const string& b, vector<int>& res) {
    int na = a.size(), nb = b.size();

    res.resize(na + 1, true);
    for (int i = 0; i < na; ++i) {
        for (int j = 0; j < nb; ++j) {
            if (i + j >= na) break;
            if (a[i + j] != b[j] && a[i + j] != '?' && b[j] != '?') {
                res[i] = false;
                break;
            }
        }
    }
}

int solve(const string& a, const string& b, const string& c) {
    int na = a.size(), nb = b.size(), nc = c.size();

    vector<int> dp_ab, dp_bc, dp_ac;
    calc(a, b, dp_ab);
    calc(b, c, dp_bc);
    calc(a, c, dp_ac);

    int ans = na + nb + nc;
    for (int i = 0; i <= 4000; ++i) {
        if (!dp_ab[min(i, na)]) continue;
        for (int j = 0; j <= 4000; ++j) {
            if (!dp_bc[min(j, nb)] || !dp_ac[min(i + j, na)]) continue;
            ans = min(ans, max({na, i + nb, i + j + nc}));
        }
    }
    return ans;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    array<string, 3> vs;
    for (int i = 0; i < 3; ++i) {
        cin >> vs[i];
    }

    vector<int> ids = {0,1,2};
    int ans = 10000;
    do {
        ans = min(ans, solve(vs[ids[0]], vs[ids[1]], vs[ids[2]]));
    } while (next_permutation(ids.begin(), ids.end()));
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll d(n); re(i, n) std::cin >> d[i];
  sort(all(d));

  ll ans = 0;
  for(ll i=0;i<=100000;i++){
    ll num = lower_bound(all(d), i) - d.begin();
    if(num == n - num) ans++;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		String b = scan.next();
		if(a.equals(b)){
			System.out.println("H");
		}else {
			System.out.println("D");
		}
	}

}


Measured memory_bytes: 23764
using System;
class Mainclass
{
    static void Main()
    {
        int[] s = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
        Console.WriteLine(s[0] * s[1] > s[2] * s[3] ? s[0] * s[1] : s[2] * s[3]);
    }
}

Measured memory_bytes: 27472
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define itn int
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){
    int c=max(a,b)-min(a,b);
    return c;
}
int gcd(int a,int b){//最大公約数
    int c=a%b;
    while(true){
	if(c==0) break;
	a=b;
	b=c;
	c=a%b;
    }
    return b;
}
bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for(int i=3;i<=sqrtNum;i+=2){
	if(num%i==0){
	    return false;
	}
    }
}
int lcm(int a,int b){//最小公倍数
    return (a*b)/gcd(a,b);
}	
signed main(){
// __builtin_ctz(N); Nを２で何回割り切れるかを返す
//(n+1)*n/2; １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b[1000000],c=0,d=0,l,k=0,o=0,p=0,m=0,n=0,v=0;
    cin>>a;
    for(int i=0;i<a;i++){
	cin>>b[i];
	c+=b[i];
    }
    l=c/a;
    o=l+1;
    p=l-1;
    for(int i=0;i<a;i++){
	m+=(l-b[i])*(l-b[i]);
	n+=(o-b[i])*(o-b[i]);
	v+=(p-b[i])*(p-b[i]);
    }
    
    cout<<min(m,min(n,v))<<"\n";
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]

pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    (v[0], v[1])
}

pub struct Edge {
    from: usize,
    to: usize,
    weight: f64
}

pub fn kruskal(edges: &mut Vec<Edge>, size: usize) -> f64 {
    let mut uf = UnionFind::new(size);
    edges.sort_by(|a, b| b.weight.partial_cmp(&a.weight).unwrap());
    let mut ret = 0.0;
    for e in edges {
        if !uf.same(e.from, e.to) {
            uf.unite(e.from, e.to);
            ret += e.weight;
        }
    }
    ret
}

pub struct UnionFind {
    par: Vec<usize>,
    rank: Vec<usize>
}

impl UnionFind {
    pub fn new(size: usize) -> UnionFind {
        UnionFind {
            par: (0..size).collect(),
            rank: vec![0; size]
        }
    }

    pub fn find(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            x
        } else {
            let par = self.par[x];
            self.par[x] = self.find(par);
            self.par[x]
        }
    }

    pub fn unite(&mut self, x: usize, y: usize) {
        let x = self.find(x);
        let y = self.find(y);
        if x == y {
            return;
        }

        if self.rank[x] < self.rank[y] {
            self.par[x] = y;
        } else {
            self.par[y] = x;
            if self.rank[x] == self.rank[y] {
                self.rank[x] += 1;
            }
        }
    }

    pub fn same(&mut self, x: usize, y: usize) -> bool {
        self.find(x) == self.find(y)
    }
}

pub fn dist(c1: (i32, i32), c2: (i32, i32)) -> f64 {
    (((c1.0-c2.0).pow(2) + (c1.1-c2.1).pow(2)) as f64).sqrt()
}


fn main() {
    let (N, M) = read_tuple::<usize>();
    let coords: Vec<(i32, i32)> = (0..N).map(|_| read_tuple::<i32>()).collect();
    let mut edges = Vec::new();
    for i in 0..M {
        let (p, q) = read_tuple::<usize>();
        let p = p - 1;
        let q = q - 1;
        edges.push(Edge {
            from: p,
            to: q,
            weight: dist(coords[p], coords[q])
        });
    }
    let ans: f64 = edges.iter().map(|e| e.weight).sum::<f64>() - kruskal(&mut edges, N);
    println!("{}", ans);
}



Measured memory_bytes: 2352
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int n,m,t,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int a,b;
    cin>>n;
  cout<<(n+1)/2;
}
 
 
signed main()
{

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;

    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(){

int a,b;
cin >> a >> b;

if(a>b){
 cout << "a > b" << endl;
}else if(a<b){
 cout << "a < b" << endl;
}else{ 
cout << "a == b" << endl;
}

return 0;
}


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

using namespace std;

int main(){
int n, m;
cin>>n>>m;
vector<int> cnt(n+1,0);
for(int i=0; i<m; i++){
int a, b;
cin>>a>>b;
cnt[a]++;
cnt[b]++;
}
for(int i=1; i<=n; i++) cout<<cnt[i]<<endl;
}

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


money_high = 1000
kabu_high = money_high // A[0]
zankin = 0
for i in range(n):
    money_high = max(kabu_high * A[i] + zankin, money_high)
    kabu_high = max(money_high // A[i], kabu_high)
    zankin = money_high % A[i]

print(max(kabu_high * A[n-1] + zankin, money_high))


Measured memory_bytes: 61824
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
/* WARNING : do NOT compile this debug func calls with following flags: // \
 * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
   stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); \
}
void err(istream_iterator<string> it) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
	err(++it, args...);
}

const int N = (int)1e5 + 10, MOD = (int)1e9 + 7;
vector <vector <int>> adj;
int n, m;
int dp[N], exc[N];
bool vis[N];

int mul (int a, int b) {
   return int((1ll *(a%MOD) * (b%MOD))%MOD);
}
int add (int a, int b) {
   return ((a%MOD) + (b%MOD))%MOD;
}

void root_at(int u, int pr) {
   vis[u] = true;
   for (int i = 0; i < (int)adj[u].size(); ++i) {
      if (adj[u][i] == pr) {
         adj[u].erase(adj[u].begin() + i);
         break;
      }
   }
   for (int v : adj[u])
      if (!vis[v]) root_at(v, u);
}

void dfs(int u) {
   vis[u] = true;
   for (int v : adj[u])
      if (!vis[v]) dfs(v);

   int dp_mul = 1, exc_mul = 1;
   for (int v : adj[u]) {
      dp_mul = mul(dp_mul, dp[v]);
      exc_mul = mul(exc_mul, exc[v]);
   }
   dp[u] = add(dp_mul, exc_mul);
   exc[u] = dp_mul;
   return;
}

void solve() {
   for (int i = 0; i < n; ++i) vis[i] = 0;
   root_at(0, -1);
   for (int i = 0; i < n; ++i) vis[i] = 0;
   dfs(0);

   cout << dp[0] << '\n';
}

signed main() {
   IOS; PREC;
   cin >> n;
   m = n - 1;
   adj.assign(n, vector <int> ());
   for (int e = 0; e < m; ++e) {
      int u, v;
      cin >> u >> v;
      --u, --v;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }
   solve();

   return EXIT_SUCCESS;
}


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

const long long MOD = 1e9 + 7;

const int maxn = 1e6;

long long mod(long long value) {
  if (value >= 0) {
    return value % MOD;
  }
  for (int i = 1; ; i++) {
    long long tmp = value + i * MOD;
    if (tmp >= 0) {
      return tmp;
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n);
  vector<long long> sum(maxn, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long tmp = 0;
  for (int i = n - 1; i >= 1; i--) {
    tmp += a[i];
    sum[i] = tmp;
    if (sum[i] >= MOD) {
      sum[i] = mod(sum[i]);
    }
  }
  long long ans = 0;
  for (int i = 0; i < n - 1; i++) {
    ans += a[i] * sum[i + 1];
    if (ans >= MOD) {
      ans = mod(ans);
    }
  }
  cout << ans << '\n';
  return 0;
}


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

int main() {
	int s,i=0,j;
	vector<int> a;
	cin >> s;
	a.push_back(s);
	i++;
	while (true) {
		if (a[i - 1] % 2) {
			a.push_back(a[i - 1] * 3 + 1);
		}
		else {
			a.push_back(a[i - 1] / 2);
		}
		for (j = 0; j < i; j++) {
			if (a[i] == a[j]) {
				cout << i + 1 << endl;
				return(0);
			}
		}
		i++;
	}
	
}

Measured memory_bytes: 256