akhauriyash/Code-Regression huggingface dataset:
//#include <GOD>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define si size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define E end()
#define B begin()
#define pi pair<int, int>
#define en cout << endl
#define cn const
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

cn int maxv = 1e5 + 10;
ll v[110];
ll w[110];
ll dp[110][maxv];

int main(){
	fast_io;
	int N, W;
	cin >> N >> W;
	for(int i = 0; i < N; i ++)
		cin >> w[i] >> v[i];
		
//	memset(dp, 64, sizeof(dp));
	for(int i = 0; i < N; i ++){
		for(int j = 1; j < maxv; j ++){
			dp[i][j] = INT_MAX;
		}
	}
		
//	cout << "qarrrrrr" << endl;
		
	dp[0][v[0]] = w[0];
	for(int i = 1; i < N; i ++){
		for(int j = 1; j < maxv; j ++){
			if(j >= v[i] && dp[i - 1][j - v[i]] < INT_MAX)
				dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
			dp[i][j] = min(dp[i - 1][j], dp[i][j]);
		}
	} 
//	cout << dp[2][90] << endl;
	
//	cout << "qarrrrrr" << endl;
	
	int ans = 0;
	for(int i = 0; i < maxv; i ++){
		if(dp[N - 1][i] < INT_MAX && dp[N - 1][i] <= W)
			ans = i;
//		cout << dp[N - 1][i] << endl;
	}
	
	cout << ans;
	
	return 0;
}



Measured memory_bytes: 80128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

struct point { int x, y; };

int main()
{
	int W, H, N, x, y, a, ans;
	point left, right;

	cin >> W >> H >> N;
	left.x = 0;
	left.y = 0;
	right.x = W;
	right.y = H;

	rep(i, N) {
		cin >> x >> y >> a;

		switch (a) {
		case 1:
			left.x = max(x, left.x);
			break;
		case 2:
			right.x = min(x, right.x);
			break;
		case 3:
			left.y = max(y, left.y);
			break;
		case 4:
			right.y = min(y, right.y);
		}
	}

	if (left.x >= right.x || left.y >= right.y) ans = 0;
	else ans = (right.x - left.x) * (right.y - left.y);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <cstdio>
typedef long long ll;
ll sum[100005], dp[100005];
int app[200005], seg[800005], mn[100005], mx[100005];
inline void push_down(int u)
{
	if (~seg[u])
	{
		seg[u << 1] = seg[u << 1 | 1] = seg[u];
		seg[u] = -1;
	}
}
void modify(int u, int l, int r, int L, int R, int val)
{
	if (L > R)
		return;
	if (L <= l && r <= R)
	{
		seg[u] = val;
		return;
	}
	push_down(u);
	int m = l + r >> 1;
	if (L <= m)
		modify(u << 1, l, m, L, R, val);
	if (m < R)
		modify(u << 1 | 1, m + 1, r, L, R, val);
}
int query(int u, int l, int r, int pos)
{
	if (l == r)
		return seg[u];
	push_down(u);
	int m = l + r >> 1;
	if (pos <= m)
		return query(u << 1, l, m, pos);
	return query(u << 1 | 1, m + 1, r, pos);
}
int main()
{
	// freopen("AGC011-F.in", "r", stdin);
	memset(seg, -1, sizeof(seg));
	int n, k, cnt = 0;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		if (x << 1 > k && y == 1)
		{
			puts("-1");
			return 0;
		}
		sum[i] = (i ? sum[i - 1] : 0) + x;
		if (y == 2)
			mx[i] = k - 1;
		else
		{
			mn[i] = (-2 * (i ? sum[i - 1] : 0) % k + k) % k;
			mx[i] = (-2 * sum[i] % k + k) % k;
		}
		app[cnt++] = mn[i];
		app[cnt++] = mx[i];
	}
	std::sort(app, app + cnt);
	cnt = std::unique(app, app + cnt) - app;
	for (int i = 0; i < n; i++)
	{
		mn[i] = std::lower_bound(app, app + cnt, mn[i]) - app;
		mx[i] = std::lower_bound(app, app + cnt, mx[i]) - app;
	}
	auto calc = [&] (const int &x) -> ll
	{
		int res = query(1, 0, cnt - 1, x);
		if (-1 == res)
			return 0;
		return dp[res] + (app[mn[res]] - app[x] + k) % k;
	};
	for (int i = n - 1; i >= 0; i--)
	{
		dp[i] = calc(mn[i]);
		if (mn[i] > mx[i])
			modify(1, 0, cnt - 1, mx[i] + 1, mn[i] - 1, i);
		else
		{
			modify(1, 0, cnt - 1, 0, mn[i] - 1, i);
			modify(1, 0, cnt - 1, mx[i] + 1, cnt - 1, i);
		}
	}
	ll ans = dp[0];
	for (int i = 0; i < cnt; i++)
		ans = std::min(ans, calc(i));
	printf("%lld\n", ans + sum[n - 1] * 2);
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  string s;
  cin >> s;

  int i;
  for(i=0;i<s.length();i++){
     if(i%2==1 && (s[i]=='L' || s[i]=='U' || s[i]=='D')) continue;
     else if(i%2==0 && (s[i]=='R' || s[i]=='U' || s[i]=='D')) continue;
     else{
      cout<<"No";
      break;
     }
  }

  if(i==s.length()){
    cout<<"Yes";
  }
  
  return 0;
}


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

int main() {
  string s,t;
  int c=0;

  cin >> s >> t;

  for(int i=0;i<3;i++) {
    if(s[i] == t[i]) {c++;}
  }

  cout << c << endl;

  return 0;
}


Measured memory_bytes: 256
/*  
    And solitare's the only game in town
    And every road that takes him
    Takes him down
    And by himself it's easy to pretend
    He'll never love again
    _________________________
    _________________________
    984 Hours of Solitude
    Quarantine_Day : 41
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;
typedef pair<ll, ll>		pll;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<ll>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 200005

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

    int n; cin>>n;
    int temp = n;
    int sum(0);
    while(temp){
        sum += temp % 10;
        temp /= 10;
    }
    cout<<(n % sum == 0?"Yes\n":"No\n");

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    string s,t; cin >> s >> t; SORT(s); SORT(t); REVERSE(t);
    Yn(s<t);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
void fp(bool flag, string s, string t){
    if(flag)cout << s << endl;
    else cout << t << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a = 1;
    repi(i,2,n + 1){
        a *= i;
        a %= MOD;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
S = [int(input()) for _ in range(n)]

l = []
for s in S:
    if s%10 != 0:
        l.append(s)

a = sum(S)
if a%10 != 0:
    print(a)
else:
    if l:
        print(a-min(l))
    else:
        print(0)


Measured memory_bytes: 38256
#define TEST_MODE true
 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= b; --i)
#define range(i, a, b, c) for (int i = a;             \
                               c > 0 ? i < b : i > b; \
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long
 
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << endl
#else
const bool test = false;
#define dump(x) 
#endif
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while (getline(ss, buffer, sep))
    {
        v.push_back(buffer);
    }
    return v;
}

string reverse_str(string input) {
  string res = input;
  reverse(all(res));
  return res;
}
 
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
    return accumulate(begin, end, 0ll);
}

int H = 20, W = 30;

bool ng(int y, int x) {
    return y < 0 || H <= y || x < 0 || W <= x;
}

void solve();

string dir_str[] = {"RIGHT", "DOWN", "LEFT", "UP"};
bool visited[40][40];

class Solver {
public:
  string s;

  void solve() {
    cin >> s;
	cout << (s == reverse_str(s) ? "Yes" : "No") << endl;
  }
};
 
signed main()
{
    cout << fixed << setprecision(20);
    auto ptr = new Solver();
    ptr->solve();
    delete ptr;
	// while (true) {
	//   auto ptr = new Solver();
	//   ptr->solve();
	//   delete ptr;
    // }
    return 0;
}
 
// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'
 


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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

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

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 dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

struct point {int x, y, cost; };

int H, W;

vector<string> maze(20);

int bfs(point& start)
{
    queue<point> q;
    q.push(start);

    bool used[H][W];
    FILL0(used);
    used[start.y][start.x]=true;

    while(!q.empty())
    {
        point cp = q.front();
        q.pop();
        int x = cp.x;
        int y = cp.y;

        rep(i, 4)
        {   
            if(0<=x+dx[i]&&x+dx[i]<W)
            if(0<=y+dy[i]&&y+dy[i]<H)
            if(maze[y+dy[i]][x+dx[i]]=='.')
            if(!used[y+dy[i]][x+dx[i]])
            {
                point tmp;
                tmp.x=x+dx[i];
                tmp.y=y+dy[i];
                tmp.cost=cp.cost+1;

                q.push(tmp);
                used[y+dy[i]][x+dx[i]]=true;
            }
        }
        if(q.empty())
        {
            return cp.cost;
        }
    }

}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    cin >> H >> W;

    rep(i, H)
    {
        cin >> maze[i];
    }

    point start;
    int max=0;
    rep(i, H)
    {
        rep(j, W)
        {
            if(maze[i][j]=='.')
            {
                start.y = i;
                start.x = j;
                start.cost = 0;
                chmax(max, bfs(start));
            }
        }
    }

  cout << max << endl;
    return 0;
}
 

//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 1e18
#define common cout << "Case #" << w+1 << ": "  



int main()
{
    fastio;
    int d,t,s;
    cin >> d >> t >> s;
    if(s*t>=d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3636
n,k=map(int,input().split())
a=list(map(int,input().split()))
from collections import Counter
c=Counter(a)
c=c.most_common()[::-1]
# print(c)
if len(c)<=k:
  print(0)
  exit()
l=len(c)-k
ans=0
for i in range(l):
  ans+=c[i][1]
print(ans)


  
  

Measured memory_bytes: 39352
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_D&lang=ja
//最長増加部分列
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}

//strict=trueの場合、lower_bound(以上を更新するので,同じ値は含まれない)
//O(nlongn)
template< typename T >
size_t longest_increasing_subsequence(const vector< T > &a, bool strict) {
    vector< T > lis;
    for(auto &p : a) {
        typename vector< T >::iterator it;
        if(strict) it = lower_bound(begin(lis), end(lis), p);
        else it = upper_bound(begin(lis), end(lis), p);
        //終端だと後ろに追加,そうでない場合、lower_boundの位置を更新
        if(end(lis) == it) lis.emplace_back(p);
        else *it = p;
    }
    return lis.size();
}

int main() {
  ll N; cin>>N;
  vector<ll> an(N);
  for(auto&& a:an){
    cin>>a;
  }
  // ll ans=longest_increasing_subsequence(an,true);
  // cout<<ans<<endl;

  vector<ll> lis;
  for(const auto& a:an){
    auto it = lower_bound(lis.begin(),lis.end(),a);
    if(it==lis.end()){
      lis.push_back(a);
    }else{
      *it=a;
    }
  }
  cout<<lis.size()<<endl;
  return 0;
}


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

template <typename T>
struct edge {
    int to;
    T weight;
};

template <typename T>
pair<T, int> dfs(const vector<vector<edge<T>>> &G, int v, int par) {
    pair<T, int> farthest(0, v);
    for(edge<T> e : G[v]) {
        if(e.to == par) continue;
        auto far = dfs(G, e.to, v);
        far.first += e.weight;
        if(farthest.first < far.first) farthest = far;
    }
    return farthest;
}

template <typename T>
T diameter(const vector<vector<edge<T>>> &G) {
    auto far1 = dfs<T>(G, 0, -1);
    auto far2 = dfs<T>(G, far1.second, -1);
    return far2.first;
}

int main() {
    int n; cin >> n;
    vector<vector<edge<int>>> G(n, vector<edge<int>>());
    for(int i = 1; i < n; ++i) {
        int s, t, w;
        cin >> s >> t >> w;
        G[s].push_back({t, w});
        G[t].push_back({s, w});
    }
    cout << diameter<int>(G) << endl;
}



Measured memory_bytes: 17476
#include <bits/stdc++.h>
using namespace std;
#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 ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

using PS = pair<string,int>;

int main(){
	string s;
    int k;
    cin >> s >> k;
    int n = s.size();

    VI v;
    set<int> h;
    set<string> out;

    while(out.size() < k){
        rep(i,n){
            if(h.count(i)) continue;
            if(v.empty()){
                v = {i};
            }else if(s[i] < s[v[0]]){
                v = {i};
            }else if(s[i] == s[v[0]]){
                v.push_back(i);
            }
        }

        for(auto x : v){
            rep2(i,1,6){
                string X = s.substr(x,i);
                out.insert(X);
            }
        }

        for(auto x : v){
            h.insert(x);
        }
        v = {};
    }

    int cnt=0;
    for(auto val : out){
        cnt++;
        if(cnt == k){
            cout << val << endl;
            break;
        }
    }

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std ;
using ll = long long ;

int main(){
	ll n ; cin >> n ;
	vector<ll> a(n),b(n) ;
	for(auto &i:a) cin >> i ;
	for(auto &i:b) cin >> i ;
	ll cnt = 0 ;
	for(int i=0;i<n;i++){
		if(a.at(i)>=b.at(i)) cnt -= a.at(i)-b.at(i) ;
		else cnt += (b.at(i)-a.at(i))/2 ;
	}
	cout << (cnt>=0?"Yes":"No") << endl ;
}


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

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

  int ans = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      for (int k = j; k <= n; k++) {
        if (i + j + k == s){
          if (i == j && j == k)
            ans++;
          else if (i == j || j == k || k == i)
            ans += 3;
          else
            ans += 6;
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

#include <math.h>
#define PI 3.14159265358979323846264338327950L


int main() {
    
    int a, b;
    cin >> a >> b;
    a--;b--;
    vector<bool> f(3, true);
    f[a] = false;
    f[b] = false;
    for (int i = 0; i < 3; i++) {
        if (f[i]) cout << i + 1;
    }
    return 0;
}

Measured memory_bytes: 3568
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    a_list = [a for a in a_list if a % 2 == 0]
    ans = 'APPROVED'
    for a in a_list:
        if a % 3 != 0 and a % 5 != 0:
            ans = 'DENIED'
            break
    print(ans)

if __name__ == "__main__":
    main()    

Measured memory_bytes: 3060
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g $PROGRAM -o $OUTPUT -DLOCAL -lasan -lubsan
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}
typedef vector<char> VC;
typedef vector<VC> VCC;
int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n,m;
	cin>>n>>m;
	
	VCC adj(n,VC(m));
	for(auto &x:adj)
	for(auto &y:x)cin>>y;

	vector<vector<ll>> dp(n,vector<ll>(m,0));
	if(adj[n-1][m-1]=='#'){
		cout<<0;
		return 0;
	}
	dp[n-1][m-1]=1;

	for(int i=n-1;i>=0;--i)
	{
		for(int j=m-1;j>=0;--j)
		{
			if(i-1>=0 && adj[i-1][j]=='.')
			dp[i-1][j]+=(dp[i][j])%MOD;
			if(j-1>=0 && adj[i][j-1]=='.')
			dp[i][j-1]+=(dp[i][j])%MOD;
		}
	}

	cout<<dp[0][0]%MOD;


#ifdef LOCAL
	auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cerr << "\nTime taken by program is : " << fixed
		 << time_taken << setprecision(9);
	cerr << " sec" << endl;
#endif
	return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

const long long MOD = 1000000007;

int main() {
  long long N, K;
  cin >> N >> K;
  long long ans = 0;
  long long dp[100001];
  for(long long i = K; i >= 1; i--) {
    long long a = K / i;
    long long t = N;
    long long temp = 1;
    while(t > 0) {
      if(t & 1) {
        temp = temp * a;
        temp %= MOD;
      }
      a = a * a % MOD;
      t >>= 1;
    }
    // cout << temp << endl;
    for(long long j = i+i; j <= K; j+=i) {
      temp -= dp[j];
    }
    dp[i] = temp;
  }

  rep(i, K) {
    ans += dp[i+1] * (i+1);
    ans %= MOD;
  }

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

Measured memory_bytes: 4380
import sys

a = []

for i in range(3):
    array = list(map(int, input().strip().split()))
    a.append(array)

n = int(input())
for j in range(n):
    tmp = int(input())
    for x in range(3):
        for y in range(3):
            if(a[x][y] == tmp):
                a[x][y] = 0


if a[0][0] == 0 and a[0][1] == 0 and a[0][2] == 0:
    print('Yes')
    sys.exit()
elif a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
    print('Yes')
    sys.exit()
elif a[0][0] == 0 and a[1][0] == 0 and a[2][0] == 0:
    print('Yes')
    sys.exit()
elif a[0][1] == 0 and a[1][1] == 0 and a[2][1] == 0:
    print('Yes')
    sys.exit()
elif a[0][2] == 0 and a[1][2] == 0 and a[2][2] == 0:
    print('Yes')
    sys.exit()
elif a[1][0] == 0 and a[1][1] == 0 and a[1][2] == 0:
    print('Yes')
    sys.exit()
elif a[2][0] == 0 and a[2][1] == 0 and a[2][2] == 0:
    print('Yes')
    sys.exit()
elif a[2][0] == 0 and a[1][1] == 0 and a[0][2] == 0:
    print('Yes')
    sys.exit()
else:
    print('No')
    sys.exit()



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

using namespace std;

int main()
{
	int a,b;
	cin >> a >> b;
	
	if (a <= 0 && b >= 0)
	{
		cout << "Zero" << endl;
	}
	else if (a > 0 && b > 0)
	{
		cout << "Positive" << endl;
	}
	else if (a == 0 || b == 0)
	{
		cout << "Zero" << endl;
	}
	else
	{
		if ((abs(a) - abs(b) + 1) % 2 == 0)
		{
			cout << "Positive" << endl;
		}
		else
		{
			cout << "Negative" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

constexpr int mod = 1000000007;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, 0, n) {
    int a;
    cin >> a;
    v[a]++;
  }

  int start = (n & 1) ? 2 : 1;
  if (n & 1 && v[0] != 1) {
    cout << 0 << endl;
    return 0;
  }

  for (int i = start; i < n; i += 2) {
    if (v[i] != 2) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = 1;
  rep(i, 1, n / 2 + 1) {
    ans *= 2;
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main()
{
    f_io;
    ll n,w;
    cin >> n >> w;
    vector<pair<ll,ll> > arr(n);
    foi(0,n)
        cin >> arr[i].first >> arr[i].second;
    vector<ll> dp(w+1);
    foi(0,n)
    {
        for(ll j=w;j>=0;j--)
        {
            if(j-arr[i].first>=0)
                dp[j] = max(dp[j],dp[j-arr[i].first]+arr[i].second);
        }
    }
    cout << dp[w];
    return 0;
}


Measured memory_bytes: 3992
import java.util.Scanner;
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 X = sc.nextInt();
		int[][][] price = new int[A+1][B+1][C+1];

		int way = 0;

		for(int i=0; i<=A; i++) {
			for(int j=0; j<=B; j++) {
				for(int k=0; k<=C; k++) {
					price[i][j][k] = 500*i + 100*j + 50*k;
					if(price[i][j][k] == X) {
						way += 1;
					}
				}
			}
		}

		System.out.println(way);
	}

}


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

int main(void)
{
  long long n, b, r;
  cin >> n >> b >> r;
  int64_t cnt = n / (b + r);
  int64_t odd = n % (b + r);
  int64_t total = 0;
  if(odd >= b)
  {
    total += b;
  }else{
    total += odd;
  }
  total += cnt * b;
  cout << total << endl;
}

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

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

using namespace std;

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

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

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

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	int T[110];
	rep(i, 0, N)
	{
		cin >> T[i];
	}

	int M;
	cin >> M;

	int P, X;
	rep(i, 0, M)
	{
		cin >> P >> X;
		P--;
		int res = 0;
		rep(j, 0, N)
		{
			if (j == P)
			{
				res += X;
			}
			else
			{
				res += T[j];
			}
		}
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int n;
vector<ll> sum;

ll memo[410][410];
ll rec(int l, int r){
  if(l == r)return 0;
  if(memo[l][r] != -1)return memo[l][r];

  ll ans = LINF;
  for(int i = l; i < r; ++i){
    ans = min(ans, rec(l, i) + rec(i + 1, r) + sum[r + 1] - sum[l]);
  }
  return memo[l][r] = ans;
}

int main(){
  cin >> n;
  vector<ll> a(n);
  sum.assign(n + 1, 0);
  for(int i = 0; i < n; ++i){
  	cin >> a[i];
  	sum[i + 1] = sum[i] + a[i];
  }

  fill((int*)memo, (int*)memo + sizeof(memo) / sizeof(int), -1);
  cout << rec(0, n - 1) << endl;

  return 0;
}


Measured memory_bytes: 1536
#define _CRT_SECURE_NO_WARNINGS
using namespace std;
#include <stdio.h>
#include <iostream>
#include <limits>
#include <string>
#include <vector>
#include <iterator>
#include <numeric>
#include <algorithm>

int main() {
	int a;
	cin >> a;
	cout << ((a == 1) ? "0" : "1");
	return 0;
}


Measured memory_bytes: 3636
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=1e5+5;



int main()
{ 

IOS;

ll m1,d1;

cin>>m1>>d1;

vl t={31,28,31,30,31,30,31,31,30,31,30,31};

m1--;

if(t[m1]==d1)cout<<1;
else cout<<0;

//end_routine();

return 0;
 
}


Measured memory_bytes: 3648
require 'set'
suits = %w(S H C D)
deck = Hash[suits.map {|s| [s, Set[*(1..13).to_a]] }]
n = gets.to_i
n.times do
  s, i = gets.chomp.split
  deck[s].delete(i.to_i)
end
suits.each do |s|
  deck[s].each do |i|
    puts "#{s} #{i}"
  end
end


Measured memory_bytes: 6980
open Hashtbl
let n = read_int ()
let ws = Array.init n @@ fun _ -> read_line ()
let h = create n
let _ = Array.fold_left (fun p w -> if mem h w || p <> w.[0] then (print_endline "No"; exit 0); add h w 1; w.[String.length w - 1]) ws.(0).[0] ws |> ignore; print_endline "Yes"

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
int main(){
    int n;
    cin >> n;
    for(int a = 1; a <= 3500; ++a)
        for(int b = a; b <= 3500; ++b){
            // 1/n -1/a -1/b = 1/c
            int c = floor(1.0/(4.0/n-1.0/a-1.0/b)+0.5);
            if(c <= 0)
                continue;
            // 1/n = 1/a + 1/b + 1/c
            //n*(bc+ac+ab) = abc
            ll test = 4*(ll)a*b*c - (ll)n*(b*c+a*c+a*b);
            if(test == 0){
                cout << a << ' ' << b << ' ' << c << '\n';
                return 0;
            }
        }
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;
#define rep(i,s,e) for(int i = (int)(s); i < (int)(e); ++i)
#define per(i,s,e) for(int i = (int)(s)-1; i >= (int)(e); --i)

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  ll k; cin >> k;
  vector<int> v(n);
  cin >> v;
  vector<set<int>> sv(200001);
  rep(i,0,n) sv[v[i]].insert(i);
  int cnt = 1;
  {
    int p = n-1;
    while(1){
      int val = v[p];
      auto it = lower_bound(sv[val].begin(), sv[val].end(), p);
      if(it == sv[val].begin()){
	cnt++;
	it = sv[val].end();	
      }
      it--;      
      p = *it;
      if(p == 0) break;
      p--;      
    }
  }
  int t = k % cnt;
  cnt = 1;
  int p = 0;
  vector<int> ans; 
  while(1){

    int val = v[p];

    auto it = upper_bound(sv[val].begin(), sv[val].end(), p);
    if(it == sv[val].end()){
      if(cnt >= t){
	p++;
	ans.push_back(val);
	if(p>=n)break;
	continue;
      } else {
	cnt++;
	it = sv[val].begin();
      }
    }
    p = *it;
    p++;
    if(p>=n){
      if(cnt>=t){
	break;
      }
      cnt++;
      p=0;
    }    
  }
  rep(i,0,ans.size()){
    if(i)cout << ' ';
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


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

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

    int ans = 1;
    int l = 0;
    int d = 0;
    for (int i = 0; i < n; ++i) {
        cin >> l;
        int tmp = d + l;
        if (tmp <= x) {
            ans++;
            d = tmp;
        } else {
            break;
        }
    }
    cout << ans << endl;
}



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

int N, M;
int x, y;

int main(int argc, char* argv[]){
  scanf("%d %d", &N, &M);
  vector<int>num(N+1,1);
  vector<bool>red(N+1,false);
  red[1]=true;
  for(int i=0; i<M; i++){
	scanf("%d %d", &x, &y);
	if(red[x]) red[y]=true;
	num[x]--;
	num[y]++;
	if(num[x]==0) red[x]=false;
  }
  int count = 0;
  for(int i = 1; i <= N; i++) if(red[i]) count++;
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;
int inf = 2e9, mod = 1e9 + 7;

int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int n,res = 0; cin >> n;
    if(n == 1) return cout << n << endl, 0;
    if(n == 2) return cout << n * n % mod<< endl, 0;
    vi dp(n);
    dp[0] = dp[1] = 1;
    res = (n-1 + (n-1) * (n-1) * 2) % mod;
    for(int i = 2, tmp = 1;i < n;i++){
        dp[i] = tmp % mod;
        res = (res + dp[i] * (n-1) % mod * (i == n-1 ? 1 : (n-1)) % mod) % mod;
        res = (res + (n-1) * dp[i-1] % mod) % mod;
        tmp = (tmp + dp[i] + dp[i-2] - dp[i-1] + mod) % mod;
    }
    cout << (res + 1) % mod << endl;
    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

using Graph = vector<vector<int>>;

int dfs(Graph &graph, vector<int> &d, vector<int> &f, int cur, int time)
{
    if(d[cur] > 0) return time;
    d[cur] = time;
    time++;
    for(int child : graph[cur])
    {
        time = dfs(graph, d, f, child, time);
    }
    f[cur] = time;
    time++;
    return time;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    Graph graph(n);
    REP(i, n) 
    {
        int u, k;
        cin >> u >> k;
        REP(j, k) 
        {
            int v;
            cin >> v;
            graph[u-1].push_back(v-1);
        }
    }

    vector<int> d(n, 0), f(n, 0);
    int time = 1;
    REP(i, n)
    {
        if(d[i] > 0) continue;
        time = dfs(graph, d, f, i, time);
    }

    REP(i, n)
    {
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
}


Measured memory_bytes: 3152
#include<cstdio>
int main(){
	int n,a[100000],m=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]%2==1){
			m++;
		}
	}
	if(m%2==0){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct node
{
	int id,v;
	node(int x1=0,int x2=0){v=x1,id=x2;}
};
stack<node> s;
int n,m;
int a[5001];
int sum[5001];
int v[5001][201];
int pre[5001][201];
int nxt[5001][201];
int res[5010][5010];
void add(int x,int x1,int y,int y1,int ind)
{
	res[x][y]+=ind;
	res[x][y1+1]-=ind;
	res[x1+1][y]-=ind;
	res[x1+1][y1+1]+=ind;
}
void calc()
{
	for(int i=1;i<=n;i++)
		res[0][i]+=res[0][i-1],res[i][0]+=res[i-1][0];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			res[i][j]=res[i-1][j]+res[i][j-1]+res[i][j]-res[i-1][j-1];
}
signed main()
{
	scanf("%lld%lld",&n,&m);
	for(int i=2;i<=n;i++)
		scanf("%lld",&a[i]),sum[i]=sum[i-1]+a[i];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%lld",&v[i][j]);
	for(int j=1;j<=m;j++)
	{
		for(int i=1;i<=n;i++)
		{
			while(!s.empty()&&s.top().v<=v[i][j])
			{
				nxt[s.top().id][j]=i-1;
				s.pop();
			}
			pre[i][j]=(s.empty()?0:s.top().id)+1;
			s.push(node(v[i][j],i));
		}
		while(!s.empty())
		{
			nxt[s.top().id][j]=n;
			s.pop();
		}
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			add(pre[i][j],i,i,nxt[i][j],v[i][j]);
	calc();
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)
			ans=max(ans,res[i][j]-sum[j]+sum[i]);
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 220032
N = int(input())
s = {}
t = {}
for i in range(N):
    k = input()
    if k not in s.keys():
        s[k] = 0
        t[k] = 0
    s[k] += 1

M = int(input())

for i in range(M):
    k = input()
    if k not in t.keys():
        t[k] = 0
    t[k] += 1

ans = 0
for k in s.keys():
    ans = max(ans , s[k] - t[k])
print(ans)


Measured memory_bytes: 38512
N, X = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

def calc(A, X):
    a = A[:]
    r = 0
    for i in range(len(A) - 1):
        t = a[i] + a[i + 1]
        if t > X:
            d = t - X
            if d <= a[i + 1]:
                r += d
                a[i + 1] -= d
            else:
                r += d - a[i + 1] + a[i + 1]
                a[i] -= d - a[i + 1]
                a[i + 1] = 0
    #print(a)
    return r

result = calc(A, X)

print(result)


Measured memory_bytes: 14428
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
    int n;
    std::cin >> n;
    std::vector<int> v(n);
    for( int& t : v ){
        std::cin >> t;
    }
    std::sort( v.begin(), v.end() );
    std::cout << *(v.end()-1) - *(v.begin()) << std::endl;
    return 0;
}


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

int main(){
	int N;
	cin >> N;
	vector<int> a(N+1);
	for(int i(1);i<N+1;++i) cin >> a[i];
	int b_sum;
	vector<int> b(N+1,0);
	for(int i(N);i>=1;--i){
		b_sum = 0;
		for(int j(i);j<=N;j+=i){
			b_sum += b[j];
		}
		if(b_sum%2 != a[i]){
			b[i] = 1;
		}
	}
	// for(int i(1);i<N+1;++i){
	// 	if(b[i]%2 != a[i]){
	// 		cout << '-1' << endl;
	// 		return 0;
	// 	}
	// }
	int M(0);
	for(int i(1);i<N+1;++i){
		if(b[i] == 1) M++;
	}
	cout << M << endl;
	if(M > 0){
		for(int i(1);i<N+1;++i){
			if(b[i]) cout << i << ' ';
		}
	}
	return 0;
}

Measured memory_bytes: 2432
#include <stdio.h>
int main (){
	
	char s[100000];
	int count = 0;
	

		scanf("%s", &s);
	
	
	for (int j = 0; s[j+1] != '\0'; j++){
		if(s[j] == s[j+1] && s[j] == s[j-1]){
//		if(s[j] == s[j+1]){
			if(s[j] == '0'){
				s[j] = '1';
			}
			else{
				s[j] = '0';
			}
			count++;
		}
		else if(s[j] == s[j+1] && s[j] != s[j-1]){
			if(s[j+1] == '0'){
				s[j+1] = '1';
			}
			else{
				s[j+1] = '0';
			}
			count++;
	   	}
	}
	
	
	printf("%d", count);
	
	
	
	
	
	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 rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int factorial(int n)
{
    if (n == 0)
        return 1;
    return n * factorial(n - 1);
}

int main()
{
    int n;
    cin >> n;
    vll a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    sort(all(a));
    int A = a[n-1], B = 0;
    rep2(i, 1, n)
    {
        if (abs((double)A / (double)2 - B) > abs((double)A / (double)2 - a[i]))
        {
            B = a[i];
        }
    }
    cout << A << " "<< B;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 1000
using namespace std;
int main() {
  ll cnt = 0;
  ll n = 0;
  ll a, b;
  cin >> n;
  while (n--) {
    cin >> a >> b;
    cnt += b - a + 1;
  }
  cout << cnt << endl;
  return 0;
}


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

typedef long long int ll;

ll pow(ll x, ll n, ll M){
	ll res=1;
  	if(n>0){
      res=pow(x,n/2,M);
      if(n%2==0){
      	res=(res*res)%M;
      }
      else{res=(((res*res)%M)*x)%M;}
    }
      return res;
    }

ll COMBI(ll n, ll x) {
    ll p=1,q=1,res=1;
    for(long int i=0; i<x;i++) {
     	p=p*(n-i)%1000000007;
      	q=q*(i+1)%1000000007;
    }

    return p*pow(q,1000000005,1000000007) % 1000000007;
}
int main() {


	ll n,a,b;
    cin >>n>>a>>b;
    long long int ans;
    ans=pow(2,n,1000000007)-1;
  	ans=ans+1000000007*2;
  	ans=ans-COMBI(n,a)-COMBI(n,b);
  	ans=ans%1000000007;
  	cout<<ans;
}





Measured memory_bytes: 256