akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b , c;
    cin >> a >> b;
    if( b >= 10 && b <= 99 ) {
        c = a * 100 + b;
    } else if( b >= 1 && b <= 9 ) {
        c = a * 10 + b;
    } else {
        c = a * 1000 + 100;
    }
    for( int i = 1 ; i <= 316 ; i++ ) {
        if( c == i * i ) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}



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

#define pb     push_back
#define mp     make_pair
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
const ll INF =  0x3f3f3f3f;
const int MOD = 1e9+7;
const int MAX = 1e5+5;

vector<int> a;
int n, d;
ll sum;

int main(int argc, char const *argv[])
{
  ios_base::sync_with_stdio(false);
  
  // #ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
  // freopen("out","w",stdout);
  // #endif

  scanf("%d" , &n);

  for(int i = 0 ; i < n ; i++){
  	scanf("%d" , &d);
  	a.pb(d);
  	sum += d;
  }

  ll ans = LLONG_MAX;
  ll temp = 0;

  for(int i = 0 ; i < n-1 ; i++){
  	temp = temp + a[i];
  	if(abs(sum - 2*temp) < ans)
  		ans = abs(sum - 2*temp);
  }

  printf("%lld" , ans);
  return 0;
} 

Measured memory_bytes: 1400
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define PI 3.14159265358979323846264338327950288
 
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;
int main(){
    FAST_IO ;
    int X ; cin >> X ;
    if( X >= 30 )
        cout << "Yes" << endl ;
    else
        cout << "No" << endl ;
    
    return 0 ;
}
 
 

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int k, n;
  cin >> k >> n;
  int vals[n];
  for (int i = 0; i < n; i++) cin >> vals[i];
  int res = vals[n - 1] - vals[0];
  for (int i = 1; i < n; i++) {
    int ans = k - vals[i] + vals[i - 1];
    res = min(res, ans);
  }
  cout << res << '\n';
  return 0;
}


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

int arr[200001];
int cnt[200001];

int32_t main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> arr[i];
    int cur = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (arr[i] < cur)
        {
            cnt[i] = cur - arr[i];
        }
        else
        {
            cur = arr[i];
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
        ans += cnt[i];
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

typedef long long ll;

const int maxn=2e5+10;

int a[maxn];
int fa[maxn],siz[maxn];

int get_fa( int x ) { return fa[x]==x ? x : fa[x]=get_fa(fa[x]); }

int main()
{
	int n,m;
	cin>>n>>m;
	for( int i=1;i<=n;i++ ) fa[i]=i,siz[i]=1;
	
	for( int i=1;i<=m;i++ )
	{
		int x,y;cin>>x>>y;
		int fx=get_fa(x),fy=get_fa(y);
		if(fx==fy ) continue;
		siz[fx]+=siz[fy]; 
		fa[fy]=fx;
	}
	
	int res=0;
	for( int i=1;i<=n;i++ )
	{
		int fi=get_fa(i);
		res=max(res,siz[fi]);
	}
	cout<<res;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i) // ROF(i,n,0)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define SUM(a) accumulate(all(a),int(0))
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  int n; cin >> n;
  vi a(n); rep(i,n) cin >> a[i];
  vi b(n+1,-1);
  vi ans;
  ROF(i,n+1,1){ // 後ろから決める
    int tmp = 0;
    for(int j = 2*i; j <= n; j += i){
      tmp ^= b[j];
    }
    dump(i,tmp,a[i-1]);
    if(a[i-1] == tmp) b[i] = 0;
    else{
      b[i] = 1;
      ans.push_back(i);
    }
  }
  dump(b);
  cout << ans.size() << endl;
  if(ans.size()) cout << ans[0];
  else return 0;
  FOR(i,1,ans.size()) cout << " " << ans[i];
  cout << endl;
}


Measured memory_bytes: 4980
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
LL A[100011];
LL B[100011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%lld", A+i);
    REP (i, N) scanf("%lld", B+i);

    LL sumA = 0, sumB = 0;
    REP (i, N) {
	sumA += A[i];
	sumB += B[i];
    }

    if (sumA < sumB) {
	puts("-1");
    } else {
	LL rest = sumA - sumB;
	vector<LL> v;
	REP (i, N) if (A[i] >= B[i]) v.push_back(A[i] - B[i]);
	sort(v.begin(), v.end());

	int ans = 0;
	EACH (e, v) {
	    if (*e <= rest) {
		ans++;
		rest -= *e;
	    }
	}

	printf("%d\n", N - ans);
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 2936
import itertools

n = int(input())
xy_map = []
for i in range(n):
    xy_map.append([9]*n)

for i in range(n):
    ai = int(input())
    for j in range(ai):
        xj, yj = [int(_) for _ in input().split()]
        xy_map[i][xj-1] = yj

def judge_ox(i, j, set_01):
    if set_01[j] == '1':
        if 0 in [xy_map[i][j], xy_map[j][i]]:
            return False
        else:
            return True
    else:
        if xy_map[i][j] in [0, 9]:
            return True
        else:
            return False

res = 0
for set_01 in itertools.product('01', repeat=n):
    flag = 1
    for i in range(n):
        if set_01[i] != '1':
            continue
        for j in range(n):
            if i == j:
                continue
            if not judge_ox(i, j, set_01):
                flag = 0
                break
    if flag:
        res = max(res, sum([int(x) for x in set_01]))
print(res)

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

using ll = long long;
const int INF = 1e9 + 1;

int main(){

	int N;
	string S;
	cin >> N >> S;

	int ans = 0;
	rep(i, N) {
		if (strncmp(&S[i], "ABC", 3) == 0)
			ans++;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

void OrganizeTrain(set<string>&, string, int);
string Reverse(string);

int main(){
  int i, j, n;
  string str;
  set<string> data;

  cin >> n;

  for(i=0; i<n; ++i){
    cin >> str;

    for(j=1; j<str.size(); ++j)
      OrganizeTrain(data, str, j);

    cout << data.size() << endl;
    data.clear();
  }
  return 0;
}

void OrganizeTrain(set<string>& data, string original, int n){
  string front, back;
  string reverse_front, reverse_back;

  copy(original.begin(), original.begin()+n, back_inserter(front));
  copy(original.begin()+n, original.end(), back_inserter(back));
  reverse_front = Reverse(front);
  reverse_back = Reverse(back);

  if(data.find(front + back) == data.end())
    data.insert(front + back);
  if(data.find(front + reverse_back) == data.end())
    data.insert(front + reverse_back);

  if(data.find(reverse_front + back) == data.end())
    data.insert(reverse_front + back);
  if(data.find(reverse_front + reverse_back) == data.end())
    data.insert(reverse_front + reverse_back);

  if(data.find(back + front) == data.end())
    data.insert(back + front);
  if(data.find(back + reverse_front) == data.end())
    data.insert(back + reverse_front);

  if(data.find(reverse_back + front) == data.end())
    data.insert(reverse_back + front);
  if(data.find(reverse_back + reverse_front) == data.end())
    data.insert(reverse_back + reverse_front);
}

string Reverse(string str){
  int i;
  string _str;
  for(i=str.size()-1; i>=0; --i) _str.push_back(str[i]);
  return _str;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

/*
    LazySegmentTree<int, int> seg(f, g, h, p, def, laz_def) のように宣言する
*/
template <typename Monoid, typename OperatorMonoid>
struct LazySegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;
    using G = function<Monoid(Monoid, OperatorMonoid)>;
    using H = function<OperatorMonoid(OperatorMonoid, OperatorMonoid)>;
    using P = function<OperatorMonoid(OperatorMonoid, int)>;
    int n;
    vector<Monoid> dat;
    vector<OperatorMonoid> laz;
    F f;
    G g;
    H h;
    P p;
    Monoid def;
    OperatorMonoid laz_def;

    LazySegmentTree(F f, G g, H h, P p, Monoid def, OperatorMonoid laz_def) : f(f), g(g), h(h), p(p), def(def), laz_def(laz_def){}

    void build(const vector<Monoid> & vec){
        int siz = vec.size();
        n = 1;
        while(n < siz) n *= 2;
        dat.assign(2 * n - 1, def);
        laz.assign(2 * n - 1, laz_def);
        for(int i = 0; i < siz; i++) dat[n - 1 + i] = vec[i];
        for(int i = n - 2; i >= 0; i--) dat[i] = f(dat[2 * i + 1], dat[2 * i + 2]);
    }

    void update(int a, int b, OperatorMonoid x){
        update(a, b, x, 0, 0, n);
    }

    Monoid query(int a, int b){
        return query(a, b, 0, 0, n);
    }

private:
    void eval(int k, int l, int r){
        if(laz[k] != laz_def){
            dat[k] = g(dat[k], p(laz[k], r - l));
            if(r - l > 1){
                laz[2 * k + 1] = h(laz[2 * k + 1], laz[k]);
                laz[2 * k + 2] = h(laz[2 * k + 2], laz[k]);
            }
            laz[k] = laz_def;
        }
    }

    void update(int a, int b, OperatorMonoid x, int k, int l, int r){
        eval(k, l, r);
        if(r <= a || b <= l) return;
        if(a <= l && r <= b){
            laz[k] = h(laz[k], x);
            eval(k, l, r);
        }else{
            update(a, b, x, 2 * k + 1, l, (l + r) / 2);
            update(a, b, x, 2 * k + 2, (l + r) / 2, r);
            dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }

    Monoid query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return def;
        eval(k, l, r);
        if(a <= l && r <= b) return dat[k];
        Monoid vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        Monoid vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
};

signed main(){
    int n,q;
    cin >> n >> q;
    auto f = [](int a, int b){return min(a, b);};
    auto g = [](int a, int b){return b;};
    auto h = [](int a, int b){return b;};
    auto p = [](int a, int b){return a;};
    LazySegmentTree<int, int> seg(f, g, h, p, INT_MAX, INT_MAX);
    seg.build(vector<int> (n, INT_MAX));
    int Q;
    REP(i,q){
        cin >> Q;
        int s,t,x;
        if(Q == 0){
            cin >> s >> t >> x;
            t++;
            seg.update(s, t, x);
        }else{
            cin >> s >> t;
            t++;
            cout << seg.query(s, t) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5212
a, b, k = map(int, input().split())
ans = []

if k >= b-a+1:
    for i in range(b-a+1):
        print(a+i)
    exit()

for i in range(k):
    ans.append(a+i)
for i in range(k):
    if not b-i in ans:
        ans.append(b-i)
ans.sort()
for i in ans:
    print(i)


Measured memory_bytes: 38256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,a,b,c,d;
    cin >>a>>b>>c>>d;
    ans=max(a*b,c*d);

    dbg{
        if(true)cout <<"YES"<<endl;
        else cout <<"NO"<<endl;
    }

    cout <<ans<<endl;

    return 0;

}

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

int f(int n) {
    int count = 0;
    for (int x = 1; x <= 100; x++) {
        for (int y = x; y <= 100; y++) {
            for (int z = y; z <= 100; z++) {
                int p = x * x + y * y + z * z + x * y + y * z + z * x;
                if (p == n) {
                    if (x == y && y == z) count += 1;
                    else if (x == y && y != z) count += 3;
                    else if (y == z && z != x) count += 3;
                    else if (z == x && x != y) count += 3;
                    else count += 6;
                }
            }
        }
    }
    return count;
}

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cout << f(i) << endl;
    }
}

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

using namespace std;

#define ll					long long
#define vi					vector<int>
#define vii					vector<vi>
#define ALL(s)			(s).begin(),(s).end()
#define pii					pair<int, int>
#define pll					pair<ll, ll>
#define si					set<int>
#define mp					make_pair
#define F						first
#define S						second
#define pb					push_back
#define tc(t)				int t; cin >> t; while(t--)
#define _						ios_base::sync_with_stdio(false); cin.tie(NULL); 
const ll MOD = 1e9 + 7;
const ll INF = 1<<29;
const ll MAX_N = 1e6 + 7;

int main() {_
	string s;
	cin >> s;
	if(s[2]==s[3] && s[4] == s[5]) cout <<"Yes\n";
	else cout << "No\n";
 
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

i64 N, A, B;

void solve() {
  i64 ans = min(N * A, B);
  cout << ans << endl;
}

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

  solve();

  return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;

ll gcd(ll x, ll y){
    return y ? gcd(y, x%y) : x; 
}

void Main(){
    int n; cin >> n;
    vector<ll> t(n), f(n);
    map<Pll, ll> mp;
    
    rep(i, n){
        string s; cin >> s;
        ll den;
        ll nom;

        if(s.find('.') == string::npos){
            den = 1;
            nom = stoll(s);
        }else{
            int fr = s.find('.');
            int ba = s.size() - fr - 1;
            den = pow(10, ba);
            nom = stoll(s.substr(0, fr)) * den + stoll(s.substr(fr + 1));
        }
        ll g = gcd(den, nom);
        den /= g;
        nom /= g;
        // cout << s << " -> " << nom << " / " << den << endl;
        while(nom % 2 == 0){
            nom /= 2;
            t[i]++;
        }
        while(nom % 5 == 0){
            nom /= 5;
            f[i]++;
        }
        while(den % 2 == 0){
            den /= 2;
            t[i]--;
        }
        while(den % 5 == 0){
            den /= 5;
            f[i]--;
        }
        // cout << s << " -> " << t[i] << ", " << f[i] << endl;
        mp[{t[i], f[i]}]++;        
    }
    
    /*
    for(auto [d, c] : mp){
        cout << d.fi << "," << d.se << " -> " << c << endl;
    }
    cout << endl;
    //*/
    
    ll ans = 0;
    for(auto [d, c] : mp) {
        for(auto [D, C] : mp){
            if(d == D && d.fi >= 0 && d.se >= 0) {
                // cout << "case 1: " << d.fi << ", " << d.se << " -> " << c * (c-1) << endl;
                ans += c * (c-1);
            }
            else if(d.fi + D.fi >= 0 && d.se + D.se >= 0) {
                ans += c * C;
            }
        } 
    }
    cout << ans/2 << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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

using namespace std;

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

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
#define mem(x,n) memset(x,n,sizeof(x))
#define all(x) x.begin(), x.end()
#define endl "\n"

int main()
{
	faster;
	
	string a,b;
	cin >> a >> b;
	int ans = 1;

	if(a.size() < b.size()){
		ans = 3;
	}else if(a.size() > b.size()) {
		ans = 2;
	}else {
		for(int i = 0; i < a.size(); i++){
			if(a[i] > b[i]){
				ans = 2;
				break;
			}else if(a[i] < b[i]){
				ans = 3;
				break;
			}
		}
	}

	if(ans == 1) cout << "EQUAL" << endl;
	else if(ans == 2) cout << "GREATER" << endl;
	else cout << "LESS" << endl;
	
	return 0;
}

Measured memory_bytes: 3600
'use strict'
N = int(input())
B = list(map(int, input().split()))
A = [0 for i in range(N)]

A[0] = B[0]
A[1] = B[0]

for i in range(1, N-1):
    if B[i] >= B[i-1]:
        A[i+1] = B[i]
    else:
        A[i+1] = B[i]
        A[i] = B[i]

print(sum(A))

Measured memory_bytes: 3064
function Main(input) {
  input = input.split("\n");
  const N = input[0];
  const heights = input[1].split(" ");
  
  var steps = 0;
  
  for(var i = 1; i < N ; i++){
    var a = parseInt(heights[i-1], 10);
    var b = parseInt(heights[i], 10);
  	if(b < a){
    	var dif = a - b;
    	steps += dif;
      	heights[i] = parseInt(heights[i], 10) + dif;
    }
  }
  
  console.log("%d", steps);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 49104
def main():
    n = int(input())
    s = input()

    ans = -float("inf")
    for i in range(1, n):
        s_union = set(s[:i]) & set(s[i:])
        ans = max(ans, len(s_union))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
N = int(input())
As = []
xys = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    As.append(A)
    for j in range(A):
        x, y = map(int, input().split())
        xys[i].append((x-1, y))

ans = 0
for i in range(2**N):
    state = [(i>>j)&1 for j in range(N)]
    isOk = True
    for k in range(N):
        if state[k]==0:
            continue
        for x, y in xys[k]:
            if not state[x]==y:
                isOk = False
    if isOk:
        ans = max(ans, sum(state))

print(ans)



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
typedef long long ll;
using namespace std;
int main(void){
    int a,b,x;
    cin>>a>>b>>x;
    if(a<=x&x<=a+b){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
//
// Created by kuroneko on 2019-08-04.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000007LL

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight):src(src), dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

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

    if (A - B > C) cout << 0 << endl;
    else cout << C - A + B << endl;

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long
#define MAXN 200005
#define mod 998244353
#define INF 0x3f3f3f3f
#define ld long double
using namespace std;
ll s1[MAXN],s2[MAXN];
set<ll>ans;
int main(){
    ios::sync_with_stdio(false);
    #define int ll
    int n,k,c;
    cin>>n>>k>>c;
    string s;
    cin>>s;

    int t=0,num=0;
    for(int i=0;i<n;i++){
        if(t==0&&s[i]=='o'){

            if(num<k)num+=1;
            s1[i]=num;
            t=c;
        }
        else {
            if(t>0)t-=1;
            s1[i]=num;
        }
    }
    t=0;num=0;
    for(int i=n-1;i>=0;i--){
        if(t==0&&s[i]=='o'){

            if(num<k)num+=1;
            s2[i]=num;
            t=c;
        }
        else {
            if(t>0)t-=1;
            s2[i]=num;
        }
    }
    for(int i=0;i<n;i++){
        if(i==0){
            if(s2[1]>=k){
                ans.insert(i+1);
            }
        }
        else if(i==n-1){
            if(s1[n-2]>=k){
                ans.insert(i+1);
            }
        }
        else{
            if(s1[i-1]+s2[i+1]>=k){
                ans.insert(i+1);
            }
        }
    }

    for(int i=1;i<=n;i++){
        if(ans.find(i)==ans.end()){
            cout<<i<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 12948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSR(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n,m;
int vec[200005];

struct maintain_interval{
	int bit[(1<<18)+5];
	void init(){
		memset(bit,0,sizeof(bit));
	}
	int f(int x)
	{
		return x&-x;
	}
	void add(int i,int x)
	{
		for(int s=i;s<=(1<<18);s+=f(s)) bit[s]+=x;
	}
	int sum(int i)
	{
		int res=0;
		for(int s=i;s>0;s-=f(s)) res+=bit[s];
		return res;
	}
}mt;

P forbid[200005][2];
bool ok[200005],ok2[200005];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<2*n;i++){
		scanf("%d",&vec[i]);
	}
	sort(vec,vec+2*n);
	
	int lb = -1,ub = m-1;
	while(ub-lb > 1){
		int mid = (lb+ub)/2;
		rep(i,200005) rep(j,2) forbid[i][j] = mp(0,0);
		for(int i=0;i<2*n;i++){
			//vec[i]と足してmod mでmidより大な区間
			for(int j=0;j<2;j++){
				//[mid+1+m*j,m*(j+1)-1]
				if(vec[i] <= mid+1 && j == 1) break;
				int L = mid+1+m*j-vec[i];
				int R = m*(j+1)-1-vec[i];
				L = lower_bound(vec,vec+2*n,L)-vec;
				R = upper_bound(vec,vec+2*n,R)-vec; R--;
				if(L <= R) forbid[i][j] = mp(L+i+1,R+i+1);
			}
		}
		mt.init();
		for(int i=0;i<2*n;i++){
			for(int j=0;j<2;j++) if(forbid[i][j].fi){
				mt.add((forbid[i][j].fi+1)/2,1);
				mt.add((forbid[i][j].sc)/2+1,-1);
			}
			if(i%2 == 1){
				ok[i] = !mt.sum((i+1)/2);
			}
		}
		mt.init();
		for(int i=2*n-1;i>=0;i--){
			for(int j=0;j<2;j++) if(forbid[i][j].fi){
				mt.add((forbid[i][j].fi+1)/2,1);
				mt.add((forbid[i][j].sc)/2+1,-1);
			}
			if(i%2 == 0){
				ok2[i] = !mt.sum((2*n+i)/2);
			}
		}
		ok2[2*n] = true;
		bool flag = 0;
		for(int i=0;i<2*n;i++){
			if(i%2 == 1){
				if(ok[i] && ok2[i+1]){
					flag = 1;
					break;
				}
			}
		}
		if(flag) ub = mid;
		else lb = mid;
	}
	printf("%d\n",ub);
	return 0;
}


Measured memory_bytes: 5632
n = int(input())
a = list(map(str,input().split()))

data1 = a[:]
data2 = a[:]

def bubble_sort(data):
	for i in range(len(data)):
		for j in range(len(data)-1,i,-1):
			if(data[j][1] < data[j-1][1]):
				data[j],data[j-1] = data[j-1],data[j]

	return(data)

def selection_sort(data):
	for i in range(len(data)):
		minj = i
		for j in range(i,len(data)):
			if(data[j][1] < data[minj][1]):
				minj = j

		data[i],data[minj] = data[minj],data[i]

	return(data)
data1 = bubble_sort(data1)
data2 = selection_sort(data2)
print(*data1)
print("Stable")
print(*data2)
print("Stable" if data1 == data2 else "Not stable")



Measured memory_bytes: 5616
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define rep2(i, m, n) for (int i = m; i < n; i++)
#define all(v) v.begin(), v.end
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

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

    if(s.at(2) == s.at(3) && s.at(4) == s.at(5)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def solve():
    N = int(raw_input())
    arr = [int(_) for _ in raw_input().split()]
    left = [0] * (N + 1)
    right = [0] * (N + 1)
    left[0] = 0
    right[N] = 0
    for i in range(1, N+1):
        left[i] = gcd(left[i - 1], arr[i - 1])
    for i in range(N - 1, 0, -1):
        right[i] = gcd(right[i + 1], arr[i])
    max_gcd = 0
    for i in range(N):
        max_gcd = max(max_gcd, gcd(left[i], right[i+1]))
    print str(max_gcd)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 12980
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
int main(){
	ll n, k, s; cin >> n >> k >> s;
		for(ll i = 0; i < n; ++i){
			if(i < k)
				cout << s << " ";
			else cout << (s + ll(1)) % ll(1000000000) <<" ";
		}
	return 0;
}


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

int main()
{
    int d,r,a,b;
    double f,s,t;
    cin >> a >> b;
    s=a;
    t=b;
    d=a/b;
    r=a%b;
    f=s/t;
    cout<<d<<" "<<r<<" ";

    cout<<fixed<<setprecision(5)<<f<<endl;

    return 0;

}



Measured memory_bytes: 3276
N = int(input())
t = [int(i) for i in input().split()]
v = [int(i) for i in input().split()]

for i in range(1, N) :
        t[i] += t[i-1]
        
l = [t_ + v_ for t_, v_ in zip(t, v[1:]+[0])]
for i in range(N-2, -1, -1) :
    l[i] = min(l[i], l[i+1])
    
cur_v, cur_t = 0, 0
ret = 0
for i in range(N) :
    t1 = v[i] - cur_v + cur_t
    t2 = l[i] - v[i]
    if t[i] < t1 <= t2 :
        ret += (2 * cur_v + t[i] - cur_t) * (t[i] - cur_t) / 2
        cur_v = cur_v + t[i] - cur_t
        
    elif cur_t <= t1 <= t2 :
        ret += (t1 - cur_t) * (cur_v + v[i]) / 2
        if t2 <= t[i] :
            ret += (t2 - t1) * v[i]
            ret += (t[i] - t2) * (v[i] + l[i] - t[i]) / 2
            cur_v = l[i] - t[i]
        else :
            ret += (t[i] - t1) * v[i]
            cur_v = v[i]
    
    else :
        t3 = (l[i] + cur_t - cur_v) / 2
        if t3 >= t[i] :
            t3 = t[i]
        ret += (t3 - cur_t) * (2 * cur_v + t3 - cur_t) / 2
        ret += (t[i] - t3) * (2 * (cur_v + t3 - cur_t) - (t[i] - t3)) / 2
        if t3 == t[i] :
            cur_v = cur_v + t[i] - cur_t
        else :
            cur_v = l[i] - t[i]
    cur_t = t[i]
    
print(ret)

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    
    int N[3];
    for(int i = 0; i < 3; i++){
        cin >> N[i];
    }
    sort(N, N+3);
    
    int ans = N[2] * 10 + N[1] + N[0];
    cout << ans << endl;
    
}


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

struct p{
	int a,b,c,d;
}

p[55];

int d[15];

int n,m,q;
ll mx =0;

void calc(int s , int ct){
	if(ct ==n+1){
	/*	for(int i=1; i<=n; i++){
			cout<<d[i]<<" ";
		}
		cout<<endl;*/
		ll sum =0;
		for(int i=0; i<q; i++){
			if(p[i].c == d[p[i].b]-d[p[i].a]){
				sum += p[i].d;
			}
		}
	/*	cout<<sum<<endl;*/
		 mx = max(mx, sum);

		return ;
	}

	for(int i=s; i<=m; i++ ){
		d[ct] =i;

		calc(i,ct+1);
	}
}



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

	cin>>n>>m>>q;

	for(int i=0; i<q; i++){
		cin>>p[i].a>>p[i].b>>p[i].c>>p[i].d;
	}
	calc(1, 1);

	writeln(mx);

/*
	for(int i=0; i<q; i++){
		cout<<p[i].a<<" "<<p[i].b<<" "<<p[i].c<<" "<<p[i].d<<endl;
	}

*/



}




Measured memory_bytes: 3640
local n, c = io.read("*n", "*n")
local tbl = {}
for i = 1, n do
  local tmp = {}
  tmp.s, tmp.t, tmp.c = io.read("*n", "*n", "*n")
  tbl[i] = tmp
end
table.sort(tbl, function(a, b) return a.s < b.s end)
local rec_end = {tbl[1].t}
local rec_ch = {tbl[1].c}

for i = 2, n do
  local fpos = nil
  for ir = 1, #rec_end do
    if rec_end[ir] == tbl[i].s and rec_ch[ir] == tbl[i].c then
      rec_end[ir] = tbl[i].t
      fpos = ir
      break
    elseif rec_end[ir] < tbl[i].s then
      if not fpos then
        fpos = ir
      else
        if rec_end[ir] < rec_end[fpos] then
          fpos = ir
        end
      end
    end
  end
  if fpos then
    rec_end[fpos] = tbl[i].t
    rec_ch[fpos] = tbl[i].c
  else
    table.insert(rec_end, tbl[i].t)
    table.insert(rec_ch, tbl[i].c)
  end
end
print(#rec_end)


Measured memory_bytes: 16896
#include<bits/stdc++.h>
using namespace std;
#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 RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;

int main(){
  int n,k;
  cin >> n >> k;
  vector<ll> a(n);
  REP(i,n)cin >> a.at(i);

  for(int i=k;i<n;i++){
    if(a.at(i)>a.at(i-k))cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


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

int main() {
    int a, b, c, t;
    cin >> a >> b >> c;
    if (a > b){
        t = a;
        a = b;
        b = t;
    }
    if ( b > c){
        t = b;
        b = c;
        c = t;
    }
    if (a > b){
        t = a;
        a = b;
        b = t;
    }
    
    cout << a << " "<< b << " " << c <<endl;
    
    return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#define maxn 200010
#define inf 1000000007
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
int a[maxn],pos[maxn];
int t[maxn*4];
int od[maxn*4],ev[maxn*4];
void push_up(int k)
{
    t[k]=min(t[k*2],t[k*2+1]);
    od[k]=min(od[k*2],od[k*2+1]);
    ev[k]=min(ev[k*2],ev[k*2+1]);
}
void build(int k,int l,int r)
{
    if(l==r)
    {
        t[k]=a[l];
        od[k]=ev[k]=inf;
        if(l%2==0)  ev[k]=min(ev[k],a[l]);
        else  od[k]=min(od[k],a[l]);
        return;
    }
    int mid=(l+r)/2;
    build(k*2,l,mid);
    build(k*2+1,mid+1,r);
    push_up(k);
}
int query(int k,int l,int r,int x,int y,int book)
{
    if(l>=x&&r<=y)
    {
        if(book==0)  return ev[k];
        if(book==1)  return od[k];
        return t[k];
    }
    int mid=(l+r)/2;
    int res=inf;
    if(mid>=x)  res=min(res,query(k*2,l,mid,x,y,book));
    if(mid<y)   res=min(res,query(k*2+1,mid+1,r,x,y,book));
    return res;
}
struct P{
    int l,r,mix;
};
struct cmp{
    bool operator () (const P a,const P b)
    {
        return a.mix>b.mix;
    }
};
priority_queue<P,vector<P>,cmp> q;
void work(int l,int r)
{
    int tmp=query(1,1,n,l,r,l%2);
    q.push((P){l,r,tmp});
}
void solve()
{
    int tmpx=query(1,1,n,1,n,1);
    q.push((P){1,n,tmpx});
    while(q.size())
    {
        P now=q.top();
        q.pop();
        int L=pos[now.mix];
        int R=pos[query(1,1,n,L+1,now.r,(now.l+1)%2)];
        printf("%d %d ",a[L],a[R]);
        if(now.l<=L-1)  work(now.l,L-1);
        if(L+1<=R-1)    work(L+1,R-1);
        if(R+1<=now.r)  work(R+1,now.r);
    }
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++)  a[i]=read();
    for(int i=1;i<=n;i++)  pos[a[i]]=i;
    build(1,1,n);
    solve();
    puts("");
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int H, W, h, w; cin >> H >> W >> h >> w;
  if (H%h==0&&W%w==0) {cout << "No" << endl; return 0;}
  int pos = 1000;
  int neg = -1 * (pos*(h*w-1)+1);
  int result[H][W];
  rep(i,H) rep(j,W) {
    result[i][j] = ((i+1)%h==0&&(j+1)%w==0) ? neg : pos;
  }

  cout << "Yes" << endl;
  rep(i,H) {
    rep(j,W) cout << result[i][j] << " ";
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 2560
use std::io;


fn main() {
    let (n, m) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let mut wa = vec![0; n];
    let mut ac = vec![false; n];
    for _ in 0..m {
        let (p, s) = {
            let i = read::<String>();
            (i[0].clone().parse::<usize>().unwrap() - 1, i[1].clone())
        };

        if ac[p] { continue; }
        if s == "WA" { wa[p] += 1; }
        else { ac[p] = true; }
    }
    let sum_ac = ac.iter().map(|&t| if t { 1 } else { 0 }).sum::<usize>();
    let mut sum_wa = 0;
    for i in 0..n {
        if ac[i] {
            sum_wa += wa[i];
        }
    }
    println!("{} {}", sum_ac, sum_wa);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main(){
  long long q,h,s,d,n;
  cin>>q >>h >>s >>d >>n;
  
  cout<<(n/2)*min({q*8,h*4,s*2,d})+(n%2)*min({q*4,h*2,s})<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long int
#define pb push_back
#define mp make_pair
#define ip pair<int, int>
#define it pair<int, pair<int, int>>
#define F first
#define S second
#define fori(p, n) for(int i = p; i < n; i++)
#define forj(q, m) for(int j = q; j < m; j++)
#define fork(r, l) for(int k = r; k < l; k++)
#define revi(h) for(int i = h; i >= 0; i--)
#define all(v) v.begin(), v.end()
#define PI 3.14159265358
#define debug(x) cout<<"DEBUGGING --- "<<x<<endl;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define input_from_file  freopen("input.txt", "r", stdin);
#define output_to_file freopen("output.txt", "w", stdout);
signed main(){
    fastio;
    //input_from_file; 
    //output_to_file;
    int h, w; cin>>h>>w;
    vector<vector<char>>G(h + 1, vector<char>(w + 1));
    fori(0, h)
        forj(0, w) cin>>G[i][j];
    int m = 1000000007;
    vector<vector<int>>D(h + 1, vector<int>(w + 1, 0));
    D[0][0] = 1;
    fori(1, h) if(G[i][0] == '.') D[i][0] = D[i - 1][0];
    fori(1, w) if(G[0][i] == '.') D[0][i] = D[0][i - 1];
    fori(1, h)
        forj(1, w)
            if(G[i][j] == '.') D[i][j] = (D[i - 1][j] + D[i][j - 1]) % m;
    cout<<D[h - 1][w - 1]<<endl;                            
}

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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;
int visited[1000][1000];
int r,c;
char grid[1000][1000];
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
bool isvalid(int i, int j) {
    return i >= 0 && i < r && j >= 0 && j < c;
}
int32_t main() {
    nitin;
    cin>>r>>c;
    queue<pair<int,int>>q;
    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++)
        {
            cin>>grid[i][j];
            if(grid[i][j]=='#') {
                q.push({i, j});
                visited[i][j] = 1;
            }
        }
    }
    int cnt=0;
    while(true)
    {
        cnt++;
        queue<pair<int,int>>nq;
        while(!q.empty()){
            int x=q.front().first;
            int y=q.front().second;
            q.pop();
            for(int i=0;i<4;i++)
            {
                int a=x+dx[i];
                int b=y+dy[i];
                if(isvalid(a,b) && !visited[a][b])
                {
                    nq.push({a,b});
                    visited[a][b]=1;
                }
            }
        }
        q=nq;
        if(q.empty())
            break;
    }
    cout<<cnt-1<<endl;
    return 0;
}

Measured memory_bytes: 28588
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;

    if (n % 1000 == 0) {
        cout << 0 << endl;
    } else {
        cout << 1000 - (n % 1000) << endl;
    }

return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste
// #include "UnionFind.h"
// #include "power.h"

signed main() {
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;
    int ans = 2 * N;
    for (int i = 0; i < N; ++i) {
        // cout << s.substr(N - 1 - i, N) << " " << t.substr(0, i + 1) << endl;
        if (s.substr(N - 1 - i, N) == t.substr(0, i + 1)) {
            ans = min(ans, 2 * N - (i + 1));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
vector<string> r{"dream", "dreamer", "erase", "eraser"};
/* function */
/* main */
int main(){
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    for (int i = 0; i < r.size(); i++) reverse(r[i].begin(), r[i].end());

    bool can;
    int i = 0;
    while(true) {
        can = false;
        for (string s : r) {
            if (i + s.size() > S.size()) continue;
            if (S.substr(i, s.size()) == s) {
                can = true;
                i += s.size();
                break;
            }
        }
        if (can == false) { cout << "NO" << '\n'; return 0; }
        else if (i == S.size()) { cout << "YES" << '\n'; return 0; }
    }
}

Measured memory_bytes: 512
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <numeric>
#include <queue>
typedef long long int ll;
using namespace std;
int main(){
	int A,B;
	cin>>A>>B;
	for(int i=1;i<1010;i++){
		if((i*8/100==A) and (i/10==B)){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define inf 1000000000007;
typedef long long ll;
int main(){
	fast;
	ll n; cin>>n;
	cout<<(ll)ceil((double)n/2)<<'\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
const int inf = 1e9+7;
int main() {
    int n, m; cin >> n >> m;
    vector<vector<pair<int, int> > > g(n);
    repeat (i,m) {
        int a, b, c; cin >> a >> b >> c; -- a; -- b;
        g[a].emplace_back(b, c);
        g[b].emplace_back(a, c);
    }
    vector<vector<int> > dist = vectors(n, n, inf);
    repeat (i,n) dist[i][i] = 0;
    repeat (i,n) for (auto it : g[i]) dist[i][it.first] = it.second;
    repeat (k,n) repeat (i,n) repeat (j,n) setmin(dist[i][j], dist[i][k] + dist[k][j]); // warshall floyd
    int cnt = 0;
    repeat (i,n) for (auto it : g[i]) {
        int j, cost; tie(j, cost) = it;
        if (i > j) continue;
        bool used = false;
        repeat (k,n) {
            if (dist[i][k] == cost + dist[j][k]) {
                used = true;
                break;
            }
        }
        if (not used) cnt += 1;
    }
    cout << cnt << endl;
    return 0;
}


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

#define ran 202202

int n;
int a[ran];
vector<int> e[ran];

int f[ran];
int len;

int ans[ran];

void dfs(int cur, int par) {
	int val = a[cur];
	int it = lower_bound(f, f+len, val) - f;
	int tmp = f[it];
	f[it] = val;
	
	bool inc = false;
	if(it>=len) { len++; inc = true; }
	
	ans[cur] = len;
	
	for(int i=0;i<(int)e[cur].size();i++) {
		int nxt = e[cur][i];
		if(nxt==par) continue;
		dfs(nxt, cur);
	}
	
	f[it] = tmp;
	if (inc) len--;
}

int main() {
	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d", &a[i]);
	for(int i=1;i<n;i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	
	len = 0;
	dfs(1, -1);
	
	for(int i=1;i<=n;i++) printf("%d\n", ans[i]);
	
	return 0;
}

Measured memory_bytes: 30572
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  int n,W;
  cin>>n>>W;
  vector<int> w(n);
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>w[i]>>v[i];
  vector<vector<int> > dp(n+1,vector<int>(W+W+1,0));

  for(int i=0;i<n;i++){
    for(int j=0;j<W;j++){
      dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
    }
  }
  int ans=0;
  for(int i=0;i<=W;i++){
    ans=max(ans,dp[n][i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 159744
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e3+5;
int a[N];
int main() {
    //freopen("in.txt","r",stdin);
    int n,x,y;
    scanf("%d%d%d",&n,&x,&y);
    for(int i=1;i<=n;i++) {
        for(int j=i+1;j<=n;j++) {
            int t=min(j-i,abs(i-x)+abs(j-y)+1);
            a[t]++;
        }
    }
    for(int i=1;i<n;i++) {
        printf("%d\n",a[i]);
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;

public class Main {
    public static void main(String[] args) throws IOException {
	ReadableByteChannel in = Channels.newChannel(System.in);
	ByteBuffer buf = ByteBuffer.allocate(1000000);
	buf.clear();
	in.read(buf);
	buf.flip();
	int n, m, a;
	while ((n = get(buf)) != 0) {
	    m = get(buf);
	    a = get(buf);
	    int max = 0;
	    int[][] amida = new int[1000][n + 1];
	    for (int i = 0; i < m; i++) {
		int h = get(buf) - 1;
		int p = get(buf);
		int q = get(buf);
		amida[h][p] = q;
		amida[h][q] = p;
		max = Math.max(h, max);
	    }
	    for (int h = max; h >= 0; h--) {
		if (amida[h][a] != 0) {
		    a = amida[h][a];
		}
	    }
	    System.out.println(a);
	}
	in.close();
    }

    private static int get(ByteBuffer buf) {
	int i = buf.get();
	while (i < '0' || '9' < i) {
	    i = buf.get();
	}
	int res = 0;
	while ('0' <= i && i <= '9') {
	    res = res * 10 + (i - '0');
	    i = buf.get();
	}
	return res;
    }
}

Measured memory_bytes: 45104
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  if ((A * B > 0) && (A < 10) && (B < 10)) {
    cout << A * B << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
	getline(cin,a);getline(cin,b);
	sort(a.begin(),a.end());
	sort(b.begin(),b.end(),greater<char>());
	if(a<b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A=sc.nextInt();
        int B= sc.nextInt();
        int C=sc.nextInt();
        int gedoku = A+B;
        int max=0;
        if(gedoku<C) max = gedoku+B+1;
        else if(gedoku==C) max = gedoku+B;
        else max = C+B;
        System.out.println(max);
    }
}

Measured memory_bytes: 23124