akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define PI ( acos(-1.0) )
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define FORD(i,a,b) for(int i=a ; i>=b ; i--)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )
#define all(x) x.begin(),x.end()
#define flog2(n) 64 - __builtin_clzll(n) - 1
#define popcnt(n) __builtin_popcountll(n)

using namespace std;

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



int main()
{//IN; //OUT;
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    string s;
    int p;
  	int nn;
  	cin >> nn;
    cin >> p >> s;

    ll res = 0;
    int n = s.size();
    // find all substr with len <= 20
    FOR (i, 0, n - 1) {
        int val = 0;        
        for (int j = i; j < n && j < i + 20; j++) {
            val = val * 10 + s[j] - '0';
            val %= p;
            if (val == 0) {
                res++;
            }
        }
    }
    if (n <= 20) {
        cout << res << endl;
        return 0;
    }

    int pw2 = 1;
    int pw5 = 1;
    
    while (p % 2 == 0) {
        p /= 2;
        pw2 *= 2;
    }

    while (p % 5 == 0) {
        p /= 5;
        pw5 *= 5;
    }
    // find all position that a substr can end at
    int curVal2 = 0, curVal5 = 0;
    vector<bool> canEnd(n);

    FOR (i, 0, n - 1) {
        curVal2 = curVal2 * 10 + s[i] - '0';
        curVal2 %= pw2;

        curVal5 = curVal5 * 10 + s[i] - '0';
        curVal5 %= pw5;

        if (curVal2 == 0 && curVal5 == 0 && i >= 19) {
            canEnd[i] = 1;
            // cout << i << endl;
        }
    }

    // calc suffix
    vector<ll> suffixSum(n + 1);
    ll curPow = 1;
    FORD (i, n - 1, 0) {
        suffixSum[i] = curPow * (s[i] - '0') + suffixSum[i + 1];
        suffixSum[i] %= p;
        curPow = curPow * 10 % p;
        // cout << i << " " << suffixSum[i] << endl;
    }

    // j - i >= 20
    vector<ll> cnt(p + 1);
    FORD (i, n - 21, 0) {
        // update
        if (canEnd[i + 20]) {
            cnt[suffixSum[i + 21]]++;
        }

        res += cnt[suffixSum[i]];
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2196
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}cout<<endl;}

int main() {
    ll a,b;
    cin>>a>>b;
    ll keta =0;
    

    vector<ll> va,vb;

    auto bb = b;
    keta =0;
    while(bb>0){
        bb=bb>>1;
        keta++;
    }
    rep(i,keta){
        if(i == 0 ){
            if(b % 4 == 1 || b % 4 == 2) vb.push_back(1);
            else vb.push_back(0);
        }
        else
        {
            ll t = pow(2, i + 1);
            auto cnt1 = max((b + 1) % t - pow(2, i), 0.0);
            vb.push_back(cnt1);
        }
    }
    reverse(alll(vb));
    ll suma=0,sumb=0;

    rep(i, vb.size()) {
        sumb*=2;
        sumb+=(vb[i] % 2);
    }

    if(a == 0){
        pr(sumb);
        return 0;
    }
    a--;
    ll aa = a;

    while(aa>0){
        aa=aa>>1;
        keta++;
    }
    rep(i,keta){
        if(i == 0 ){
            if(a % 4 == 1 || a % 4 == 2) va.push_back(1);
            else va.push_back(0);
        }
        else
        {
            ll t = pow(2, i + 1);
            auto cnt1 = max((a + 1) % t - pow(2, i), 0.0);
            va.push_back(cnt1);
        }
    }
    reverse(alll(va));



    rep(i, va.size()) {
        suma*=2;
        suma+=(va[i] % 2);
    }
    pr(sumb ^ suma);


    return 0;
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int a, b, m;
  cin >> a >> b >> m;
  vi32 x(a), y(b);
  cin >> x >> y;
  int ans = *min_element(all(x)) + *min_element(all(y));
  rep(i, m) {
    int c, d, e;
    cin >> c >> d >> e;
    c--, d--;
    amin(ans, x[c] + y[d] - e);
  }
  cout << ans << endl;
}


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

using namespace std;

int main() {
    int n;
    while(cin>>n)
    {
        bool flag=0;
        for(int i=0;i<=n/7;i++)
        {
            if((n-7*i)%4==0) {flag=1;break;}
        }
        if(flag) cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}

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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void precal() {

	return;
}

void solve() {
	lli n;
	cin >> n;
	
	double sum = 0;
	
	for (int i = 0; i < n; ++i) {
		double dollar;
		string type;
		cin >> dollar >> type;
		
		if ( type == "BTC" ) sum += dollar * 380000;
		else sum += dollar;
	}
	
	cout << sum << '\n';
}

int main() {
	precal();
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
int max2(int a, int b){return a<b?b:a;}
int min2(int a, int b){return a>b?b:a;}
int max3(int a, int b, int c){return max2(a,max2(b,c));}
int min3(int a, int b, int c){return min2(a,min2(b,c));}
 

int A1, A2, A3, ans;
int main(){
  scanf("%d%d%d", &A1, &A2, &A3);
  ans = max3(A1, A2, A3) - min3(A1, A2, A3);
  printf("%d\n", ans); 
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
typedef long long ll;
int main()
{
	fast;
	double n; cin>>n;
	double res = pow(n/3, 3);
	cout << fixed << setprecision(12) << res << endl;
	return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
using namespace std;

#define TYO 0
#define HIS 1

int main(){
	int in1, in2, in3;
	int ans[2] = {};

	while (scanf("%d,%d,%d", &in1, &in2, &in3) != EOF){
		// 長方形check
		if (pow(in1, 2) + pow(in2, 2) == pow(in3, 2)){
			ans[TYO]++;
		}
		else if (in1 == in2){
			ans[HIS]++;
		}
	}
	for (int i = 0; i < 2; i++){
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N;
  cin >> N;
  vector<int> tree[2 * N];
  int dummy = N;
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    int mid = dummy++;
    tree[a].push_back(mid);
    tree[mid].push_back(a);
    tree[b].push_back(mid);
    tree[mid].push_back(b);
  }
  auto solve = [&](int center) {
    long long depth = 1, leaves = tree[center].size();
    bool used[dummy];
    fill(used, used + dummy, false);
    used[center] = true;
    vector<int> vs;
    for (int v : tree[center]) vs.push_back(v);
    while (!vs.empty()) {
      depth++;
      vector<int> next;
      long long deg = 1;
      for (int v : vs) {
        used[v] = true;
        for (int u : tree[v])
          if (!used[u]) {
            next.push_back(u);
          }
        deg = max(deg, (long long)tree[v].size() - 1);
      }
      leaves *= deg;
      vs.swap(next);
    }
    return make_pair((depth + 1) / 2, leaves);
  };
  long long color = LLONG_MAX, leaves = 0;
  for (int i = 0; i < dummy; i++) {
    if (tree[i].size() == 1) continue;
    auto [c, l] = solve(i);
    // debug(i);
    // debug(c);
    // debug(l);
    // cerr << "\n";
    if (color > c) {
      color = c;
      leaves = l;
    } else if (color == c && leaves > l) {
      leaves = l;
    }
  }
  cout << color << " " << leaves << '\n';
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
const ll INF = (ll)1e18;
const ll MAXN = 1000006;

ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int T=1;
    //cin >> T;
    while(T--){
        ll n;
        cin>>n;
        ll z=n%1000;
        if(z==0) cout<<z<<el;
        else cout<<(1000-z)<<el;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main()
{
	double x[3];
	double y[3];
	double h[3];
	double r;
	double mh=0.0;
	for(int i=0;i<3;i++)
		cin>>x[i]>>y[i];
	double s=abs((x[0]-x[2])*(y[1]-y[2])-(x[1]-x[2])*(y[0]-y[2]));//三角形の面積の2倍
	for(int i=0;i<3;i++)
	{
		int j=i-1;
		if(j<0)
			j=2;
		h[i]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
		mh=max(mh,h[i]);
	}
	r=s/(h[0]+h[1]+h[2]);//内接円の半径
	double ok=0.0;
	double ng=r;
	for(int cnt=0;cnt<100;cnt++)
	{
		double mid=(ok+ng)/2.0;
		if(mid*2>mh*(1.0-mid/r))
			ng=mid;
		else
			ok=mid;
	}
	cout<<setprecision(12)<<ok<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define UMap        std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd   ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm   ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs   ( llong n )          { return ( n < 0 ) ? -n : n; }
    template<class A, class B>inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B>inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    int a[110];
    int sum;

    signed call_of_Cthulhu( signed datum ) {

        int n;
        read n;
        for ( int i = 0; i < n; i++ ) {
            read a[i];
            sum += a[i];
            a[i] *= n;
        }
        int ans = 0;
        int tmp = INF;
        for ( int i = 0; i < n; i++ ) {
            if ( chmin( tmp, std::abs ( sum - a[i] ) ) ) {
                ans = i;
            }
        }
        echo ans fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); echo std::fixed << std::setprecision(8); int main_result = Rlyeh::call_of_Cthulhu(114514); return main_result;}


Measured memory_bytes: 256
//abc153E
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
  int h, n, i, k;
  scanf("%d %d", &h, &n);
  int dp[h], a[n], b[n]; //dp:HPをh減らすために必要な最小魔力、a:AtackPoint、b:MagicPoint
  for(i=0; i < n; i++) scanf("%d %d", &a[i], &b[i]);
  for(i=0; i < h; i++) dp[i]=(1 + i / a[0]) * b[0];//1種類のみで減らしてみる

  for(i=1; i < n; i++){//種類を増やしていく
    for(k=0; k < h; k++){
      if(k < a[i]){
        if(dp[k] > b[i]) dp[k]=b[i];
      }else if(dp[k] > dp[k - a[i]] + b[i]) dp[k]=dp[k - a[i]] + b[i];
    }
  }
  printf("%d", dp[h - 1]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 99999999999999999
#define MOD 998244353 

void func()
{
    char ch;
    cin>>ch;
    if(ch>='a'&&ch<='z'){
        cout<<"a"<<"\n";
    }
    else{
        cout<<"A"<<"\n";
    }
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
 
    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

vector <int> Vp[26];
char in[200050];

int u[200050];
int bit[600000];
void update(int p, int v) {
	for (; p <= IT_MAX; p += p & (-p)) bit[p] += v;
}
int getsum(int p) {
	int rv = 0;
	for (; p; p -= p & (-p)) rv += bit[p];
	return rv;
}
ll getv(int x) {
	memset(bit, 0, sizeof(bit));
	int i, j;
	ll rv = 0;
	for (i = 1; i <= x; i++) {
		rv += getsum(x) - getsum(u[i]);
		update(u[i], 1);
	}
	return rv;
}

vector <int> Vl;
vector <int> Vr;
char in1[100050];
char in2[100050];

int main() {
	int N, i, j;
	scanf("%s", in + 1);
	N = strlen(in + 1);

	for (i = 1; i <= N; i++) Vp[in[i] - 'a'].push_back(i);
	int c = 0;
	for (i = 0; i < 26; i++) if (Vp[i].size() % 2) c++;
	if (c != N % 2) return !printf("-1\n");

	ll ans = 0;
	for (i = 0; i < 26; i++) {
		if (Vp[i].size() % 2) {
			u[Vp[i][Vp[i].size() / 2]] = 2;
		}
	}
	for (i = 0; i < 26; i++) {
		for (j = 0; j < Vp[i].size() / 2; j++) Vl.push_back(Vp[i][j]);
		for (j = 0; j < Vp[i].size() / 2; j++) Vr.push_back(Vp[i][Vp[i].size() - 1 - j]);
	}
	for (auto it : Vl) u[it] = 1;
	for (auto it : Vr) u[it] = 3;
	sort(all(Vl));
	sort(all(Vr));
	ans += getv(N);

	for (i = 0; i < N / 2; i++) in1[i] = in[Vl[i]];
	for (i = 0; i < N / 2; i++) in2[i] = in[Vr[N / 2 - 1 - i]];

	for (i = 0; i < 26; i++) Vp[i].clear();
	for (i = 0; i < N / 2; i++) Vp[in1[i] - 'a'].push_back(i);
	for (i = 0; i < N / 2; i++) Vp[in2[i] - 'a'].push_back(i);
	for (i = 0; i < 26; i++) {
		for (j = 0; j < Vp[i].size() / 2; j++) {
			int x = Vp[i][j];
			int y = Vp[i][j + Vp[i].size() / 2];
			u[x + 1] = y + 1;
		}
	}
	return !printf("%lld\n", ans + getv(N / 2));
}

Measured memory_bytes: 5876
//import java.io.File;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
try{
		//Scanner scan = new Scanner(new File("in.txt"));
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();

		int[][] arr1 = new int[n][m];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				arr1[i][j] = scan.nextInt();
			}
		}
		int[][] arr2 = new int[m][l];
		for(int i = 0; i < m; i++) {
			for(int j = 0; j < l; j++) {
				arr2[i][j] = scan.nextInt();
			}
		}

		for(int i = 0; i < n; i++) {
			for(int j = 0; j < l; j++) {
				long sum = 0;
				for(int k = 0; k < m; k++) {
					sum += arr1[i][k]*arr2[k][j];
				}
				System.out.print(sum);
				if(j!=l-1) System.out.print(" ");
			}
			System.out.println();
		}
		

}catch(Exception e) {
	e.printStackTrace();
}
	}
}

Measured memory_bytes: 56180
#include<bits/stdc++.h>
using namespace std;
#define int long long
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/*---------------------template----------------------*/
/*----------------------end--------------------------*/
/* --------------------ライブラリ--------------------*/
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
/*---------------------臨時関数----------------------*/
/*----------------------end-------------------------*/
signed main(){
  int X,N;cin>>X>>N;
  vi P(N);rep(i,N)cin>>P[i];
  sort(all(P));
  int i=X;
  int j=X;
  while(true){
    if(!binary_search(all(P),i)&&binary_search(all(P),j)){
      cout<<i<<endl;
      break;
    }
    else if(!binary_search(all(P),j)){
      cout<<j<<endl;
      break;
    }
    i++;
    j--;
  }
}


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

int main() {
  string s;
  cin >> s;
  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
    cout << "Bad" << endl;
  }
  else{
    cout << "Good" << endl;
  }

}


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

const int maxn = 200010;
int A[maxn],B[maxn],P[maxn],N;

inline int gi()
{
	char ch; int ret = 0,f = 1;
	do ch = getchar(); while (!(ch >= '0'&&ch <= '9')&&ch != '-');
	if (ch == '-') f = -1,ch = getchar();
	do ret = ret*10+ch-'0',ch = getchar(); while (ch >= '0'&&ch <= '9');
	return ret*f;
}

int main()
{
	//freopen("E.in","r",stdin);
	//freopen("E.out","w",stdout);
	N = gi();
	for (int i = 1;i <= N;++i) P[i] = gi();
	for (int i = 1;i <= N;++i) A[i] = i*20001;
	for (int i = 1;i <= N;++i) B[i] = (N-i+1)*20001;
	for (int i = 1;i <= N;++i) A[P[i]] += i;
	for (int i = 1;i < N;++i) printf("%d ",A[i]); printf("%d\n",A[N]);
	for (int i = 1;i < N;++i) printf("%d ",B[i]); printf("%d\n",B[N]);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

vector<lol> anss(10, 0);

void bfs(lol n)
{
    queue<lol> a;
    REP(i, 9)
        a.push(i+1);
    lol nown = 9;
    while(nown <= n)
    {
        //cout << "*";
        lol now = a.front(); a.pop();
        string s = to_string(now);
        char ch = s[s.length()-1];
        lol chn = (lol)ch - (lol)'0';
        if(chn > 0)
        {
            string s1 = s + to_string(chn-1);
            nown++;
            anss.push_back(stoll(s1));
            a.push(stoll(s1));
        }
        string s2 = s + to_string(chn);
        nown++;
        anss.push_back(stoll(s2));
        a.push(stoll(s2));
        if(chn < 9)
        {
            string s3 = s + to_string(chn+1);
            nown++;
            anss.push_back(stoll(s3));
            a.push(stoll(s3));
        }
        if(nown > n)
            break;
    }
}

int main()
{
    lol result{0};
    lol n; cin >> n;
    REP(i, 9)
    {
        anss[i+1] = i + 1;
    }
    if(n <= 9)
        result = n;
    else
    {
        //cout << "あ" << endl;
        bfs(n);
        result = anss[n];
    }
    /*REP(i, n)
    {
        cout << anss[i+1] << " ";
    }
    cout << endl;*/
    

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 5040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(int argc, char** argv){
	char s[3],t[3];
	cin >> s;
	cin >> t;
	int r = 0;
	for(int i = 0; i < 3; i++){
		if(s[i] == t[i]){
			r++;
		}
	}

	cout << r << endl;
	return 0;
}


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

#define int long long

using namespace std;

const int N = 1e5 + 123;
int n, a[N], pr[N], ans;

main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	for(int i = n; i >= 1; i--){
		pr[i] = pr[i + 1] + a[i];
	}
	ans = 1;
	for(int i = 1; i <= ans; i++){
		int s = a[i];
		int l = i, r = n;
		while(l <= r){
			int mid = (l + r) / 2;
			if(pr[mid] * 2 >= s){
				ans = mid;
				l = mid + 1;
			}
			else{
				r = mid - 1;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 1792
import itertools

def main():
    n = int(input())
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))

    l = range(1,n+1)
    for i, v in enumerate(itertools.permutations(l, n)):
        if v == tuple(P):
            p_index = i
        if v == tuple(Q):
            q_index = i
    print(abs(p_index-q_index))

if __name__ == '__main__':
    main()


Measured memory_bytes: 41180
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define mkp make_pair
#define p_q priority_queue
#define INF 200000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, Q, a, b, p, x; cin >> N >> Q;
  vector<int> G[200000];
  REP(i, N-1){
    cin >> a >> b;
    a--; b--;
    G[a].pb(b); G[b].pb(a);
  }
  vector<int> ans(N, 0);
  REP(i, Q){
    cin >> p >> x;
    ans[p-1] += x;
  }
  queue<int> que; que.push(0);
  bool visit[200000] = {}; visit[0] = 1;
  while(!que.empty()){
    int pos = que.front(); que.pop();
    REP(i, G[pos].size()){
      int nx = G[pos][i];
      if(!visit[nx]){
        visit[nx] = 1;
        ans[nx] += ans[pos];
        que.push(nx);
      }
    }
  }
  REP(i, N) cout << ans[i] << ' ';
  cout << endl;
}

Measured memory_bytes: 18160
//
// Created by Chmie on 2020/1/31.
//

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    long long as=a.size();
    cout<<a[0];
    cout<<as-2;
    cout<<a[as-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
s = gets.chomp!

until s == "" do
    l = s.length - 1
    if s[l-4..l] == "dream" then
        s.slice!(l-4..l)
    elsif s[l-6..l] == "dreamer"
        s.slice!(l-6..l)
    elsif s[l-4..l] == "erase"
        s.slice!(l-4..l)
    elsif s[l-5..l] == "eraser"
        s.slice!(l-5..l)
    else
        puts "NO"
        exit
    end
end

puts "YES"

Measured memory_bytes: 1916
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int H, W, K; cin >> H >> W >> K;
	VS S(H);
	REP(i, H)cin >> S[i];

	
	int ans = LLINF;

	REP(i, 1 << (H - 1)) {
		int sum = 0;
		int cnt[10] = { 0 };
		int j = 0;
		int k = 0;
		int l = 0;
		int b = 0;

		while (j < W) {
			
			if (S[l][j] == '1')cnt[k]++;

			if (cnt[k] > K) {
				if (b == j) {
					sum += INF;
					break;
				}
				REP(q, 10)cnt[q] = 0;
				sum++;
				l = 0;
				b = j;
				k = 0;
				continue;
			}

			if (l != H - 1 && (i&(1 << l)))k++;
			l++;
			if (l == H) {
				l = 0;
				k = 0;
				j++;
			}
		}
		


		int tmp = i;
		while (tmp) {
			sum += tmp % 2;
			tmp /= 2;
		}


		chmin(ans, sum);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;

int N, M;
Graph G;
int u[50], v[50];

bool f(int idx, int par, int target, int& path) {
    if (idx == target) {
        return true;
    }
    for (auto& e : G[idx]) {
        if (e.first == par)
            continue;
        if (f(e.first, idx, target, path)) {
            path |= (1LL << e.second);
            return true;
        }
    }
    return false;
}
int path[55];


void solve() {
    FOR(M)
    f(v[i], -1, u[i], path[i]);
    int ans = 0;
    FOR(bit, 1 << M) {
        int val = 0;
        FOR(M) {
            if (bit & (1 << i))
                val |= path[i];
        }
        int tmp = (1LL << (N - 1 - __builtin_popcountl(val)));
        if (__builtin_popcountl(bit) % 2 == 1)
            tmp *= -1;
        ans += tmp;
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    G.resize(N);
    FOR(N - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b, i);
        G[b].emplace_back(a, i);
    }
    cin >> M;
    FOR(M) {
        cin >> u[i] >> v[i];
        u[i]--;
        v[i]--;
    }


    solve();
    return 0;
}


Measured memory_bytes: 384
// i wanna find something i wanted all along
// somewhere i belong

#include <bits/stdc++.h>
#include <vector>

#define s second
#define f first
#define pb push_back
#define int ll

using namespace std;

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

const long long MAX=1e5+10,INF=1e5+7,mod=1e9+7,sq=320;

int n,m,t,q,W,w[MAX],dp[110][MAX],val[MAX];
//string s;
//set<int>st;
//bool mark[MAX];
//int dx[2]={0,1};
//int dy[2]={1,0};
//pii p[MAX];
//vector <int> v1,v2;
//multiset <int> st;
//queue <pii> q;
//map<pii,int> dp;
//map <pii,bool> mark;
//deque <int> dq;

void update_dp()
{
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=W;j++)
        {
            if(j-w[i-1]<0)
            {
                dp[i][j]=dp[i-1][j];
                continue;
            }
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+val[i-1]);
        }
    }
}
main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> W;
    for(int i=0;i<n;i++)
    {
        cin >> w[i] >> val[i];
    }
    update_dp();
    cout << dp[n][W];
    return -0;
}


Measured memory_bytes: 78592
N = int(input())
A = [int(i) for i in input().split()]

counter = 0
flag = 1  #????????£??\????´?????????¨??????
while flag:
    flag = 0
    for j in range(N-1, 0, -1):
        if A[j] < A[j-1]:
            v = A[j]
            A[j] = A[j-1]
            A[j-1] = v
            flag = 1
            counter += 1

print(' '.join([str(A[i]) for i in range(0, N)]))
print(counter)

Measured memory_bytes: 7680
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

N = int(input())
xs, ys = [], []
for _ in range(N):
    x, y = map(int, input().split())
    x2 = x+y
    y2 = x-y
    xs.append(x2)
    ys.append(y2)

#for i in range(N):
#    print(pts[i])

minX, maxX = min(xs), max(xs)
minY, maxY = min(ys), max(ys)
#print('# minX:', minX, '/ maxX:', maxX, file=sys.stderr)
#print('# minY:', minY, '/ maxY:', maxY, file=sys.stderr)

ans = 0
for x, y in zip(xs, ys):
    cs = [abs(x-minX), abs(x-maxX), abs(y-minY), abs(y-maxY)]
    m = max(cs)
    if m > ans:
        ans = m

print(ans)


Measured memory_bytes: 24752
// --------------
// Tejas Pandey  |
// 13 - 06 - 20  |
// ATcoder RC    |
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll a,b,v,w,t;
  cin >> a >> v >> b >> w >> t;
  if(w >= v) cout << "NO\n";
  else{
	ll df = abs(a-b),dv = v - w;
	if(dv*t >= df) cout << "YES\n";
	else cout << "NO\n";
  }
  return 0;
}


Measured memory_bytes: 3652
A, B, C, D = list(input())
op = {'+': 1, '-': -1}
for op1 in op:
    for op2 in op:
        for op3 in op:
            tmp = A + op1 + B + op2 + C + op3 + D
            if eval(tmp) == 7:
                print(tmp + '=7')
                exit()


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

using namespace std;

int x[10];

int main()
{
	scanf("%d%d%d", &x[1], &x[2], &x[3]);
	sort(x + 1, x + 4);
	printf("%d\n", x[1] + x[2]);
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include<string>
#include <numeric>
using namespace std;
int a[114514];
int b[114514];
#define rep(i,n) for(long long i=0;i<n;i++)
int main() {
	long long n, m;
	cin >> n >> m;
	long long iwa = 0;
	long long ta = 0;
	rep(i, n) { cin >> a[i]; iwa += a[i]; }
	rep(i, m) { cin >> b[i]; ta += b[i]; }
	cout << iwa * ta << endl;
}




Measured memory_bytes: 3880
#include<stdio.h>

int main(){

int x,y,s;
while(1){

scanf("%d%d%d",&x,&y,&s);if(x==0&&y==0&&s==0)break;
int max=0;
int ng=0,mg=0;int n=0,m=0;
int X=100+x,Y=100+y;
for(int i=1;i<s;i++){
ng=i*X/100;n=i*Y/100;
for(int j=1;j<=s-i;j++)
{
mg=j*X/100;m=j*Y/100;
if(ng+mg==s&&n+m>max)max=n+m;
}
}
printf("%d\n",max);
}
return 0;
}

Measured memory_bytes: 1028
from itertools import groupby

n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())

point = 0

for i in range(k):
    li = ["x"]+t[i::k]
    for j in range(1,len(li)):
        if li[j-1] == li[j]:
            li[j] = "x"
            continue
        if li[j] == "r":
            point += p
        elif li[j] == "s":
            point += r
        else:
            point += s
    
print(point)

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

int main()
{
  int n;
  long long a,b,x,y,tmp;

  x=y=1;
  scanf("%d",&n);
  while(n--)
  {
    scanf("%lld%lld",&a,&b);
    if (a>=x&&b>=y)x=a,y=b;
    else
    {
      tmp=std::max((x+a-1)/a,(y+b-1)/b);
      x=a*tmp,y=b*tmp;
    }
  }
  printf("%lld\n",x+y);
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// Did you miss me ?

# define gc          getchar
# define LL          long long
# define pb          push_back
# define mp          make_pair
# define vi          vector<int>
# define vll         vector<LL>
# define pii         pair<int,int>
# define all(v)      v.begin(),v.end()

const int MOD = 1000000007;
const int MAXN = 1e5 + 5;
const int INF = 1e9;
const int LN = 18;
const double PI = 3.14159265359;

template<class T> void in(T &x) { register T c=gc();x=0;T neg=0;for(;((c<48||c>57)&&c!='-');c=gc());if(c=='-'){neg=1;c=gc();}for(;c>47&&c<58;c=gc()){x=(x<<1)+(x<<3)+c-48;}if(neg)x=-x;}
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
LL power(LL a,LL b,LL m){ if(b==0) return 1; if(b==1) return a%m; LL t=power(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}
LL lcm(LL a, LL b) { LL ret = a*b; ret /= __gcd(a,b); return ret;}
LL nC2(LL n) {LL ret = n*(n-1)/2; return ret;}

vector<int> primes;
void sieve(int n)
{
	bool isPrime[n + 1];
	memset(isPrime, true, sizeof(isPrime));
	isPrime[0] = isPrime[1] = false;
	for(int i = 2; i * i <= n; i++) {
		if (isPrime[i]) {
			for (int j = 2 * i; j <= n; j += i)
			 	isPrime[j] = false;
		}
	}
	for (int i = 2; i <= n; i++)
		if (isPrime[i])
			primes.push_back(i);
}

int main() {
    int n;
    LL k;
    cin>>n>>k;
    LL a[n];
    LL g=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        g=__gcd(g,a[i]);
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]==k)
        {
            cout<<"POSSIBLE";
            return 0;
        }
        if(a[i]>k)
        {
            LL diff=a[i]-k;
            if(diff%g==0)
            {
                cout<<"POSSIBLE";
                return 0;
            }
        }
    }
    cout<<"IMPOSSIBLE";
	return 0;
}


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

int main(void){
    int num=0;
    scanf("%d",&num);

    int nums[num];
    int max=-1000000;
    int min=1000000;
    long long int sum=0;

    for(int h=0;h<num;h++){
        scanf("%d",&nums[h]);
    }

    for(int i=0;i<num;i++){
        if(nums[i]>max){
            max=nums[i];
        }
        if(nums[i]<min){
            min=nums[i];
        }
        sum=sum+nums[i];
    }

    printf("%d %d %lld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 1952
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
class bipartite_matching {
public:
    int n;
    std::vector<std::vector<int>> g;
    std::vector<int> match;

    bipartite_matching(int n_) : n(n_*2), g(n_*2), match(n_*2), used(n_*2) {}

    void add_edge(int u, int v) {
        g[u].push_back(v);
        g[v].push_back(u);
    }

    ll maximum_matching(void) {
        int res = 0;
        fill(begin(match), end(match), -1);
        for (int v = 0; v < n; ++v) {
            if (match[v] == -1) {
                fill(begin(used), end(used), false);
                if (dfs(v)) res++;
            }
        }
        return res;
    }

private:
    std::vector<int> used;
    bool dfs(int v) {
        used[v] = true;
        for (int u : g[v]) {
            int w = match[u];
            if (w == -1 || (!used[w] && dfs(w))) {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }
};
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
ll n,i;
  cin>>n;
  bipartite_matching vec(n);
  std::vector<P> v(n),w(n);
  rep(i,n){
    ll a,b;
    // cin>>a>>b;
    cin>>v[i].fi>>v[i].se;
  }
  rep(i,n){
    ll a,b;
    // cin>>a>>b;
    cin>>w[i].fi>>w[i].se;
  }
  rep(i,n)rep(j,n){
    if(v[i].fi<w[j].fi&&v[i].se<w[j].se) vec.add_edge(i,j+n);
  }
  cout<<vec.maximum_matching()<<endl;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

double dp[301][301][301];
bool done[301][301][301];
int n, a;
int cnt[4];

double solve(int i, int j, int k){
  if(done[i][j][k])return dp[i][j][k];
  done[i][j][k] = true;
  double &res = dp[i][j][k];
  double p = 1. * (i+j+k) / n;
  if(i){
    double p0 = 1. * i / n;
    res += (solve(i-1, j, k) + 1 / p)* i / (i+j+k);
  }
  
  if(j){
    double p0 = 1. * j / n;
    res += (solve(i+1, j-1, k) + 1 / p) * j / (i+j+k);
  }
  
  if(k){
    double p0 = 1. * k / n;
    res += (solve(i, j+1, k-1) + 1 / p) * k / (i+j+k);
  }
  //  cout << i << " " << j <<" " << k <<" " << res << endl;
  return res;
}
int main(){
  done[0][0][0] = true;
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> a;cnt[a]++;
  }
  for(int k = 0;k <= n;k++){
    for(int j = 0;j <= n;j++){
      for(int i = 0;i <= n;i++){
	if(i + j + k > n)continue;

      }
    }
  }

  printf("%.10lf\n",  solve(cnt[1],cnt[2],cnt[3]));
  return 0;
}

Measured memory_bytes: 239872
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;

int N,M;
vector<int> G[100001];
int n[100001];
int main(){
	cin >> N >> M;
	for(int i=0;i<M;i++){
		int x,y;
		cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);		
	}
	for(int i=1;i<=N;i++)n[i] = -1;
	n[1] = 0;
	queue<int> q;
	q.push(1);
	while(q.size()){
		int x = q.front();
		q.pop();
		for(int i=0;i<G[x].size();i++){
			int u = G[x][i];
			if(n[u] != -1)continue;
			n[u] = x;
			q.push(u);
		}
	}
	for(int i=1;i<=N;i++)if(n[i] == -1){cout << "No" << endl; return 0;}
	cout << "Yes" << endl;
	for(int i=2;i<=N;i++)cout << n[i] << endl;
	return 0;	
}



Measured memory_bytes: 10404
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mset(m,v) memset(m,v,sizeof(m))
#define pr(a,s) printf("Case #%lld: %lld\n",a,s)
#define mod 1000000007
#define mp make_pair
#define all(a)                a.begin(),a.end()
#define pb push_back
#define scan(a) scanf("%d",&a)
#define scanl(a) scanf("%lld",&a)
#define se second
#define fi first
#define pi 3.14159265358979323
#define pii pair<ll,ll>
 
const ll inf = 1e15;
const int MAXM = 1e2+4;
const int MAXN = 1e5+1;

int arr[MAXM], dp[MAXN];

int main()
{
	int n,k;
	cin>>n>>k;
	for (int i=1;i<=n;i++) {
		cin>>arr[i];
	}	
	for (int i=1;i<=k;i++) {
		for (int j=1;j<=n;j++) {
			if (i >= arr[j] and dp[i-arr[j]] == 0) {
				dp[i] = 1;
				break;
			}
		}
	}
	if (dp[k] == 1) {
		cout << "First\n";
	} else {
		cout << "Second\n";
	}
}

Measured memory_bytes: 640