akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int n,m,cnt;
vector<int> v[101010];
bool used[101010];
ll a[101010];
int color[101010];
map<pint,ll> mp;
bool nibu;

bool dfs(int x){
    bool ok=true;
    for(auto to:v[x]){
        if(!used[to]){
            a[to]=mp[{x,to}]-a[x];
            color[to]=-color[x];
            used[to]=true;
            ok=dfs(to);
        }
        else{
            if(color[to]!=color[x]){
                if(mp[{to,x}]!=a[to]+a[x])ok=false;
            }
            else{
                nibu=false;
                if(mp[{to,x}]==a[to])continue;
                if(cnt>0)ok=false;
                else {
                    if((mp[{to,x}]-a[to]-a[x])%2)ok=false;
                    else {
                        cnt++;
                        ll r=(mp[{to,x}]-a[to]-a[x])/2+a[x];
                        rep(i,n)color[i]=0;
                        rep(i,n)used[i]=0;
                        rep(i,n)a[i]=0;
                        a[x]=r;
                        color[x]=1;
                        used[x]=1;
                        ok=true;
                        ok=dfs(x);
                    }
                }
            }
        }
    }
    return ok;
}

int main(){
   cin>>n>>m;
   rep(i,m){
       int x,y,z;
       cin>>x>>y>>z;
       x--;y--;
       v[x].push_back(y);
       v[y].push_back(x);
       mp[{x,y}]=z;
       mp[{y,x}]=z;
   }
   a[0]=1;
   color[0]=1;
   used[0]=true;
   nibu=true;
   dfs(0);
   for(auto x:mp){
       if(a[x.first.first]+a[x.first.second]!=x.second){
           cout<<0<<endl;
           return 0;
       }
   }
   if(nibu){
       ll mi1=longinf,mi0=longinf;
       rep(i,n){
           if(color[i]==1)mi1=min(mi1,a[i]);
           if(color[i]==-1)mi0=min(mi0,a[i]);
       }
       cout<<max(0LL,mi1+mi0-1)<<endl;
   }
   else{
       ll mi=longinf;
       rep(i,n)mi=min(mi,a[i]);
       if(mi>0)cout<<1<<endl;
       if(mi<=0)cout<<0<<endl;
   }
   return 0;
}


Measured memory_bytes: 37888
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
#include <deque>
#include <math.h>
#include <tgmath.h>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

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

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

//fast power
ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

ll comb2(ll a) {
    ll b = a / 2;
    if (a % 2) {
        b = (a - 1) / 2;
        return (b * a);
    }
    return (b * (a - 1));
}

int dfs(int x, int y, int z) {
    if (x == a && y == b && z == c) return 1;
    
    int ans = 0;
    if (x != a) ans += dfs(x + 1, y, z);
    if (x >= y + 1/* && y != b*/) ans += dfs(x, y + 1, z);
    if (y >= z + 1/* && z != c*/) ans += dfs(x, y, z + 1); 

    return ans;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;

    unsigned long long int aa = 0;
    rep(i, 0, n + 1) {
        if (i % 3 != 0 && i % 5 != 0) {
            aa += i;
        }
    }

    cout << aa << endl;


    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)++)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define input(x) x; cin >> x;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using pii = pair<int, int>;

int main(){
  int input(n);
  int input(l);
  string list_input(a, n);
  sort(a, a + n);
  for(string s: a) cout << s;
  cout << endl;
}


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

using namespace std;

constexpr int MAXN = 2e5 + 5;

template <typename T>
inline void read(T& x, T f = 1, char ch = getchar()) {
    x = 0;
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

int tc, n, m;
array<int, MAXN> a;

signed main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    int cnt = 0, ans = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'R') cnt++, ans = max(ans, cnt);
        else cnt = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
struct point{
	int x,y;
	point operator - (const point p){
		point pp;
		pp.x=x-p.x;
		pp.y=y-p.y;
		return pp;
	}
}p0,p1,p2;
double waiji(point p1,point p2){
	return p1.x*p2.y-p1.y*p2.x;
}
double neiji(point p1,point p2){
	return p1.x*p2.x+p1.y*p2.y;
}
void solve(){
	double xc=waiji(p1-p0,p2-p0);	
	if(xc>0){cout<<"COUNTER_CLOCKWISE"<<endl;return;}
	if(xc<0){cout<<"CLOCKWISE"<<endl;return;}
	if(neiji(p1-p0,p2-p0)<0){cout<<"ONLINE_BACK"<<endl;return;}
	if(abs(p1.x-p0.x)<abs(p2.x-p0.x)||abs(p1.y-p0.y)<abs(p2.y-p0.y)){cout<<"ONLINE_FRONT"<<endl;return;}
	cout<<"ON_SEGMENT"<<endl;
}
int main(){
	cin>>p0.x>>p0.y;
	cin>>p1.x>>p1.y;
	int T; cin>>T;
	while(T--){
		cin>>p2.x>>p2.y;
		solve();
	}
	return 0;
}



Measured memory_bytes: 3108
N,K = map(int,input().split())
sunuke_list=[str(i) for i in range(1,N+1)]
for i in range(K):
  d=int(input())
  kasi_list = list(map(str,input().split()))
  for j in kasi_list:
    try:
	    sunuke_list.remove(j)
    except:
      pass
    

print(len(sunuke_list))

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
 
int n, m, d[1001][1001], a[1001][1001], xs, ys, xf, yf;
bool inque[1001][1001];
deque<pair<int, int>> coada;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
 
bool in(int x, int y) {
    return x >= 1 && x <= n && y >= 1 && y <= m;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    cin >> xs >> ys;
    cin >> xf >> yf;
    for(int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        for(int j = 1; j <= m; j++) {
            d[i][j] = n * m;
            if(s[j - 1] == '.') {
                a[i][j] = 1;
            } else {
                a[i][j] = 0;
            }
        }
    }
    d[xs][ys] = 0;
    inque[xs][ys] = 1;
    coada.push_back(make_pair(xs, ys));
    while(!coada.empty()) {
        int x = coada.front().first;
        int y = coada.front().second;
        inque[x][y] = 0;
        coada.pop_front();
        for(int i = 0; i < 4; i++) {
            int newx = x + dx[i];
            int newy = y + dy[i];
            if(in(newx, newy) && a[newx][newy] && d[newx][newy] > d[x][y]) {
                d[newx][newy] = d[x][y];
                if(!inque[newx][newy]) {
                    inque[newx][newy] = 1;
                    coada.push_front(make_pair(newx, newy));
                }
            }
        }
        for(int i = max(x - 2, 1); i <= min(x + 2, n); i++) {
            for(int j = max(y - 2, 1); j <= min(y + 2, m); j++) {
                if(abs(i - x) + abs(j - y) > 1 && a[i][j] && d[i][j] > d[x][y] + 1) {
                    d[i][j] = d[x][y] + 1;
                    if(!inque[i][j]) {
                        inque[i][j] = 1;
                        coada.push_back(make_pair(i, j));
                    }
                }
            }
        }
    }
    if(d[xf][yf] == n * m) {
        cout << -1;
    } else {
        cout << d[xf][yf];
    }
    return 0;
}

Measured memory_bytes: 12432
#pragma region Template
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "../../../debug_print.hpp"
#else
#define debug(...)
#endif
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}
#pragma endregion Template

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

    int h, w, n;
    scan(h, w, n);

    int a = n / h;
    a += n % h == 0 ? 0 : 1;
    int b = n / w;
    b += n % w == 0 ? 0 : 1;
    print(min(a, b));

    return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))
ans = 0
from itertools import combinations
# combinations('ABCD', 2) --> AB AC AD BC BD CD
# combinations(range(4), 3) --> 012 013 023 123
combi_list = list(combinations(L,2))
for i in combi_list:
    ans += i[0] * i[1]
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<vector>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
	vector<int> v;
	for( int i=0; i<10; i++)
	{
		int n;
		cin>>n;
		v.push_back(n);
	}
	
	sort( v.begin(), v.end(), greater<int>() );

	cout << v[0] << endl ;
	cout << v[1] << endl ;
	cout << v[2] << endl ;

	return 0;
}

Measured memory_bytes: 1216
package main

import "fmt"

func main() {
	var n int
	var div int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	loop := true
	for loop {
		for i, v := range a {
			if v%2 == 1 {
				loop = false
			}
			a[i] = a[i] / 2
		}
		if loop {
			div++
		}
	}
	fmt.Println(div)
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 10010;
const int MAXP = 10000000;
const u64 MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const int INF = 1000000010;

int n;
int p[MAXN];

int main()
{
	
	int a, b;
	cin >> a >> b;
	cout << a+b/2 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define pb          emplace_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define Max(a,b)    ((a)>(b)?(a):(b))
#define Min(a,b)    ((a)<(b)?(a):(b))
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<(b);i+=1)
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define debug(a)    cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
using namespace std;

void solve(){
    int N;
    cin>>N;
    N*=2;
    vi x(N);
    rep(i,0,N)cin>>x[i];
    sort(all(x));
    ll ans=0;
    rep(i,0,N/2){
        ans+=x[2*i];
    }
    cout<<ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define endl "\n"
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e2+4;

int main()                  
{
	int x,y; scn(x); scn(y);

	if(y>=2*x and (y-2*x)%2==0 and (y-2*x)/2<=x)
	printf("Yes");
	else
	printf("No");
} 

Measured memory_bytes: 3824
#include<iostream>
#include<sstream>
#include<iomanip>
#include<bitset>
#include<cmath>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<limits.h>
using namespace std;

typedef long long LL;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int MAXN=2e5+10;
int a[MAXN];

bool cmp(int x,int y){
    return x>y;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;++i)
        cin>>a[i];
    if(k>=n)
        cout<<0<<endl;
    else {
        sort(a, a + n, cmp);
        LL ans=0;
        for(int i=k;i<n;++i)
            ans+=a[i];
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(void){
    
    int N;  cin >> N;
    vector<int> C(N), S(N), F(N);

    for(int i = 0 ; i < N - 1 ; i++){
        int c, s, f;  cin >> c >> s >> f;
        C[i] = c, S[i] = s, F[i] = f;
    }

    for(int i = 0 ; i < N ; i++){
        int t = 0;
        for(int j = i ; j < N - 1; j++){
            if(t < S[j])  t = S[j];
            else if(t % F[j] == 0);
            else   t = t + F[j] - t % F[j];

            t += C[j];
        }
        cout << t << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)


class UnionFind(object):
    def __init__(self, n):
        self.parent = list(range(n))
        self.size = [1] * n

    def root(self, a):
        p = self.parent[a]
        if p == a:
            return a
        q = self.root(p)
        self.parent[a] = q
        return q

    def merge(self, a, b):
        '''merge a into b'''
        a = self.root(a)
        b = self.root(b)
        if a == b:
            return False
        self.parent[a] = b
        self.size[b] = self.size[a] + self.size[b]
        return True

    def get_size(self, a):
        a = self.root(a)
        return self.size[a]


def main():
    n, m = map(int, input().split())
    tree = [[int(a)-1 for a in input().split()] for _ in range(m)]
    uf = UnionFind(n)
    sep = []
    sep_prev = n * (n - 1) // 2
    for a, b in tree[::-1]:
        asize = uf.get_size(a)
        bsize = uf.get_size(b)
        sep.append(sep_prev)
        success = uf.merge(a, b)
        if success:
            sep_prev -= asize * bsize

    for s in sep[::-1]:
        print(s)


main()


Measured memory_bytes: 42228
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int main()
{
  int N,M;
  cin >> N >> M;
  long long D[110][110];
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      if(i!=j){
        D[i][j]=INF;
      }else{
        D[i][j]=0;
      }
    }
  }

  int path[1010][3];
  for(int i=0;i<M;++i){
    int a,b,c;
    cin >> a >> b >> c;
    D[a-1][b-1] = c;
    D[b-1][a-1] = c;
    path[i][0] = a-1;
    path[i][1] = b-1;
    path[i][2] = c;
  }

  for(int k=0;k<N;++k){
    for(int i=0;i<N-1;++i){
      for(int j=i+1;j<N;++j){
        D[i][j] = min(D[i][j],D[i][k]+D[j][k]);
        D[j][i] = D[i][j];
      }
    }
  }

  int ans = 0;
  for(int i=0;i<M;++i){
    if(path[i][2] > D[path[i][0]][path[i][1]]){
      ans += 1;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
# coding: -utf8
N,A,B = input().split(" ")
N = int(N)
A = int(A)
B = int(B)
NC = [0,0,0,0,0]

answer = 0
for i in range(N+1):
  NC[4] = i // 10000
  NC[3] = (i - NC[4] * 10000)// 1000
  NC[2] = (i - NC[4] * 10000 - NC[3] *1000) // 100
  NC[1] = (i - NC[4] * 10000 - NC[3] *1000 - NC[2] * 100) //10
  NC[0] = i % 10
  sum = 0
  for j in range(5):
    sum = sum + NC[j]
  if(A <= sum and sum <= B):
    answer = answer + i
print(answer)

Measured memory_bytes: 3064
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef float f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
const int mod=998244353;
//const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
void solve() {
	int a,b,c,d,e,f,g;
	cin>>a>>b>>c>>d>>e>>f>>g;
	int ans=(a/2)*2+b+(d/2)*2+(e/2)*2;
	a--;
	d--;
	e--;
	if(a>=0&&d>=0&&e>=0)
	ans=max(ans,(a/2)*2+b+(d/2)*2+(e/2)*2+3);
	cout<<ans<<endl;
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vi p(n),q(n),num(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  rep(i,n) num[i] = i+1;
  int a,b, cnt = 0;
  do{
    cnt++;
    bool ok1 = true, ok2 = true;
    rep(i,n){
      if(num[i] != p[i]) ok1 = false;
      if(num[i] != q[i]) ok2 = false;
    }
    if(ok1) a = cnt;
    if(ok2) b = cnt;
  }while(next_permutation(all(num)));
  cout << abs(a-b);
  cout << endl;
  return 0;
}


Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, k;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	int cnt = n / k;
	long long ans = 0;
	for (int i = 1; i <= min(cnt, 3); i++) {
		if (i == 1) ans += cnt;
		if (i == 2) ans += cnt * 1LL * (cnt - 1) * 3;
		if (i == 3) ans += cnt * 1LL * (cnt - 1)*(cnt - 2);
	}
	if (k % 2 == 0) {
		if (n%k >= k / 2) cnt++;
		for (int i = 1; i <= min(cnt, 3); i++) {
			if (i == 1) ans += cnt;
			if (i == 2) ans += cnt * 1LL * (cnt - 1) * 3;
			if (i == 3) ans += cnt * 1LL * (cnt - 1)*(cnt - 2);
		}
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const ll mod=998244353;
int main()
{
	ll x;
	scl(x);
	pf("%lld\n",x/500*1000+x%500/5*5);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main() {
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    for (auto& i : l) cin >> i;
    sort(l.begin(), l.end(), greater<int>());
    cout << accumulate(l.begin(), l.begin() + K, 0) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(void) {
 
	int a= 0;
	int b= 0;
	int c= 0;
  
	
	scanf("%d %d %d", &a, &b, &c);

	if(a < b && b < c){
	printf("Yes\n");

}
	else{
	printf("No\n");

}
 
	
return 0;

}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;



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

    ll n, K; cin >> n >> K;
    vector<ll> a(n);
    for(int i=0; i<n; ++i) cin >> a[i];

    vector<ll> bit_stand(40, 0);
    for(int i=0; i<40; ++i){
        for(int j=0; j<n; ++j) if(a[j]&1LL<<i) ++bit_stand[i];
    }

    ll ans = 0;
    for(int k=40; k>=-1; --k){
        if(k>=0 && (K&(1LL<<k)) == 0) continue;

        ll tmp = 0;
        // seeing from left, to first bit which is '1' in K, and '0' in x
        for(int d=40; d>k; --d){
            if(K&1LL<<d) tmp += (1LL<<d)*(n-bit_stand[d]);
            else tmp += (1LL<<d)*bit_stand[d];
        }

        // d == k
        if(k != -1) tmp += (1LL<<k)*bit_stand[k];

        for(int d=k-1; d>=0; --d){
            tmp += max(bit_stand[d], n-bit_stand[d])*(1LL<<d);
        }

        chmax(ans, tmp);

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
primes = [0, 0] + [1] * 999999
for i in range(2, 1001):
    if primes[i]:
        for j in range(i*i, 1000001, i):
            primes[j] = 0

while True:
    a, d, n = map(int, input().split())
    if not a:
        break
    cnt = 0
    while True:
        if primes[a]:
            cnt += 1
        if cnt == n:
            break
        a += d
    print(a)

Measured memory_bytes: 22840
import itertools
n = int(input())
s = []
c=0
for i in range(n):
    s.append(input()[0])
seq = list(itertools.combinations(["M","A","R","C","H"],3))
for l in seq:
    c += s.count(l[0])*s.count(l[1])*s.count(l[2])
print(c)

Measured memory_bytes: 3896
s = input().strip()
t = input().strip()

dp = [[0 for _ in range(3100)] for _ in range(3100)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])

ans = ""
i = len(s)
j = len(t)
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = s[i-1] + ans
        i -= 1
        j -= 1

print(ans)



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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li n;

    cin>>n;

    li a[n],b[n],c[n-1];

    f(i,0,n-1)
    {
        cin>>a[i];
    }   

    f(i,0,n-1)
    {
        cin>>b[i];
    }   
    
    f(i,0,n-2)
    {
        cin>>c[i];
    }   

    li ans=0;

    f(i,0,n-1)
    {
        ans+=b[a[i]-1];

        if(i<n-1)
        {
            if(a[i+1]-1==a[i])
                ans+=c[a[i]-1   ];
        }
    }
    cout<<ans;
}   


int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
template<typename T>
T add(T x) {
  return x;
}
template<typename T, typename... Ts>
T add(T x, Ts... y) {
  T res = x + add(y...);
  if (res >= mod)
    res -= mod;
  return res;
}
template<typename T, typename... Ts>
T sub(T x, Ts... y) {
  return add(x, mod - add(y...));
}
template<typename T, typename... Ts>
void udd(T& x, Ts... y) {
  x = add(x, y...);
}
template<typename T, typename... Ts>
void uub(T& x, Ts... y) {
  x = sub(x, y...);
}
template<typename T>
T mul(T x) {
  return x;
}
template<typename T, typename... Ts>
T mul(T x, Ts... y) {
  return (x * 1ll * mul(y...)) % mod;
}
template<typename T, typename... Ts>
void uul(T& x, Ts... y) {
  x = mul(x, y...);
}
int bin(int a, ll deg) {
  int r = 1;
  while (deg) {
    if (deg & 1)
      uul(r, a);
    deg >>= 1;
    uul(a, a);
  }
  return r;
}
int inv(int x) {
  assert(x);
  return bin(x, mod - 2);
}

int d[3][3];
int nd[3][3];

void go(int& n0, int& n1, int c) {
  if (c == 0) {
    ++n0;
    if (n0 == 3) {
      n0 -= 2;
    }
  } else if (c == 1) {
    if (n0 > 0) {
      --n0;
    } else {
      ++n1;
      n1 = min(n1, 2);
    }
  }
}

signed main() {
#ifdef LOCAL
  assert(freopen("e.in", "r", stdin));
#endif
  string s;
  cin >> s;
  d[0][0] = 1;
  for (auto c : s) {
    memset(nd, 0, sizeof(nd));
    for (int n0 = 0; n0 < 3; ++n0) {
      for (int n1 = 0; n1 < 3; ++n1) {
        if (c != '1') {
          int x = n0, y = n1;
          go(x, y, 0);
          udd(nd[x][y], d[n0][n1]);
        }
        if (c != '0') {
          int x = n0, y = n1;
          go(x, y, 1);
          udd(nd[x][y], d[n0][n1]);
        }
      }
    }
    memcpy(d, nd, sizeof(nd));
  }
  int res = 0;
  for (int n0 = 0; n0 < 3; ++n0) {
    for (int n1 = n0; n1 < 3; ++n1) {
      udd(res, d[n0][n1]);
    }
  }
  cout << res << '\n';
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
const ll M=1000000000;
//------------------------------------------//

int main(){
  int a,b;cin>>a>>b;
  cout<<(b-a)*(b-a-1)/2-a<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define Pi 3.1415926535
#define MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}

int solve(){
    double l; cin >> l;
    l /= 3;
    cout << l*l*l << endl;

    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        Console.WriteLine(
            n[2] > n[1] + n[0] ? "dangerous" :
            n[2] > n[1] ? "safe" :
            "delicious");
    }
}


Measured memory_bytes: 13268
n=int(input())
s=[list(map(int, input().split())) for i in range(n-1)]
#sum=移動時間  x=乗り換え時間

for i in range(n):
    t=0
    for j in range(i,n-1):
        if t<=s[j][1]:
            t=s[j][0]+s[j][1]
        else:
            if t%s[j][2]==0:
                t+=s[j][0]
            else:
                t+=s[j][0]+(s[j][2]-t%s[j][2])
    print(t)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n ;
  cin >> n ;
  vector <int> a(n) ;
  for ( int i=0 ; i<n ; i++){
    cin >> a.at(i) ;
  }
  sort ( a.begin() , a.end() ) ;
  cout << a.at(n/2) - a.at(n/2 - 1) << endl;
}

Measured memory_bytes: 3732
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let n, k = Scanf.sscanf (read_line ()) "%d %d" ( fun n k -> n, k)
let lst = Str.split (Str.regexp " ") (read_line ())
          |> List.map int_of_string
          |> List.sort compare
          |> List.mapi (fun i elmnt ->
                  if i < k then
                          elmnt
                  else
                          0
          ) 

let () =
        List.sum lst
        |> Printf.printf "%d\n"


Measured memory_bytes: 5860
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
typedef pair <PP,bitset<8100> > Pv;
typedef pair <P,bitset<8100> > KEY;

static const double EPS = 1e-8;


int tx[] = {-1,0,1,0};
int ty[] = {0,1,0,-1};

int main(){
	int m,n;
	while(~scanf("%d %d",&m,&n)){
		if(m==n && n==0) break;

		vector<P> pos;

		bitset<8100> field;
		for(int y=0;y<n;y++){
			for(int x=0;x<m;x++){
				int ice;
				scanf("%d",&ice);
				field[y*m+x] = ice ? true : false;
				if(ice) pos.push_back(P(x,y));
			}
		}

		int res=0;
		for(int p=0;p<pos.size();p++){
			queue<Pv> que;
			que.push(Pv(PP(1,pos[p]),field));

			//map<KEY,int> visited; 
			
			while(!que.empty()){
				int cost = que.front().first.first;
				int x = que.front().first.second.first;
				int y = que.front().first.second.second;
				bitset<8100> now = que.front().second;
				//vector< vector<int> > now = que.front().second;
				now[y*m+x] = 0;
				res = max(res,cost);
				que.pop();
				for(int i=0;i<4;i++){
					int dx = x + tx[i];
					int dy = y + ty[i];

					if(dx<0 || dx >=m || dy<0 || dy>=n) continue;
					if(now[dy*m+dx]==0) continue;
					//if(visited.find(KEY(P(dx,dy),now)) != visited.end()){
					//	continue;
					//}
					que.push(Pv(PP(cost+1,P(dx,dy)),now));
				}
			}
			
		}
		printf("%d\n",res);
	}
}

Measured memory_bytes: 1232
n = int( input())
k = int( input())

a = [1]
b = [1]
x = 10**6
for i in range(n+1):
  for j in range(n-i,n-i+1):
    f = 1*2**i+j*k
    if x > f:
      x = f
      
print(x)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    int l,r,d;
    cin >> l >> r >> d;
    l--;
    cout << r/d-l/d << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>

using namespace std;

int main(){
		int n,count=0;
		cin>>n;
		int a[n];
		for(int i =0; i<n;i++){
			cin>>a[i];
		}
		for(int i=0;i<n-2;i++){
			for(int j=i+1;j<n-1;j++){
				for(int k=j+1;k<n;k++){
					if(a[i]!=a[j] && a[i]!=a[k]&&a[j]!=a[k])
					if(a[i]+a[j] >a[k] && a[i]+a[k]>a[j]&& a[j]+a[k]>a[i]){
						count++;
					}
				}
			}
		}
	
	cout<<count<<endl;
	return 0;
}

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

struct Dice {
  int label[6];
  void swap(int a, int b, int c, int d) {
    int temp = label[a];
    label[a] = label[b];
    label[b] = label[c];
    label[c] = label[d];
    label[d] = temp;
  }
  void roll(char dir) {
    switch (dir) {
    case 'N': swap(0, 1, 5, 4); break;
    case 'E': swap(0, 3, 5, 2); break;
    case 'W': swap(0, 2, 5, 3); break;
    case 'S': swap(0, 4, 5, 1); break;
    }
  }
};

int main() {
  Dice dice;
  for (int i = 0; i < 6; i++) {
    cin >> dice.label[i];
  }
  int q, a, b;
  cin >> q;
  while (q--) {
    cin >> a >> b;
    for (auto& dir : "NNNENNN") {
      if (dice.label[1] == b) break;
      dice.roll(dir);
    }
    while (dice.label[0] != a) {
      dice.roll('E');
    }
    cout << dice.label[2] << "\n";
  }
}


Measured memory_bytes: 3084
N = int(input())
A = [int(a) for a in input().split()]
maxi, maxA, mini, minA = 0, A[0], 0, A[0]
for i in range(1, N):
    if A[i] > maxA: maxi, maxA = i, A[i]
    if A[i] < minA: mini, minA = i, A[i]

Ans = []
if abs(maxA) >= abs(minA):
    for i in range(N):
        if A[i] < 0:
            Ans.append((maxi+1, i+1))
            A[i] += maxA
    for i in range(1, N):
        if A[i] < A[i-1]:
            Ans.append((i, i+1))
            A[i] += A[i-1]
else:
    for i in range(N):
        if A[i] > 0:
            Ans.append((mini+1, i+1))
            A[i] += minA
    for i in reversed(range(N-1)):
        if A[i] > A[i+1]:
            Ans.append((i+2, i+1))
            A[i] += A[i+1]

print(len(Ans))
for x, y in Ans:
    print(x, y)

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

int main(){
  int S; cin >> S;
  vector<int> s(4);
  s[0]=S/1000;
  S=S%1000;
  s[1]=S/100;
  S=S%100;
  s[2]=S/10;
  S=S%10;
  s[3]=S;
 if((s[0]>=1 && s[1]>2) || (s[0] == 0 && s[1] == 0)){
   if((s[2]>=1 && s[3]>2) || (s[2] == 0 && s[3] == 0)){
     cout << "NA" << endl;
     return 0;
   }else{
     cout << "YYMM" << endl;
     return 0;
   }
}
  if((s[2]>=1 && s[3]>2) || (s[2] == 0 && s[3] == 0)){
    if((s[0]>=1 && s[1]>2) || (s[0] == 0 && s[1] == 0)){
      cout <<"NA" << endl;
      return 0;
    }
    else{
      cout <<"MMYY"<< endl;
      return 0;
    }
  }
  else{
  cout <<"AMBIGUOUS"<< endl;
  return 0;
}
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
using namespace std;
const int MAXN=110000;
vector<int> g[MAXN];
int in[MAXN], que[MAXN];
int f[MAXN];
int main()
{
//	freopen("G.in", "r", stdin);
//	freopen("G.out", "w", stdout);
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i=1; i<=m; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		g[x].push_back(y); in[y]++;
	}
	int head=0, tail=0;
	for (int i=1; i<=n; i++)
		if (in[i]==0) que[tail++]=i;
	while (head<tail)
	{
		int u=que[head++];
		for (int i=0; i<g[u].size(); i++)
		{
			int v=g[u][i];
			f[v]=max(f[v], f[u]+1);
			if (--in[v]==0) que[tail++]=v;
		}
	}
	printf("%d\n", *max_element(f+1, f+n+1));
	return 0;
}

Measured memory_bytes: 7168
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>
#include<unordered_map>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int N;
    cin >> N;
    unordered_map<string, int> S(N);
    string str;
    rep(i, N) {
        cin >> str;
        if (S.find(str) == S.end()) S[str] = 1;
        else S[str]++;
    }
    vector<string> ans;
    int maxi = 0;
    for ( const auto &p : S ) {
        if (p.second == maxi) ans.push_back(p.first);
        if (p.second > maxi) {
            ans.clear();
            maxi = p.second;
            ans.push_back(p.first);
        }
    }
    sort(ans.begin(), ans.end());
    rep(i, ans.size()) {
        cout << ans[i] << endl;
    }



	return 0;
}


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

#define int unsigned long long

using namespace std;
int  n,ans=0;
int  a[100005],b[100005],c[100005];
signed  main()
{
    cin>>n;
    n++;
    for (int i=1; i<=n; i++)
        cin>>a[i];

    b[1]=1,c[n]=a[n];
    for (int i=2; i<=n; i++)
        b[i]=(b[i-1]-a[i-1])*2;
    for (int i=n-1; i>=1; i--)
        c[i]=c[i+1]+a[i];
    for (int i=1; i<=n; i++)
        ans+=min(b[i],c[i]);
    for (int i=1; i<=n; i++)
    {
        if (a[i]>b[i])
            return cout<<-1<<endl,0;
    }
    cout<<ans<<endl;

    return 0;
}


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

#define pb push_back
#define ppp pop_back
#define pii pair<int,int>
#define fi first
#define se second

const int N = 105;
const int K = 1e5 + 5;

pii a[N];
ll dp[K];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int n, w;
    cin >> n >> w;
    for (int i=1; i<=n; i++) {
        cin >> a[i].fi >> a[i].se;
    }
    sort(a+1, a+n+1);
    for (int i=0; i<K; i++) dp[i] = -1;
    dp[0] = 0;
    for (int i=n; i>=1; i--) {
        for (int j=w; j>=0; j--) {
            if (dp[j] >= 0 && a[i].fi + j <= w) {
                dp[j + a[i].fi] = max(dp[j] + a[i].se, dp[j + a[i].fi]);
            }
        }
    }
    ll maxv = 0;
    for (int i=0; i<=w; i++) maxv = max(maxv, dp[i]);
    cout << maxv << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(int argc, const char * argv[]){
    int num, a, i, min = 1000001, max = -1000001;
    long long sum = 0;
    
    scanf("%d", &num);
    
    for (i = 0; i < num; ++i) {
        scanf("%d", &a);
        min = a < min ? a : min;
        max = a > max ? a : max;
        sum += a;
    }
    printf("%d %d %lld\n", min, max, sum);
}



Measured memory_bytes: 2124
def binary_search array, key, pivot, head_index
  targets = array.dup
  #puts "#{key} in [#{targets.join(',')}][#{pivot}] is #{targets[pivot]}"
  if (targets.size == 1) && (targets[0] != key)
    return nil
  elsif targets.size == 0
    return nil
  elsif targets[pivot] == key
    return pivot + head_index
  elsif targets[pivot] > key
    #pivot?????????????????????
    next_target = targets[0..(pivot - 1)]
    binary_search(next_target, key, next_target.size / 2, 0)
  elsif targets[pivot] < key
    #pivot?????????????????????
    next_target = targets[(pivot + 1)..targets.size]
    binary_search(next_target, key, next_target.size / 2, pivot)
  else
    raise "??????????????§ #{array.join(',')}, #{key} #{pivot} #{head_index}"
  end
end

def main size, array, keys_size, keys
  puts keys.select{|key|
    not binary_search(array, key, array.size / 2, 0).nil?
  }.size

end

size, array, keys_size, keys = STDIN.read.split(/\n/)
array = array.split(' ').map{|n|n.to_i}
keys = keys.split(' ').map{|n|n.to_i}

main(size, array, keys_size, keys)

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

int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  vector<int> num = {a, b, c};

  int count = 0;
  for (int i = 0; i <= a; i ++) {
    for (int j = 0; j <= b; j ++) {
      for (int k = 0; k <= c; k ++) {
        int sum = 500 * i + 100 * j + 50 * k;
        if (sum == x) {
          count ++;
        }
      }
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
S = [None]*N
for i in range(N):
    S[i] = input()

S_M = [S[i] for i in range(N) if S[i][0] == 'M']
S_A = [S[i] for i in range(N) if S[i][0] == 'A']
S_R = [S[i] for i in range(N) if S[i][0] == 'R']
S_C = [S[i] for i in range(N) if S[i][0] == 'C']
S_H = [S[i] for i in range(N) if S[i][0] == 'H']

souwa = 0
kahi = [0]*5
kahi[0] = len(S_M)
kahi[1] = len(S_A)
kahi[2] = len(S_R)
kahi[3] = len(S_C)
kahi[4] = len(S_H)

for i in range(len(kahi)-2):
    for j in range(i+1, len(kahi)-1):
        for k in range(j+1, len(kahi)):
            souwa += kahi[i]*kahi[j]*kahi[k]
print(souwa)

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define dame {cout<< "No" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    vector<ll> B(N);
    rep(i,N) cin>>A[i];
    rep(i,N) B[A[i]-1]=i;

    //左に持っていく最大のiと右に持っていく最小のiを求めれば良い
    //数字として一番揃っている部分列を残す
    ll ma=1;
    ll now=1;
    reps(i,1,N){
        if(B[i-1]<B[i]) ++now;
        else now=1;
        maxi(ma,now);
    }
    cout<< N-ma <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 3328
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long LL;
inline int read()
{
	register int x = 0 , f = 0; register char c = getchar();
	while(c < '0' || c > '9') f |= c == '-' , c = getchar();
	while(c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0' , c = getchar();
	return f ? -x : x;
}
int n;
int main()
{
	n = read();
	if(!(n & (n - 1))) puts("No");
	else
	{
		puts("Yes");
		puts("1 2");
		puts("2 3");
		cout << 3 << " " << n+1 << '\n';
		cout << n+1 << " " << n+2 << '\n';
		cout << n+2 << " " << n+3 << '\n';
		for(int i = 4 ; i + 1 <= n ; i += 2)
		{
			int j=i+1;
			cout << 1 << " " << i << '\n';
			cout << 1 << " " << j << '\n';
			cout << i << " " << j+n << '\n';
			cout << j << " " << i+n << '\n';
		}
		if(n%2==0)
		{
			for(int i = 4 ; i <= n ; ++i)
			{
				int j = n ^ i ^ 1;
				if (j != 3 && j < n)
				{
					cout << i << " " << n << '\n';
					cout << j << " " << 2*n << '\n';
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2304