akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

struct union_find {
	vector<int> v;
	union_find(int n) : v(n, -1) {}
	int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
	}
	bool root(int x) { return v[x] < 0; }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};


int main() {
  int N, M;

  cin >> N >> M;

  vector<int> p(N);
  int x, y;

  union_find uf(N);

  for(int i = 0; i < N; i++) {
    cin >> p[i];
    p[i]--;
  }

  for(int i = 0; i < M; i++){
    cin >> x >> y;

    x--;
    y--;
    x = uf.find(x);
    y = uf.find(y);

    uf.unite(x, y);
  }

  vector<vector<int>> a(N), b(N);
  int k;
  for(int i = 0; i < N; i++){
    k = uf.find(i);
    a[k].push_back(i);
    b[k].push_back(p[i]);
  }

  int count = 0;

  // for (int i = 0; i < N; i++){
  //   if(!a[i].empty()){
  //     for(int x : a[i]){
  //       for(int y : b[i]){
  //         if (x == y) {
  //           count++;
  //            break;
  //          }
  //       }
  //     }
  //   }
  // }

  for (int i = 0; i < N; i++) {
		if (!a[i].empty()) {
			set<int> s(b[i].begin(), b[i].end());
			for (int x : a[i])if (s.count(x))count++;
		}
	}
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 12032
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	string s;
	cin >> s;
	s.insert(s.begin() + 4, ' ');
	cout << s << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int x,y,z,k,s,ans=0;
    scanf("%d %d",&k,&s);
    for(x=0;x<=k;x++){
        for(y=0;y<=k;y++){
            z=s-(x+y);
            if(z>=0&&z<=k)ans++;
        }
    }
    printf("%d\n",ans);
    }


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(void)
{
	cin.tie(0);	ios_base::sync_with_stdio(0);
	int k;	cin >> k;
	cout << arr[k-1];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<(#a)<<':'<<(a)<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key < value;
}

int binary_search(vector<ll> a,ll key){
  ll ok = a.size();
  ll ng = -1;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> a(n);
  vector<vector<pair<int,bool>> > xy(n,vector<pair<int,bool>>(0));
  rep(i,n){
    cin>>a[i];
    rep(j,a[i]){
      int x,y;cin>>x>>y;
      x--;
      xy[i].pb(mp(x,y));
    }
  }
  
  int ans = 0;
  rep(i,1<<n){
    bitset<15> bs(i);
    bool ok = true;
    rep(j,n){
      if(!bs[j])continue;
      rep(k,a[j]){
        if(bs[xy[j][k].fi] != xy[j][k].se){
          ok = false;
          break;
        }
      }
      if(!ok)break;
    }

    int tmp = 0;
    if(ok){
      rep(j,n)tmp += bs[j];
    }
    ans = max(ans,tmp);
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
using namespace std;
typedef long long ll;
#define mod 2147493647
int main() {
	int h, w;
	char g[100][100];
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> g[i];
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (g[i][j] != '#') {
				g[i][j] = '0';
				if (i > 0 && g[i - 1][j] == '#')
					g[i][j]++;
				if (i < h - 1 && g[i + 1][j] == '#')
					g[i][j]++;
				if (i > 0 && j > 0 && g[i - 1][j - 1] == '#')
					g[i][j]++;
				if (i > 0 && j < w - 1 && g[i - 1][j + 1] == '#')
					g[i][j]++;
				if (j > 0 && g[i][j - 1] == '#')
					g[i][j]++;
				if (j < w - 1 && g[i][j + 1] == '#')
					g[i][j]++;
				if (i < h - 1 && j < w - 1 && g[i + 1][j + 1] == '#')
					g[i][j]++;
				if (i < h - 1 && j >0 && g[i + 1][j - 1] == '#')
					g[i][j]++;
			}
		}
	}
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			cout << g[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  string W[N];
  map<string,int> mp;
  for(int i=0;i<N;i++){
    cin >> W[i];
    mp[W[i]]++;
  }

  /*for(auto itr=mp.begin();itr!=mp.end();itr++){
    cout << itr->first << " " << itr->second << endl;
  }*/

  for(auto itr=mp.begin();itr!=mp.end();itr++){
    if(itr->second >= 2){
      cout << "No" << endl;
      return 0;
    }
  }

  bool isok=true;
  for(int i=0;i<=N-2;i++){
    char last,start;
    last=W[i][W[i].size()-1];
    start=W[i+1][0];

    //cout << last << start << endl;
    if(last != start){
      isok = false;
      break;
    }
  }

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

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    string s; cin >> s;
    int n=s.size();
    int a=0,b=0;
    rep(i,n){
        if(s[i]=='0') a++;
        else b++;
    }
    cout << n-abs(a-b) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, K; cin >> N >> K;
    string s; cin >> s; s += '1';
    vector<pair<int, int>> seg;

    bool zeroflg = false;
    int l, r;
    for(int i=0; i<s.size(); i++){
        if(zeroflg == false && s[i] == '0'){
            zeroflg = true;
            l = i;
        }
        else if(zeroflg == true && s[i] == '1'){
            zeroflg = false;
            r = i-1;
            seg.push_back({l, r});
        }
    }

    
    //for(int i=0; i<seg.size(); i++){
    //    printf("%d %d\n", seg[i].first, seg[i].second);
    //}
    

   if(seg.size() <= K){
       cout << N << endl;
       return 0;
   }

    int ans = 0;
    for(int i=0; i<seg.size(); i++){
        if(i != 0){
            if(i+K >= seg.size()){
                int tmp = N - seg[i-1].second - 1;
                ans = max(ans, tmp);
            }
            else{
                int tmp = seg[i+K].first - seg[i-1].second - 1;
                ans = max(ans, tmp);
            }
        }
        else{
            int tmp = seg[K].first;
            ans = max(ans, tmp);
        }
    }


//    int ans = 0;
//    for(int i=0; i<seg.size()-K+1; i++){
//        if(i != 0){
//            int tmp;
//            if(i+K >= seg.size()-1){
//                tmp = N - seg[i-1].second - 1;
//            }
//            else{
//                tmp = seg[i+K].first - seg[i-1].second - 1;
//            }
//            ans = max(ans, tmp);
//        }
//        else{
//            int tmp = seg[K].first;
//            ans = max(ans, tmp);
//        }
//    }

   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 1020
while True:
    H, W = list(map(int, input().split()))
    if H == 0 and W == 0:
        break
    else:
        for i in range(H):
            for j in range(W):
                if i == 0:
                    if j == W-1:
                        print("#")                    
                    else:
                        print("#", end="")
                elif i == H-1:
                    if j == W-1:
                        print("#\n")                    
                    else:
                        print("#", end="")                    
                elif j == 0:
                    print("#", end="")
                elif j == W-1:
                    print("#")
                else:
                    print(".", end="")


Measured memory_bytes: 7008
import numpy as np
N, M = [int(str) for str in input().strip().split()]
cakes = np.array([[int(str) for str in input().strip().split()] for i in range(N)])

signs_list = [[i, j, k] for i in (-1, 1) for j in (-1, 1) for k in (-1, 1)]
score_list = []

for signs in signs_list:
    sscores = np.dot(cakes, np.array(signs).T)
    sorted_cakes = cakes[np.argsort(sscores)[::-1]]
    score_list.append(sum(np.dot(sorted_cakes[:M], np.array(signs).T)))

print(max(score_list))

Measured memory_bytes: 20236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int N=310;
int d[N][N];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
    {
        scanf("%d",&d[i][j]);
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
    {
        int flag=1;
        for(int k=1;k<=n;k++)
        {
            if(d[i][j]>d[i][k]+d[k][j])
            {
                cout<<"-1"<<endl;
                return 0;
            }
            if(i!=j&&i!=k&&j!=k&&d[i][j]==d[i][k]+d[k][j]) flag=0;
        }
        if(flag) ans+=d[i][j];
    }
    cout<<ans<<"\n";
    return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

const int MAX_N = 55556;
int prime[MAX_N+1];
bool is_prime[MAX_N + 1];

void eratos(int n) {
    int p = 0;
    for (int i = 0; i <= n; ++i) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; ++i) {
        if (is_prime[i]) {
            prime[p++] = i;
            for (int j = 2*i; j <= n; j += i) is_prime[j] = false;
        }
    }
}


int main() {
    int N;
    cin >> N;
    eratos(MAX_N);
    vector<int> a(N);
    int cnt = 0;
    int cur;
    for (cur=2; cur<MAX_N; ++cur) {
        if (cnt >= N) break;
        if (is_prime[cur]) {
            string tmp = to_string(cur);
            if (tmp[tmp.size()-1] == '2' or tmp[tmp.size()-1] == '3') {
                a[cnt++] = cur;
            }
        }
    }

    rep(i, a.size()) {
        if (i) cout << " ";
        cout << a[i];
    }
    cout << endl;
}


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

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

const ll INF = 1LL << 60;

int main(){

  ll n,r;
  cin >> n >> r;
  ll dp[110][100010]={0};
  ll w[1000],v[1000];
  FOR(i,n){
    cin >> w[i] >> v[i];
  }
  
  FOR(i,n){
    for(int j=0;j<=r;j++){
      if(j-w[i]>=0){
        chmax(dp[i+1][j],dp[i][j-w[i]]+v[i]);
      }
        chmax(dp[i+1][j],dp[i][j]);
      
    }
  }

  cout << dp[n][r] << endl;
}


Measured memory_bytes: 86144
S = [c for c in input().strip()]

if S != list(reversed(S)):
    print("No")
else:
    x = (len(S) - 1) // 2
    s1 = S[:x]
    s2 = S[x+1:]
    if s1 != list(reversed(s1)):
        print("No")
    elif s2 != list(reversed(s2)):
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdlib>

using namespace std;

#define int long long
#define LL long long
#define ULL unsigned long long

const int LL_INF = ~(ULL)0 >> 1;

typedef pair<int, int> P;

P s[202], pho[1002];

signed main() {
    int m, n;

    while (cin >> m, m) {
        for (int i = 0; i < m; ++i) {
            int x, y;
            cin >> x >> y;
            s[i] = P(x, y);
        }

        cin >> n;
        for (int i = 0; i < n; ++i) {
            int x, y;
            cin >> x >> y;
            pho[i] = P(x, y);
        }

        sort(s, s + m);
        sort(pho, pho + n);

        for (int i = 0; i < n - m; ++i) {
            int count = 0;
            int nx = s[count + 1].first - s[count].first, ny = s[count + 1].second - s[count].second, pre = i;

            for (int j = i; j < n; ++j) {
                if ((pho[j].first - pho[pre].first != nx) || (pho[j].second - pho[pre].second != ny)) continue;

                if (count == m - 2) {
                    cout << pho[i].first - s[0].first << " " << pho[i].second - s[0].second << endl;
                    goto end;
                }
                count++;
                nx = s[count + 1].first - s[count].first;
                ny = s[count + 1].second - s[count].second;
                pre = j;
            }
        }

        end:;
    }
    return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int dp[105][4][2];

int main() {
    string S;
    int K;
    cin >> S >> K;

    dp[0][0][0] = 1;
    rep(i,S.size())rep(j,4)rep(k,2){
        int nd = S[i] - '0';
        rep(d,10){
            int ni = i + 1;
            int nj = j;
            if (d != 0) {
                nj = j + 1;
            }
            if ( nj > K ) {
                continue;
            }

            int nk = k;
            if (k == 0 && d > nd) {
                continue;
            }
            if (d < nd) {
                nk = 1;
            }
            dp[ni][nj][nk] += dp[i][j][k];
        }
    }
    cout << dp[S.size()][K][0] + dp[S.size()][K][1] << endl;
}


Measured memory_bytes: 504
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void println(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n, a, b; cin >> n >> a >> b;
    int ans = 0;
    repi(i, 1, n + 1) {
        int t = i, sum = 0;
        while(t > 0) {
            sum += t % 10;
            t /= 10;
        }
        if(a <= sum && sum <= b) {
            //cout << sum << endl;
            ans += i;
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1000000007
#define PI 3.141592653
#define inf 100007
#define P pair<ll,ll>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

int n,m,q;
vi a,b,c,d;
ll ans=0;
vi v;
void dfs(int i,int j){
    if(i==n){
        ll res=0;
        pan(k,q){
            if(v[b[k]-1]-v[a[k]-1]==c[k]) res+=d[k];
        }
        ans=max(ans,res);
    }
    else{
        for(int l=j;l<=m;l++){
            v.pb(l);
            dfs(i+1,l);
            v.pop_back();
        }
    }
}

int main(){
    cin>>n>>m>>q;
    pan(i,q){
        int u,v,w,x;
        cin>>u>>v>>w>>x;
        a.pb(u),b.pb(v),c.pb(w),d.pb(x);
    }
    dfs(0,1);
    cout<<ans;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
const int MOD = 1000000007;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)

int main()
{
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i,N){
        cin >> X[i];
    }
    sort(X.begin(), X.end());
    int start = X[0];
    int end = X[N-1];
    //cout << start <<" "<< end << endl;
    ll dis = 10000000000;
    for (int i = start; i <= end; i++)
    {
        ll add = 0;
        for (int j = 0; j < N; j++)
        {
            add +=(i - X[j])*(i - X[j]);
        }
        dis = min(dis, add);
        //cout << add << endl;
    }
    cout << dis << endl;
    return 0;
}

Measured memory_bytes: 3608
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
V = list(map(int, input().split(' ')))
C = list(map(int, input().split(' ')))

r = 0
for i in range(N):
    d = V[i] - C[i]
    if d > 0:
        r += d

print(r)


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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(b < c || d < a) cout << 0 << endl;
  else if(a <= c && c <= b && b <= d) cout << b - c << endl;
  else if(c <= a && d <= b && d <= b) cout << d - a << endl;
  else if(c <= a && b <= d) cout << b - a << endl;
  else if(a <= c && d <= b) cout << d - c << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>


int main() {
	int n, k; std::cin >> n >> k;
	std::vector<std::pair<int, int>> sushi(n);
	for (auto& pair : sushi) {
		std::cin >> pair.first >> pair.second;
		pair.first--;
	}
	std::sort(sushi.begin(), sushi.end(), [](const std::pair<int, int> a, const std::pair<int, int> b) {return a.second > b.second; });
	std::vector<int> min_score(n);
	std::vector<bool> appear(n, false);
	std::priority_queue<int, std::vector<int>, std::greater<>> used;
	std::priority_queue<int> not_use;
	long long int sum = 0, type = 0;
	for (int i = 0; i < k; ++i) {
		if (!appear[sushi[i].first]) {
			appear[sushi[i].first] = true;
			++type;
		}
		else {
			used.push(sushi[i].second);
		}
		sum += sushi[i].second;
	}
	for (auto i = k; i < n; ++i) {
		if (!appear[sushi[i].first]) {
			appear[sushi[i].first] = true;
			not_use.push(sushi[i].second);
		}
	}
	long long int max = sum + type * type;
	while (!used.empty() && !not_use.empty()) {
		sum += not_use.top() - used.top();
		not_use.pop(); used.pop(); ++type;
		max = std::max(max, sum + type * type);
	}
	std::cout << max << std::endl;
}


Measured memory_bytes: 1800
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);
main(){
    #define task "TASK"
    if(fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        //freopen(task".out","w",stdout);
    }
    forinc(i,1,5) if(!in) return cout<<i,0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n;
char s[20];
int main(){
	cin >> s;

	n = strlen(s);
	REP(i,n)
		s[i] -= '0';

	ll ans = 0;
	REP(i,(1 << (n - 1))) {
		ll a = s[0];
		REP(j,n - 1) {
			if(i & (1 << j)) {
				ans += a;
				a = s[j + 1];
			}else {
				a *= 10;
				a += s[j + 1];
			}
		}
		ans += a;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  char s[100][100];
  char t[100][100];
  char u[100][100];
  int i,j,x,h,w,count=0,cnt1=0,cnt2=0;

  scanf("%d %d",&h,&w);

  for(i=0;i<h;i++){
      scanf("%s",s[i]);
  }

  for(i=0;i<h;i++){
    count=0;
    for(j=0;j<w;j++){
      if(s[i][j]=='.'){
	count++;
      }
    }
    if(count!=w){
      for(x=0;x<w;x++){
	t[i-cnt1][x] = s[i][x];
      }
    }
    else cnt1++;
  }

  for(i=0;i<w;i++){
    count=0;
    for(j=0;j<h-cnt1;j++){
      if(t[j][i]=='.'){
	count++;
      }
    }
    if(count!=h-cnt1){
      for(x=0;x<h-cnt1;x++){
	u[x][i-cnt2] = t[x][i];
      }
    }
    else cnt2++;
  }

  for(i=0;i<h-cnt1;i++){
    for(j=0;j<w-cnt2;j++){
      printf("%c",u[i][j]);
    }
    printf("\n");
  }




  return 0;
}


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

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

#define REPR(i,n) for(int i =n; i >=0; i--)

#define _REP(i,m,n) for(int i =m; i <n; i++)

#define INF 2e9


using namespace std;

int main()
{

    int n;
    cin >> n;
    vector<int > x(n),y(n),h(n);
    int th;
    REP(i,n){
        cin >> x[i] >> y[i] >> h[i] ;
        if(h[i] != 0)th = i;
    }
    bool flag = false;

    int  ans_h;
    vector<long long > a(n);
    REP(i,101)REP(j,101){
        flag = true;
        ans_h = h[th] + abs( x[th] - i) + abs(y[th] - j);
        REP(k,n){
            if(h[k] != max((ans_h- abs(x[k] - i) - abs(y[k] - j)),0))flag = false;
        }
        if(flag){
            cout << i << " "<< j << " " << ans_h << endl;
            return 0;
        }
    }


}

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

const int MN = 100005;

int N;
std::vector<int> G[MN];

int f[MN];
void DFS(int u, int p) {
	int x = 0, y = 0;
	for (int v : G[u]) if (v != p) {
		DFS(v, u);
		int z = x & f[v];
		if (z) y = std::max(y, 32 - __builtin_clz(z));
		x |= f[v];
	}
	x &= ~((1 << y) - 1);
	f[u] = x + (1 << y);
}

int main() {
	scanf("%d", &N);
	for (int i = 1, x, y; i < N; ++i) {
		scanf("%d%d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	DFS(1, 0);
	printf("%d\n", 31 - __builtin_clz(f[1]));
	return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
	return 0;
}


Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		h: usize,
		w: usize,
		k: usize,
		cs: [Chars; h],
	}

	let mut num = vec![0usize; h];
	for i in 0..h {
		for j in 0..w {
			if cs[i][j] == '.' {
				num[i] = num[i] << 1;
			}
			else {
				num[i] = (num[i] << 1) + 1;
			}
		}
	}

	let mut ans = 0;
	for i in 0..2<<(h-1) {
		for j in 0..2<<(w-1) {
			let mut count = 0;
			for z in 0..h {
				if (i >> z) % 2 == 0 {
					continue;
				} 
				count +=  (num[z] & j).count_ones() as usize;
			}
			if count == k {
				ans += 1;
			}
		}
	}
	println!("{}", ans);
}



Measured memory_bytes: 2172
#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 <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <stdio.h>
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; }
const int INF = 1001001000;
const int MOD = 1000000007;

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく
int N;
vector<int> E[200001];
vector<bool> seen;
typedef pair<int, int> P;
int D[101];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;

bool like2017OrNot(int N) {
    bool ok = true;
    if (N == 1) ok = false;
    //Nが素数か
    for(int i = 2;i<(int)sqrt(N)+1;i++){
        if (N % i == 0) ok = false;
    }
    //(N+1)/2が素数か
    for (int i = 2; i < (int)sqrt((N+1)/2) + 1; i++) {
        if ((N + 1) / 2 == 2) break;

        if (((N+1)/2) % i == 0) ok = false;
    }
    return ok;
}

int main() {
    int Q; cin >> Q;
    vector<bool> retu(100003);
    for (int i = 1; i <= 100001; i = i+2) {
        retu.at(i) = like2017OrNot(i);
        //if (retu.at(i)) cout << i << endl;
    }
    vector<int> rui(100003,0);
    for (int i = 0; i < 100002; i++) {
        rui.at(i + 1) = rui.at(i) + retu.at(i);
    }
    vector<int> left(Q), right(Q);
    for (int i = 0; i < Q; i++) cin >> left.at(i) >> right.at(i);
    //処理
    for (int i = 0; i < Q; i++) {
        cout << rui.at(right.at(i)+1)-rui.at(left.at(i)) << endl;
    }
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <math.h>


main()
{
long long int sum;
int n,m,min,max;

scanf("%d %d",&n,&m);
min=m;
max=m;
sum=m;
n--;
while(n--){
	scanf("%d",&m);
	if(min>m)min=m;
	if(max<m)max=m;
	sum+=m;
}
printf("%d %d %lld\n",min,max,sum);
}


Measured memory_bytes: 2092
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);        

        int N = sc.nextInt();
        int K = sc.nextInt();
        
        int count=1;
        while(N>=K){
            N = N / K;
            count++;
        }

        System.out.println(count);
    }
}


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

using namespace std;

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int ans = 0, tmp = 0;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'I')
			tmp++;
		else
			tmp--;
		ans = max(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get { () => (get().parse().unwrap()) }
    
    let n = get!();
    let mut ans = 0;
    let mut table = vec![0; 100_001];
    for _ in 0..n {
    	let a: u32 = get!();
        if a > 100_000 {
        	ans += 1;
        } else {
        	table[a as usize] += 1;
        }
    }
    
	for (i, &c) in table.iter().enumerate() {
        if i > c {
        	ans += c;
        } else if i < c {
        	ans += c - i;
        }
    }
    
    println!("{}", ans);
}

Measured memory_bytes: 6524
#include<iostream>
#include<cmath>
using namespace std;
const int N=10000;

bool prime(int n){
  //偶数を省く
  if(n==2) return true;
  else if(n%2==0) return false;

  double sqrtnum=sqrt(n);
  
  for(int i=3;i<=sqrtnum;i++){
    if(n%i==0){
      return false;
    }
  }
  return true;
}

int main(){
  int array[N];
  int num;
  int count=0;

  cin>>num;
  
  for(int i=0;i<num;i++){
    cin>>array[i];
  }

  for(int i=0;i<num;i++){
    if(prime(array[i])==true){
      count++;
    }
  }

  cout<<count<<"\n";

  return 0;
}

  
      



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

string S;

int main()
{
    cin >> S;
    bool aflag = false;
    bool bflag = false;
    for(int i = 0; i < 3; i++)
    {
        if(S[i] == 'A') aflag = true;
        if(S[i] == 'B') bflag = true;
    }
    cout  << ((aflag && bflag) ? "Yes" : "No") << endl;

}

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

int main(){
    int H,A[252];
    scanf("%d",&H);
    
    for(int i = 1; i <= H; i++) scanf("%d",&A[i]);
    
    for(int i = 1; i <= H; i++){
        printf("node %d: ",i);
        printf("key = %d, ", A[i]);
        if( i / 2 != 0) printf("parent key = %d, ",A[i / 2]);
        if( 2 * i <= H) printf("left key = %d, ", A[2 * i]);
        if( 2 * i + 1 <= H) printf("right key = %d, ",A[2 * i + 1]);
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define last Last
#define int long long
const int N=1e6+5;
int n,k,m,a[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
signed main()
{
	n=read();k=read();m=read();
	for(int i=1;i<=m;i++)
		a[read()]++;
	for(int i=1;i<=n;i++)
		if(k+a[i]-m>0)puts("Yes");
		else puts("No");
}


Measured memory_bytes: 1408
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main() {
  string w;
  cin >> w;
  map<int, int> mp;
  rep(i, w.size())
    mp[w[i]]++;
  for(auto it=mp.begin(); it!=mp.end(); it++) {
    if(it->second%2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

int main() {
	int		b,c,i,j,k,n,m,x,y,ans = 0;
	string	str;
	
	cin >> n;
	
	map<string, int> aa;
	
	for(i=0;i<n;i++) {
		cin >> str;
		aa[str]++;
	}
	
	for(auto p : aa) {
		ans = max(ans , p.second);
	}
	
	for(auto p: aa) {
		if (p.second == ans) {
			cout << p.first << endl;
		}
	}
	

}


Measured memory_bytes: 25216
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#define mp make_pair
#define pb push_back
using namespace std;
const int N=2e5+5;

int n,m;
vector <int> nb[N];

int wave[N];
bool vis[N];

queue <int> q;

int main()
{
  int i;
  int a,b,v;

  cin>>n>>m;
  for(i=1;i<=m;i++)
  {
      scanf("%d%d",&a,&b);

      nb[a].pb(b);
      nb[b].pb(a);
  }

  wave[1]=0;
  vis[1]=true;
  wave[n]=3;
  q.push(1);
  while(!q.empty())
  {
      v=q.front();
      q.pop();

      for(i=0;i<nb[v].size();i++)
      {
          if(!vis[nb[v][i]])
          {
              q.push(nb[v][i]);
              wave[nb[v][i]]=wave[v]+1;
              vis[nb[v][i]]=true;
          }
      }
  }


  if(wave[n]<=2)
      printf("POSSIBLE\n");
  else
      printf("IMPOSSIBLE\n");

  return 0;
}


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


int main()
{
	int N;
	cin>>N;
	vector<int> L(N);
	rep(i,N)
	{
		cin>>L[i];
	}
	sort(L.begin(),L.end());
	ll ans=0;
	rep(i,N-1)
	{
		int a=L[i];
		Rep(j,i+1,N)
		{
			int b=L[j];
			int head=j;
			int tail=N;
			while(tail-head>1)
			{
				int mid=head+(tail-head)/2;
				int c=L[mid];
				if(c<a+b)
				{
					head=mid;
				}
				else
				{
					tail=mid;
				}
			}
			ans+=head-j;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3632
N = int(input())
S = input()
R = 0
G = 0
B = 0
ans = 0
for i in range(N):
    if S[i] == 'R':
        R+= 1
    elif S[i] =='G':
        G+= 1
    else:
        B+= 1
ans = R*G*B
for i in range(int((N+1)/2)):
    for j in range(i,N-i):
        if S[j-i] != S[j] and S[j] != S[j+i] and S[j+i] != S[j-i]:
            ans -= 1

print(ans)

Measured memory_bytes: 9236
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
M=0
for i in range(N):
    A[i]-=1
for i in range(N-1):
    if A[i]+1==A[i+1]:
        M+=B[A[i]]+C[A[i]]
    else:
        M+=B[A[i]]
print(M+B[A[N-1]])

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}



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

    vector<int> p(n);

    rep(i,n){
        cin >> p[i];
    }

    sort(p);

    ll ans = 0;

    for(int i=0;i<k;i++){
        ans += p[i];
    }

    cout << ans << endl;
}


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

void solve(long long N){
    if (N < 10) cout << N << '\n';
    else if (N < 100) cout << 9 << '\n';
    else if (N < 1000) cout << 9 + N - 100 + 1 << '\n';
    else if (N < 10000) cout << 9 + 900 << '\n';
    else if (N < 100000) cout << 9 + 900 + N - 10000 + 1 << '\n';
    else if (N < 1000000) cout << 9 + 900 + 90000 << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
#define MAXE(a,b) a=max(a,b)
#define MINE(a,b) a=min(a,b)

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(N);
    I vec;
    V<LL> two;
    LL s = 1;
    for(int a = 0;a < 40;a++){
        two.push_back(s);
        s *= 2;
    }
    multiset<LL> se;
    REP(a,N){
        LCIN(b);
        vec.push_back(b);
        se.insert(b);
    }
    LL ans = 0;
    while(!se.empty()){
        LL s = *prev(se.end(),1);
        se.erase(prev(se.end(),1));
        LL w = *upper_bound(ALL(two),s);
        if(se.find(w-s) != se.end()){
            se.erase(se.find(w-s));
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 10484
n = int(input())
d1 = []
d2 = []
for i in range(n):
  w1, w2 = map(int, input().split())
  d1.append(w1)
  d2.append(w2)
a = 'No'
for i in range(n-2):
  if d1[i]==d2[i] and d1[i+1]==d2[i+1] and d1[i+2]==d2[i+2]:
    a = 'Yes'
    break
print(a)

Measured memory_bytes: 9196
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    T = list(map(int, input().split()))
    A = list(map(int, input().split()))
    if T[0] <= A[0] and A[N-1] <= T[N-1]:
        ans = 1
    else:
        return 0
    MOD = int(1e9) + 7
    for i in range(1, N-1):
        t = (T[i] == T[i-1])
        a = (A[i] == A[i+1])
        if not(t) and not(a):
           if T[i] != A[i]:
               return 0
        elif not(t) and a:
            if A[i] < T[i]:
                return 0
        elif t and not(a):
            if T[i] < A[i]:
                return 0
        else:
            ans *= min(T[i], A[i])
            ans %= MOD
    
    return ans

if __name__ == "__main__":
    print(main())

Measured memory_bytes: 19376
#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...));
}

vector<int> f(int n, int k, int c, const string& s) {
        vector<int> d;
        
        int i = 0;
        while (i < n) {
                if (s[i] == 'o') {
                        d.push_back(i);
                        i += c + 1;
                } else {
                        i++;
                }

                if (d.size() == k) break;
        }

        return d;
}

int main() {
        int n, k, c;
        cin >> n >> k >> c;

        string s, t;
        cin >> s;
        reverse_copy(s.begin(), s.end(), back_inserter(t));

        auto c1 = f(n, k, c, s), c2 = f(n, k, c, t);

        reverse(c2.begin(), c2.end());

        vector<int> ans;
        REP(i, min(c1.size(), c2.size())) {
                if (c1[i] == n - c2[i] - 1) {
                        ans.push_back(c1[i] + 1);
                }
        }

        for (int x : ans) cout << x << endl;

        return 0;
}


Measured memory_bytes: 4348
n = int(input())
a = list(map(int,input().split()))
c = 0
d = [0] * n
ans = []
for i in range(n):
    m = n-i
    p = 1
    b = 0
    while m * p <= n:
        tmp = m * p
        if d[tmp-1] == 1:
            b += 1
        p += 1
    if b % 2 != a[m-1]:
        d[m-1] = 1
        ans.append(m)
        c += 1

if c%2 != a[0]:
    print('-1')
else:
    print(c)
    print(" ".join(repr(e) for e in ans))

Measured memory_bytes: 19856
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [N, K] = input[0].map(Number);

  const Sunukes = Array<boolean>().fill(false);
  let answer = N;

  for (let i = 1; i <= K * 2; i += 2) {
    const A = input[i + 1].map(Number);

    A.forEach((a) => {
      if (!Sunukes[a]) {
        Sunukes[a] = true;
        answer -= 1;
      }
    });
  }

  return answer;
};

console.log(main(read()));


Measured memory_bytes: 29824
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>
#include <cmath>
#include <map>
#include <set>
#include <utility>
#include <stack>
#include <cstring>
#include <bitset>
#include <deque>
#include <string>
#include <list>
#include <cstdlib>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 200000 + 100;
typedef long long ll;
typedef long double ld;
char A[maxn];
char Ma[maxn * 2];
int Mp[maxn * 2];
ll len;
ll ans;
void Manachar()
{
	int l = 0;
	Ma[l++] = '.';
	Ma[l++] = ',';
	for (int i = 0; i < len; i++)
	{
		Ma[l++] = A[i];
		Ma[l++] = ',';
	}
	Ma[l] = 0;
	int pnow = 0;
	int pid = 0;
	for (int i = 1; i < l; i++)
	{
		if (pnow > i)
		{
			Mp[i] = min(Mp[2 * pid - i], pnow - i);
		}
		else
		{
			Mp[i] = 1;
		}
		for (; Ma[i - Mp[i]] == Ma[i + Mp[i]]; Mp[i]++);
		if (i + Mp[i] > pnow)
		{
			pnow = i + Mp[i];
			pid = i;
		}
	}
	for (int i = 1; i < l; i++)
	{
		if (Ma[i] == ',')
		{
			ans -= (Mp[i] - 1) / 2;
		}
		else
		{
			ans -= (Mp[i] - 1) / 2;
		}
	}
}
int main()
{
	while (~scanf("%s", A))
	{
	    len = strlen(A);
		ans = len * (len - 1) / 2 + 1;
		map<char, int> cnt;
		for (int i = 0; i < len; i++)
		{
			ans -= cnt[A[i]];
			cnt[A[i]]++;
		}
//		Manachar();
		printf("%lld\n", ans);
	}
}

Measured memory_bytes: 512
import java.util.*;

public class Main {

	public static void main(String[] args) {


		int N = 0;
		int A = 0;
		int B = 0;
		int sum = 0;
		int sumList = 0;
		List<Integer> intList = new ArrayList<Integer>();

		Scanner scanner = new Scanner(System.in);

		N = scanner.nextInt();
		A = scanner.nextInt();
		B = scanner.nextInt();

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

			while(j >= 1) {
				sum = sum + (j % 10);
				j = (int) Math.floor(j / 10);
			}

			if(A <= sum && sum <=B) {
				sumList = sumList + i;
			}
			sum = 0;
		}
		System.out.println(sumList);
	}
}


Measured memory_bytes: 21716