akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

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;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e16;

void solve() {
	int N; cin >> N;
	string S; cin >> S;
	string T = S.substr(0, N / 2);
	if (S == T + T) {
		print("Yes");
	}
	else print("No");
}

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

	solve();

}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int x, n, m, s, ss, sum;
	cin >> x;
	n = (x - (x % 500)) / 500;
	s = n * 1000;
	x = x % 500;
	m = (x - (x % 5)) / 5;
	ss = m * 5;
	sum = s + ss;
	cout << sum;
	return 0;
}

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

	int a,b,c,d;

	cin>>a>>b>>c>>d;

	int l = a + b;

	int r = c + d;

	if( l > r )
		cout<<"Left";
	else if ( l == r )
		cout<<"Balanced";
	else if ( l < r )
		cout<<"Right";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

struct point {
	double x;
	double y;
};

int main() {
	point p1, p2;

	cin >> p1.x >> p1.y >> p2.x >> p2.y;

	double distance = sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y)*(p1.y - p2.y));

	printf("%.6f\n", distance);

	return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define sll            set<ll int>
#define msll        multiset<ll int>
#define io    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;


int main()
{
    io
    ll i,j,a;
    string s;
    cin>>a>>s;
    if(a>=3200) cout<<s;
    else cout<<"red";




    return 0;
}

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

using namespace std;

typedef pair<int, int> P;
bool used[250000];

int main(){
    int N;
    int ans[250000];
    P x[500];
    cin >> N;
    
    for(int i = 0; i < N; i++) {
        cin >> x[i].first;
        x[i].first--;
        x[i].second = i+1;
        used[x[i].first] = true;
        ans[x[i].first] = i+1;
    }
    sort(x, x+N);
    int idx = 0;
    for(int i = 0; i < N; i++){
        //cout << x[i].first << ' ' << x[i].second << endl;
        int n = x[i].second;
        int cnt = 0;
        while(cnt < n-1){
            if(idx > x[i].first){
                cout << "No" << endl;
                return 0;
            }
            if(!used[idx]) {
                cnt++;
                ans[idx] = n;
            }
            idx++;
        }
    }
    idx = N*N-1;
    for(int i = N-1; i >= 0; i--){
        //cout << x[i].first << ' ' << x[i].second << endl;
        int n = N-x[i].second;
        //cout << n << endl;
        int cnt = 0;
        while(cnt < n){
            if(idx < x[i].first){
                cout << "No" << endl;
                return 0;
            }
            if(!used[idx]) {
                cnt++;
                ans[idx] = x[i].second;
            }
            idx--;
        }
    }
    cout << "Yes" << endl;
    for(int i = 0; i < N*N; i++){
        cout << ans[i];
        if(i < N*N-1) cout << ' ';
        else cout << '\n';
    }
}

Measured memory_bytes: 2304
import math

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())

ans = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      ans += math.gcd(math.gcd(a, b), c)

print(ans)

Measured memory_bytes: 67808
#include<cstdio>
#include<map>
using namespace std;

int h[105], h_max;
int c[105][105];
int main() {
    int n;

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &h[i]);
        h_max = max(h_max, h[i]);
        for (int j = 0; j < h[i]; j++) c[i][j] = 1;
    }

    int ans = 0;
    for (int j = 0; j < h_max; j++) {
        int f = 0;
        for (int i = 0; i < n; i++) {
            if (f == 0) {
                if (c[i][j] == 1) {
                    f = 1;
                    ans++;
                }
            } else {
                if (c[i][j] == 0) f = 0;
            }
        }
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;
long long p=1;
int main() {
    long long a,b,c,d;
    cin>>a>>b>>c;
    d=a-b;
  if(c-d<0) cout<<0;
  else		cout<<c-d;
  //  cout<<max(0,c-d);
    
    
}

Measured memory_bytes: 256
H,W = map(int,input().split())
C = [0]*10
for i in range(10):
    C[i] = list(map(int,input().split()))
A = [0]*H
for i in range(H):
    A[i] = list(map(int,input().split()))
for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j],C[i][k]+C[k][j])
Ans = 0
for i in range(H):
    B = A[i]
    for b in B:
        if b > -1:
            Ans += C[b][1]
print(Ans)

Measured memory_bytes: 3444
#include "bits/stdc++.h"

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

int n,p[11],mx,it,ans;

void input(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>p[i];
		if(mx<p[i])mx=p[i],it=i;
	}
	return;
}

void solve(){
	for(int i=0;i<n;i++){
		if(it==i)ans+=p[i]/2;
		else ans+=p[i];
	}
	cout<<ans<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll k;
    string s;
    cin >> s >> k;
    if (k == 1){
        cout << s[0] << endl;
        return 0;
    }
    int i = 0;
    while (i < k && i < s.size() && s[i] == '1') ++i;
    if (i >= k || i == s.size()) --i;
    cout << s[i] << endl;
    return 0;
}


Measured memory_bytes: 256
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define vi vector<ll>
#define pii pair<ll,ll>
#define bc __builtin_popcountll
#define vvi vector<vi> 
#define vpii vector<pair<ll,ll>>
#define mll unordered_map<ll,ll>
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define fo(i,a,b) for(i=a;i<=b;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()-->returns an iterator to the k-th largest element (counting from zero)
//X.order_of_key()-->the number of items in a set that are strictly smaller than our item.
struct cmp
{
	bool operator() (ll a,ll b){
		return (a>b);
	}
};
ll mod=1000000007;
const ll N=100005;
int main()
{
fast;
    ll n;
    cin>>n;
    set<pair<ll,ll>>s;
    ll ma1=0,ma2=0,mi1=INT_MAX,mi2=INT_MAX;
    f(i,n)
    {
        ll x,y;
        cin>>x>>y;
        s.insert({x,y});
        ma1=max(ma1,x+y);
        ma2=max(ma2,x-y);
        mi1=min(mi1,x+y);
        mi2=min(mi2,x-y);
    }
    if(s.size()==1)
        cout<<0;
    else
        cout<<max(ma1-mi1,ma2-mi2);
    return 0;
}

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

#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repd(i,a,b) for(int i=(a);i>=(b);--i)
#define repit(i,a) for(__typeof((a).begin()) i=(a).begin();i!=(a).end();++i)

#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())

#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

bool num[128][256];
int m, n;
map<string,pair<int,int> > bound;
string op = "+-*/";

int main()
{
    memset(num,0,sizeof(num));
    cin >> m;
    rep(i,m){
	string name;
	int lb, ub;
	cin >> name >> lb >> ub;
	bound[name] = mp(lb,ub);
    }    
    cin >> n;
    stack<int> st;
    rep(i,n){
	string e;
	cin >> e;
	if(op.find(e) == string::npos){
	    if(bound.find(e) != bound.end())
		for(int j = bound[e].first; j <= bound[e].second; j++)
		    num[i][j] = true;
	    else
		num[i][atoi(e.c_str()) & 255] = true;
	}else{
	    int b = st.top(); st.pop();
	    int a = st.top(); st.pop();
	    if(e == "+"){
		rep(j,256)rep(k,256){
		    num[i][(j + k) % 256] |= num[a][j] & num[b][k];
		}
	    }
	    if(e == "-"){
		rep(j,256)rep(k,256){
		    num[i][(j - k + 256) % 256] |= num[a][j] & num[b][k];
		}
	    }
	    if(e == "*"){
		rep(j,256)rep(k,256){
		    num[i][(j * k) % 256] |= num[a][j] & num[b][k];
		}
	    }
	    if(e == "/"){
		if(num[b][0]) {
		    cout << "error\n";
		    return 0;
		}
		rep(j,256)repi(k,1,256){
		    num[i][(j / k) % 256] |= num[a][j] & num[b][k];
		}
	    }
	}
	st.push(i);
    }
    cout << "correct\n";
    return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define pii pair<int, int>
#define ll long long
#define ff first
#define ss second
#define mp make_pair

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define MOD 1000000007LL
#define N 200005

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

    string s;
    cin>>s;
    int cnt = 0;
    for(auto c : s){
        if(c == 'x') cnt++;
    }
    if(cnt > 7) cout<<"NO";
    else cout<<"YES";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<=n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define sec setprecision
#define Pair pair<ll,ll>
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2) % mod);
	else
		return (x * pow(x, n - 1)) % mod;
}
int main() {
	int n; cin >> n;
	vector<string>a(n);
	rip(i, n)cin >> a[i];
	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;
	rip(i, n) {
		if (a[i] == "AC")ac++;
		if (a[i] == "WA")wa++;
		if (a[i] == "TLE")tle++;
		if (a[i] == "RE")re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
}


Measured memory_bytes: 6336
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


s64 gcd(s64 x, s64 y)
{
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gcd(y, x % y);
}

s64 cmul(s64 x, s64 y)
{
    s64 g = gcd(x, y);
    return x * y / g;
}

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

    s64 N, M;
    cin >> N >> M;

    vs64 A(N);
    s64 g = 0;
    rep (i, N)
    {
        cin >> A[i];
        A[i] /= 2;
        g = gcd(A[i], g);
    }

    sort(A.begin(), A.end());
    A.erase(unique(A.begin(), A.end()), A.end());
    s64 d = 1;
    rep (i, A.size())
    {
        d = cmul(d, A[i]);
        if (d > M) break;
        if ((A[i] / g) % (s64)2 == 0)
        {
            d = M + 1;
            break;
        }
    }

    s64 ans = (M + d) / ((s64)2 * d);

    cout << ans << "\n";
    return 0;
}



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


int main()
{
    cin.sync_with_stdio(0);

    string S, T;
    cin >> S >> T;

    int res = 0;
    for (int i = 0; i < S.size(); ++i)
    {
        if (S[i] != T[i])
        {
            ++res;
        }
    }

    cout << res;
}

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

int main()
{
  string s;
  cin >> s;
  string t = "Yes";
  int c = 0;
  rep(i,s.size()){
    if(i % 2){
      if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D') t = c++;
    }
    else{
      if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D') t = c++;
    }
  }
      
  cout << (c == s.size() ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

ll a[26], b[26];

int main() {
    string s;
    ll size;
    cin >> size;
    cin >> s;
    ll max_ = 0;
    for (int i = 0; i < size; i++) {
        b[s[i] - 'a']++;
    }
    for (int i = 0; i < size; i++) {
        ll cur = 0;
        a[s[i] - 'a']++;
        b[s[i] - 'a']--;
        for (int j = 0; j < 26; j++) {
            if (b[j] && a[j]) cur++;
        }
        if (cur > max_) max_ = cur;
    }
    cout << max_ << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const ll N=400000;
ll tree[N*4],arr[N];
void update(ll ind,ll lef,ll right,ll i,ll val)
{
   if(i>right||i<lef)
    return;
   if(i==lef&&i==right)
   {
       tree[ind]=val;
       return;
   }

   ll mid=(lef+right)>>1;
   update(ind<<1,lef,mid,i,val);
   update(ind<<1|1,mid+1,right,i,val);
   tree[ind]=max(tree[ind<<1],tree[ind<<1|1]);
}
ll query(ll ind,ll lef,ll right,ll i,ll j)
{
    if(i>right||j<lef)
      return 0;
   if(i<=lef&&j>=right)
   {
       return tree[ind];
   }
   ll mid=(lef+right)>>1;

   return max(query(ind<<1,lef,mid,i,j),query(ind<<1|1,mid+1,right,i,j));
}
int main()
{

    ll i,j,k,n;
    scanf("%lld%lld",&n,&k);
    for(i=0;i<n;i++)
        scanf("%lld",&arr[i]);

   for(i=n-1;i>=0;i--)
   {
        ll current=query(1LL,0LL,300000LL,max(0LL,arr[i]-k),min(arr[i]+k,300000LL));
        update(1LL,0LL,300000LL,arr[i],current+1);
   }

    printf("%lld",tree[1]);


return 0;
}












































Measured memory_bytes: 14288
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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 countbits(long long bits)
{
    bits = (bits & 0x5555555555555555) + ((bits >> 1) & 0x5555555555555555);
    bits = (bits & 0x3333333333333333) + ((bits >> 2) & 0x3333333333333333);
    bits = (bits & 0x0f0f0f0f0f0f0f0f) + ((bits >> 4) & 0x0f0f0f0f0f0f0f0f);
    bits = (bits & 0x00ff00ff00ff00ff) + ((bits >> 8) & 0x00ff00ff00ff00ff);
    bits = (bits & 0x0000ffff0000ffff) + ((bits >>16) & 0x0000ffff0000ffff);
    return (bits & 0x00000000ffffffff) + ((bits >>32) & 0x00000000ffffffff);
}

bool dfs(VVI &es, LL &bs, map<PII,int> &ma, int pos, int t, int par = -1) {
    if (pos == t) {
        return true;
    }
    for (int dst: es[pos]) {
        if (dst == par) continue;
        if (dfs(es,bs,ma,dst,t,pos)) {
            bs |= (1LL<<(ma[MP(pos,dst)]));
            return true;
        }
    }
    return false;
}

void solve() {
    int n,m,a,b;
    cin >> n;
    VVI es(n);
    map<PII,int> ma;
    REP(i,0,n-1) {
        cin >> a >> b;
        --a; --b;
        es[a].push_back(b);
        es[b].push_back(a);
        ma[MP(a,b)] = i;
        ma[MP(b,a)] = i;
    }

    cin >> m;
    VLL bs(m);
    REP(i,0,m) {
        cin >> a >> b;
        --a; --b;
        dfs(es,bs[i],ma,a,b);
    }

    LL ans = 0;
    REP(p,0,1<<m) {
        int b = countbits(p);
        // int pm = (b % 2 == 0) ? 1 : -1;
        LL bp = 0;
        REP(i,0,m) {
            if (!(p & (1<<i))) continue;
            bp = bp | bs[i];
        }
        LL cnt = (1LL << (n-1-countbits(bp)));
        // ans += cnt * pm;
        if (b % 2 == 0) ans += cnt;
        else ans -= cnt;
    }
    cout << ans << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
 
typedef long long ll;

#define rep(i,n) for(ll i = 0; i < n; i++)
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;
vector<int> dp(70000,1e+9);

int main(){
  int n,m,c[30]={};
  cin >> n >> m;
  rep(i,m) cin >> c[i];
  dp[0] = 0;
  
  rep(i,50010){
    rep(j,m){
      dp[i+c[j]] = min(dp[i+c[j]], dp[i]+1);
    }
  }
  cout << dp[n] << endl;
}



Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    string s;
    cin >> s;
    int N = (int)s.size();
    bool is = true;
    rep(i, N){
        if(i % 2 == 0){
            if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D') is = false;
            else continue;
        }else if(i % 2 == 1){
            if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D') is = false;
            else continue;
        }
    }
    if(is) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
x, y = map(int, input().split(" "))

#print(x, y)
leg_turtle = 4
leg_clane = 2

if y > x * leg_turtle:
    print("No")
    exit()
elif y < leg_clane * x:
    print("No")
    exit()


for i in range(x + 1):
    clane = i
    turtle = x - i
    #print(clane, turtle)

    legs = 2 * clane + 4 * turtle

    if legs == y:
        print("Yes")
        exit()
    else:
        continue
print("No")

Measured memory_bytes: 9180
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

const ll MOD = 1e9+7;
const ll INF = 1e18+7;

signed main(){

	int n;
	cin >> n;
	vector<vector<int>> a(2, vector<int>(n));
	for(auto& x : a)
		for(auto& y : x)
			cin >> y;

	for(int i = 1; i < n; ++i)
		a[0][i] += a[0][i - 1];
	for(int i = n - 2; i >= 0; --i)
		a[1][i] += a[1][i + 1];

	int ans = 0;
	for(int i = 0; i < n; ++i){
		ans = max(ans, a[0][i] + a[1][i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    uint64_t ans=1;
    rep(n,1,N+1) ans=(n*ans)%MOD;

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    while(1){
 int n,m,i,j,k;
 scanf("%d",&m);
 if(m==0){
     break;
 }
 int ax[m],ay[m];
 for(i=0;i<m;i++){
     scanf("%d%d",&ax[i],&ay[i]);
 }
 scanf("%d",&n);
 int bx[n],by[n];
 for(i=0;i<n;i++){
     scanf("%d%d",&bx[i],&by[i]);
 }
    for(i=0;i<m;i++){
      for(j=m-1;j>i;j--){
           if(ax[j]<ax[j-1]||(ax[j]==ax[j-1]&&ay[j]<ay[j-1])){
              int v,w;
              v=ax[j];
              w=ay[j];
              ax[j]=ax[j-1];
              ay[j]=ay[j-1];
              ax[j-1]=v;
              ay[j-1]=w;
          }
      }
    }
    for(i=0;i<n;i++){
      for(j=n-1;j>i;j--){
          if(bx[j]<bx[j-1]||(bx[j]==bx[j-1]&&by[j]<by[j-1])){
              int v,w;
              v=bx[j];
              w=by[j];
              bx[j]=bx[j-1];
              by[j]=by[j-1];
              bx[j-1]=v;
              by[j-1]=w;
          }
      }
    }
    
    for(i=0;i<=n-m;i++){
        int x=bx[i]-ax[0],y=by[i]-ay[0];
        
        for(j=1,k=i+1;j<m&&k<n-m+j+1;k++){
            if(ax[j]+x==bx[k]&&ay[j]+y==by[k]){
                j++;
            }
        }
        if(j==m){
            printf("%d %d\n",x,y);
            break;
        }
        
    }
    }
    
}

Measured memory_bytes: 2600
#include<bits/stdc++.h>
using namespace std;
const int M = 2e3 + 5;
struct node{
	double x,y;
};
double ans[10][10];
node g[10];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		double a,b;
		scanf("%lf%lf",&g[i].x,&g[i].y);
		for(int j=1;j<=i;j++){
			ans[i][j]=sqrt((g[i].x-g[j].x)*(g[i].x-g[j].x)+(g[i].y-g[j].y)*(g[i].y-g[j].y));
			ans[j][i]=ans[i][j]; 
		}
	}
	double sum=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			sum+=ans[i][j];
		}
	}
	double chu=1;
	for(int i=1;i<n;i++) chu*=i;
	printf("%.10lf",sum*1.0/n);
	return 0;
}

Measured memory_bytes: 256
var f = [];
 
function main(){
  for(var y=-2;y<12;y++){
    f[y] = [];
    for(var x=-2;x<12;x++){
      f[y][x] = 0;// initialize:undefined -> 0
    }
  }
 
   
  for(var i=0,len=input.length - 1;i<len;i++){
    var s = input[i].split(',');
    eval("d"+s[2]+"("+s[0]+","+s[1]+");");
  }
 
  var nd=0;//not dropped
  var md=0;//most dropped
  for(var y=0;y<10;y++){
    for(var x=0;x<10;x++){
      nd += !(f[y][x]);
      md = mx(f[y][x], md);
    }
  }
 
  console.log(nd);
  console.log(md);
}
 
function d1(x, y){
  f[y+1][x]++;
  f[y][x-1]++;
  f[y][x]++;
  f[y][x+1]++;
  f[y-1][x]++;
}
 
function d2(x, y){
  d1(x, y);
  f[y+1][x-1]++;
  f[y+1][x+1]++;
  f[y-1][x-1]++;
  f[y-1][x+1]++;
}
 
function d3(x, y){
  d2(x, y);
  f[y+2][x]++;
  f[y-2][x]++;
  f[y][x-2]++;
  f[y][x+2]++;
}

function mx(a, b){
 var t = (a-b);
 return a - (t & (t >> 31));
}
 
var
input = '';
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 7648
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define int long long
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define copy(a, b) memcpy(b,a,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define rep1(i, n) for(int i=1;i<=(int)n;++i)
#define per1(i, n) for(int i=(int)n;i>=1;--i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef string str;
typedef long double db;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<db> vdb;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 1e18;
const db EPS = 1e-15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 7;

int k, n;
int a[N];

int32_t main() {
  FAST_IO;
  cin >> k >> n;
  rep(i, n)
    cin >> a[i];
  vi b;
  rep(i, n - 1) {
    b.pb(a[i + 1] - a[i]);
  }
  b.pb(a[0] + k - a[n - 1]);
  sort(all(b));
  int ans = 0;
  rep(i, n - 1) {
    ans += b[i];
  }
  cout << ans;
  rtn 0;
}


Measured memory_bytes: 3956
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

signed main() {
	int H, W, N;
	cin >> H >> W >> N;

	vector<int> ret(10, 0);
	ret[0] = (H - 2) * (W - 2);

	set< pair<int, int> > p;
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		a--; b--;

		bool ar[5][5];
		memset(ar, false, sizeof(ar));
		for (int y = 0; y < 5; y++) {
			for (int x = 0; x < 5; x++) {
				ar[y][x] = (p.find(make_pair(a - 2 + y, b - 2 + x)) != p.end());
			}
		}
		for (int sy = a - 2; sy <= a; sy++) {
			if (sy < 0) continue;
			if (sy + 2 >= H) break;
			for (int sx = b - 2; sx <= b; sx++) {
				if (sx < 0) continue;
				if (sx + 2 >= W) break;

				int cnt = 0;
				for (int dy = 0; dy < 3; dy++) {
					for (int dx = 0; dx < 3; dx++) {
						if (ar[sy - (a - 2) + dy][sx - (b - 2) + dx]) cnt++;
					}
				}

				ret[cnt]--;
				ret[cnt + 1]++;
			}
		}

		p.insert(make_pair(a, b));
	}

	rep(i, 10) {
		cout << ret[i] << endl;
	}

    return 0;
}


Measured memory_bytes: 6528
n = int(input())
dict = {}
ans = 0

for i in range(n):
    s = ''
    list = sorted(input())
    for j in list:
        s += j
    if i != 0 and s in dict.keys():
        ans += dict[s]
        dict[s] += 1
    else:
        dict[s] = 1

print(ans)


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

const ll inf = 1e9+5;

int main(){
	int n;
    cin>>n;
    ll a[n];
    for(int i = 0;i < n;i++) cin>>a[i];
    ll dp[n];
    memset(dp, inf, sizeof dp);
    dp[0] = 0;
    for(int i = 0;i < n;i++) {
        for(int j = i+1;j <= i+2;j++) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pp;

int main(void) {
	ll num, i, w, k, ans = 0, dmg = 0, b, x, h;
	cin >> num >> w >> k;
	vector<pp> d(num);
	queue<pp> a;
	rep(i, num)
		cin >> d[i].first >> d[i].second;
	w <<= 1;
	sort(d.begin(), d.end());
	rep(i, num) {
		x = d[i].first;
		h = d[i].second;
		while (!a.empty() && a.front().first < x) {
			dmg += a.front().second;
			a.pop();
		}
		h -= dmg;
		if (h <= 0)
			continue;
		b = h / k + min(h % k, 1ll);
		a.push(make_pair(x + w, -b * k));
		dmg += b * k;
		ans += b;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <string>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

//struct Point {
//	int x,y;
//};
//long long ccw(const Point& A, const Point& B, const Point& C) { // 시계방향이면 음수 
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
\
int main() { // 골드 1, 플레 1
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	int m; cin >> m;
	priority_queue<ll> q;
	rep(i, n) {
		ll x; cin >> x; q.push(x);
	}

	for (int i = 0; i < m; i++) {
		ll x = q.top(); q.pop();
		x /= 2;
		q.push(x);
	}

	ll ans = 0;
	while (!q.empty()) {
		ans += q.top(); q.pop();
	}
	cout << ans << '\n';



}

Measured memory_bytes: 1400
n = int(input())
open_list = [ [ int(v) for v in  input().split() ] for i in range(n)]
profit_list = [ [ int(v) for v in  input().split() ] for i in range(n)]

ans = -10**9
for i in range(1,1024):
    total_profit = 0
    shop = [ int(v) for v in bin(i)[2:].zfill(10) ]
    for j in range(n):
        total_profit += profit_list[j][sum([shop[k] & open_list[j][k] for k in range(10)])]
    ans = max(ans,total_profit)

print(ans)


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

int main() {
  int m, d;
  cin >> m >> d;
  int ans = 0;
  for (int i = 22; i <= d; ++i) {
    int d1, d10;
    d1 = i % 10;
    d10 = i / 10;
    if (d1 < 2 || d10 < 2) continue;
    for (int j = 1; j <= m; ++j) {
      if (d1 * d10 == j) ++ans;
    }
  }
  cout << ans << endl;

  return 0;
}




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

int main() {
	int a[3];
	for (int i=0;i<3;i++){
		cin >> a[i];
	}
	
	int box;
	
	for(int i=0;i<2;i++){
		for(int j=i+1;j<3;j++){
			if(a[i]>a[j]){
				box=a[i];
				a[i]=a[j];
				a[j]=box;
			}
		}
	}
	
	cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
}

Measured memory_bytes: 3084
#include <iostream>
using namespace std;
typedef long long ll;
ll a,b;
int main(void){
    cin>>a>>b;
    a--;
    if(a<0)a=0;
    if(a%4==1)a=1;
    else if(a%4==2)a^=1;
    else if(a%4==3)a=0;
    if(b%4==1)b=1;
    else if(b%4==2)b^=1;
    else if(b%4==3)b=0;
    //cout<<a<<b<<endl;
    cout<<(a^b)<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
#define mem(a,b) memset(a,b,sizeof(a))
const int maxn = 1e5+5;
const int ff = 0x3f3f3f3f;

int n;
int a[maxn];

int main()
{
	cin>>n;
	for(int i = 1;i<= n;i++)
		scanf("%d",&a[i]);
	
	int ans = 0;
	for(int i = 1;i<= n;i++)
	{
		if(a[i] == i)
		{
			if(i!= n)
			{
				int t = a[i];
				a[i] = a[i+1];
				a[i+1] = t;
			}
			else
			{
				int t = a[i];
				a[i] = a[i-1];
				a[i-1] = t;
			}
			ans++;
		}
	}
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 640
n, m = map(int, input().split())
s = [list(map(int, input().split())) for i in range(m)]
s.sort(key=lambda x: x[1])
tmp = 0
ans = 0
for si in s:
    if tmp == 0:
        ans += 1
        tmp = si[1]
        continue
    if tmp <= si[0]:
        ans += 1
        tmp = si[1]

print(ans)


Measured memory_bytes: 64600
#include <iostream>
#include <vector>
#include <unordered_set>
#include <string>
#include <algorithm>

using namespace std;

void reverse(string &stones, int &cnt, char currentTurn)
{
	// string other = (currentTurn == 'W') ? "B" : "W";

	if (stones[0] == currentTurn)
	{
		for (auto itr = stones.rbegin(); itr != stones.rend(); itr++)
		{
			if (*itr == currentTurn)
			{
				break;
			}
			else
			{
				*itr = currentTurn;
			}
		}
		stones = stones + string{currentTurn};
		cnt++;
	}
	else
	{
		for (auto itr = stones.begin(); itr != stones.end(); itr++)
		{
			if (*itr == currentTurn)
			{
				break;
			}
			else
			{
				*itr = currentTurn;
			}
		}
		stones = string{currentTurn} + stones;
		cnt++;
	}
}

bool hasFinished(string const &stones)
{
	return find(stones.begin(), stones.end(), 'W') == stones.end() || find(stones.begin(), stones.end(), 'B') == stones.end();
}

int main()
{
	// string stones;
	// cin >> stones;

	// int cnt = 0;

	// char currentTurn = '-';

	// while (true)
	// {
	// 	if (hasFinished(stones))
	// 	{
	// 		break;
	// 	}

	// 	if (currentTurn == '-')
	// 	{
	// 		if (stones[0] == 'W' && stones[stones.length() - 1] == 'W')
	// 		{
	// 			currentTurn = 'B';
	// 		}
	// 		else
	// 		{
	// 			currentTurn = 'W';
	// 		}
	// 	}

	// 	reverse(stones, cnt, currentTurn);
	// 	currentTurn = (currentTurn == 'W') ? 'B' : 'W';
	// }

	// cout << cnt << endl;

	string stones;
	cin >> stones;
	char current;
	int cnt = 0;

	for (auto itr = stones.begin(); itr != stones.end(); itr++)
	{
		if (itr == stones.begin())
		{
			current = *itr;
		}
		else
		{
			if (current != *itr)
			{
				cnt++;
				current = *itr;
			}
		}
	}

	cout << cnt << endl;
}

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

ans = 1
judg = 0


for i in range(N):
    x = i+1
    counter = 0
    while True:
        if x%2==0:
            x = x / 2
            counter += 1
        else:
            break
    if judg<counter:
        ans = i+1
        judg = counter


print(ans)        


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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b,c) for(int i=a;i<b;i+=c)
#define REPN(i,a,b,c) for(int i=a;i<=b;i+=c)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

int main(void){
    char str[100010];
    scanf("%s", str);
    int len = strlen(str);
    if(len == 2){
        if(str[0] == str[1])cout << 1 << " " << 2;
        else cout << -1 << " " << -1;
        return 0;
    }
    FOR(i,len-2){
        if(str[i] == str[i+1] || str[i] == str[i+2] || str[i+1] == str[i+2]){
            cout << (i+1) << " " << (i+3);
            return 0;
        }
    }

    cout << -1 << " " << -1;

    return 0;
}



Measured memory_bytes: 384
import itertools

if __name__ == '__main__':
    nmq = input()
    nmq = nmq.split()
    n = int(nmq[0])
    m = int(nmq[1])
    q = int(nmq[2])

    abcd = [0]*q
    for i in range(q):
        ele = input()
        ele = ele.split()
        ele = list(map(int,ele))
        abcd[i] = ele

    comb = [i+1 for i in range(m)]

    comb_list = list(itertools.combinations_with_replacement(comb,n))


    max_amount = 0
    for i in range(len(comb_list)):
        amount = 0
        for j in range(q):
            if (comb_list[i][abcd[j][1]-1] - comb_list[i][abcd[j][0]-1]) == abcd[j][2]:
                amount += abcd[j][3]
        max_amount = max(max_amount,amount)

    print(max_amount)


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

int dfa[6][2] = { {1,2}, {-1,3}, {1,-1}, {4,5}, {5,2}, {2,1} };

int main(){
  string p;
  while(cin >> p,p!="#"){
    int now = 0, f = 1;
    for(int i=0;i<p.size();i++){
      now = dfa[now][p[i]-'0'];
      if(now<0){
	f = 0; break;
      }
    }

    cout << ((f && now==5)?"Yes":"No") << endl;
  }
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

template<int NV,class V> class MinCostFlow {
public:
	struct edge { int to; V capacity; V cost; int reve;};
	vector<edge> E[NV]; int prev_v[NV], prev_e[NV]; V dist[NV];
	void add_edge(int x,int y, V cap, V cost) {
		E[x].push_back((edge){y,cap,cost,(int)E[y].size()});
		E[y].push_back((edge){x,0, -cost,(int)E[x].size()-1}); /* rev edge */
	}
	
	pair<V,V> mincost(int from, int to, ll flow) {
		V af=0,res=0; int i,v;
		ZERO(prev_v); ZERO(prev_e);
		while(flow>0) {
			fill(dist, dist+NV, numeric_limits<V>::max()/2);
			dist[from]=0;
			priority_queue<pair<V,int> > Q;
			Q.push(make_pair(0,from));
			while(Q.size()) {
				V d=-Q.top().first;
				int cur=Q.top().second;
				Q.pop();
				if(dist[cur]!=d) continue;
				if(d==numeric_limits<V>::max()/2) break;
				FOR(i,E[cur].size()) {
					edge &e=E[cur][i];
					if(e.capacity>0 && dist[e.to]>d+e.cost) {
						dist[e.to]=d+e.cost;
						prev_v[e.to]=cur;
						prev_e[e.to]=i;
						Q.push(make_pair(-dist[e.to],e.to));
					}
				}
			}
			
			if(dist[to]>=1000000000) return {af,res};
			V lc=flow;
			for(v=to;v!=from;v=prev_v[v]) lc = min(lc, E[prev_v[v]][prev_e[v]].capacity);
			flow -= lc;
			af+=lc;
			res += lc*dist[to];
			for(v=to;v!=from;v=prev_v[v]) {
				edge &e=E[prev_v[v]][prev_e[v]];
				e.capacity -= lc;
				E[v][e.reve].capacity += lc;
			}
		}
		return {af,res};
	}
};

MinCostFlow<23050,ll> mcf;

int N,K;
ll A[50][50];
string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(y,N) FOR(x,N) cin>>A[y][x];
	FOR(y,N) mcf.add_edge(200,y,K,0);
	FOR(y,N) mcf.add_edge(100+y,201,K,0);
	FOR(y,N) FOR(x,N) mcf.add_edge(y,100+x,1,1000000000-A[y][x]);
	
	pair<ll,ll> p=mcf.mincost(200,201,K*N);
	ll ret=p.first*1000000000-p.second;
	cout<<ret<<endl;
	FOR(y,N) {
		S=string(N,'.');
		FORR(e,mcf.E[y]) if(e.to>=100&&e.capacity==0) S[e.to-100]='X';
		cout<<S<<endl;
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main()
{
  int a,i,l,k;
  k=1;
  
  cin >> a;
  
  int v[a];
   
  for(i=0;i<a;i++)
  {
    cin >>l;
    v[i]=l;
  }
  for(i=0;i<a;i++)
  {
    if(v[i]==k)
    {
      k++;
    }
  }
  if(k==1)
  {
    a=-1;
  }
  else{
  a=a-k+1;
  }
  cout << a <<endl;
	
  return 0;
  
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];
    vector<bool> b(N, false);
    ll m = 0;
    for (int i = N; i >= 1; --i)
    {
        if (2 * i > N)
        {
            if (a[i - 1] == 1)
            {
                b[i - 1] = true;
                m++;
            }
        }
        else
        {
            ll count = 0;
            for (int j = 2 * i; j <= N; j += i)
            {
                if (b[j - 1]) count++;
            }
            if (count % 2 == 0)
            {
                if (a[i - 1] == 1)
                {
                    b[i - 1] = true;
                    m++;
                }
            }
            else
            {
                if (a[i - 1] == 0)
                {
                    b[i - 1] = true;
                    m++;
                }
            }
        }
    }
    cout << m << endl;
    REP(i, N) if (b[i]) cout << i + 1 << " ";
}


Measured memory_bytes: 2560
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [usize; m]
    }

    let total: usize = a.iter().sum();
    if total <= n {
        println!("{}", n - total);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 2296
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[][] a = Enumerable.Repeat(0, nm[0]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
        int[][] check = Enumerable.Repeat(0, nm[1]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
        int[] count = new int[nm[1]];
        for (int i = 0; i < nm[0]; i++)
        {
            int min = int.MaxValue;
            int ind = -1;
            for (int j = 0; j < nm[1]; j++)
            {
                if(min > Abs(a[i][0] - check[j][0]) + Abs(a[i][1] - check[j][1]))
                {
                    ind = j;
                    min = Abs(a[i][0] - check[j][0]) + Abs(a[i][1] - check[j][1]);
                }
            }
            Console.WriteLine(ind + 1);
        }
    }
}

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};




int main(){
	int n, k;
	cin >> n >> k;
	llong int ans = 0;
	for(int i = 1; i <= n; i++){
		ans += n/i*max(0,i - k);
		ans += max(n%i - k + 1, 0);
	}
	if(k == 0) ans -= n-k;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
x1,y1,x2,y2 = map(int,input().split())
x3 = x2 + y1 - y2
y3 = y2 + x2 - x1
x4 = x1 + x3 - x2
y4 = y1 + y3 - y2
print(x3,y3,x4,y4)

Measured memory_bytes: 61712
#include "bits/stdc++.h"
using namespace std;

int main()
{
	int64_t k, k_copy;
	cin >> k;
	int64_t count = 5;
	/*k_copy = k;
	while(k_copy != 0)
	{
		k_copy /= 10;
		count++;
	}*/
	vector<vector<int64_t>> runrun(count, vector<int64_t>());
	vector<int64_t> runruns;
	if (k <= 12)
	{
		cout << k;
		return 0;
	}
	for (int64_t i = 0; i < 10; i++)
	{
		runrun[0].push_back(i);
		runruns.push_back(i);
	}

	for (int64_t i = 1; i < count; i++)
	{
		int64_t temp = pow(10, i - 1);
		if (temp == 0) temp = 1;
		for (int64_t j = 0; j < runrun[i - 1].size(); j++)
		{
			int64_t temp2  =runrun[i - 1][j] / temp;
			if (temp2 - 1 >= 0)
			{
				runrun[i].push_back((temp2 - 1) * 10 * temp + runrun[i - 1][j]);
				runruns.push_back(runrun[i].back());
			}
			if (temp2 + 1 < 10)
			{
				runrun[i].push_back((temp2 + 1) * 10 * temp + runrun[i - 1][j]);
				runruns.push_back(runrun[i].back());
			}
			runrun[i].push_back((temp2) * 10 * temp + runrun[i - 1][j]);
			runruns.push_back(runrun[i].back());

		}
		if (runruns.size() <= k)
		{
			count++;
			runrun.push_back(vector<int64_t>());
		}
	}
	sort(runruns.begin(), runruns.end());
	runruns.erase(unique(runruns.begin(), runruns.end()), runruns.end());
	cout << runruns[k] << endl;
	return 0;
}

Measured memory_bytes: 136928