akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>

using namespace std;

int remove(int row[5])
{
    int i;
    int start_num = row[0];
    int len = 1;
    for (i = 1; i < 5; i++)
    {
        if (row[i] == start_num) { len++; }
        else {
            if (len >= 3) { break; }
            else { start_num = row[i]; len = 1; }
        }
    }
    int pt = 0, ct = 0;
    if (len >= 3) {
        pt = row[i - len];
        while (len-- > 0)
        {
            row[i - len - 1] = 0;
            ct++;
        }
        pt *= ct;
    }
    return pt;
}

void drop(int row[10][5], int h)
{
    for (int x = 0; x < 5; x++)
    {
        for (int y = h - 1; y > 0; )
        {
            if (row[y][x] == 0)
            {
                bool flag = false;
                for (int i = y; i > 0; i--)
                {
                    row[i][x] = row[i - 1][x];
                    if (row[i][x] != 0)
                    {
                        flag = true;
                    }
                }
                row[0][x] = 0;
                if (flag == false)
                {
                    break;
                }
            }
            else
            {
                y--;
            }
        }
    }
}

int calc(int row[10][5], int h)
{
    int pt = 0;

    while (true)
    {
        int tmp = 0;
        for (int i = 0; i < h; i++)
        {
            tmp += remove(row[i]);
        }
        drop(row, h);
        if (tmp == 0)
        {
            break;
        }
        pt += tmp;
    }
    return pt;
}

int main(void)
{
    int H;

    while (cin >> H, H)
    {
        int row[10][5];
        for (int i = 0; i < H; i++)
        {
            cin >> row[i][0] >> row[i][1] >> row[i][2] >> row[i][3] >> row[i][4];
        }

        int ans = calc(row, H);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
 
int reve(int x)
{
  int m;
  	m = 0;
	m += (x % 10) * 10000;
	x /= 10;
	m += (x % 10) * 1000;
	x /= 10;
	m += (x % 10) * 100;
	x /= 10;
	m += (x % 10) * 10;
	x /= 10;
	m += (x % 10) * 1;
return m;
}
 
int main(void)
{
  int A, B, s;
  cin >> A >> B;
  s = 0;
  for(int i = A; i <= B; i++){
  	if(i == reve(i)){
    s++;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 3528
#!/usr/bin/env python3

N = int(input().split()[0])
s_list = []
a_list = []
b_list = []
ab_list = []
ab_count = 0
for _ in range(N):
    s = input()
    s_list.append(s)
    ab_count += s.count("AB")
    if s[0] == "B" and s[-1] == "A":
        ab_list.append(s)
    elif s[0] == "B":
        b_list.append(s)
    elif s[-1] == "A":
        a_list.append(s)

if a_list:
    if ab_list:
        a_list.pop()
        ab_count += len(ab_list)
        if b_list:
            ab_count += 1
            b_list.pop()
        ab_count += max(min(len(a_list), len(b_list)), 0)
    else:
        ab_count += min(len(a_list), len(b_list))
elif b_list:
    ab_count += len(ab_list)
else:
    ab_count += max(len(ab_list) - 1, 0)

ans = ab_count
print(ans)


Measured memory_bytes: 3956
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main()
{
	char b;
	scanf("%c", &b);
	switch(b)
	{
	case 'A':printf("T\n");break;
	case 'T':printf("A\n");break;
	case 'C':printf("G\n");break;
	case'G':printf("C\n");break;
	}


	return 0;
}

Measured memory_bytes: 128
from operator import itemgetter
n=int(input())
l=[[] for i in range(n)]
for i in range(n):
  s,p=input().split()
  l[i].append(s)
  l[i].append(int(p))
  l[i].append(i+1)
l2=sorted(l,key=itemgetter(1),reverse=True)
l3=sorted(l2,key=itemgetter(0))
for i in range(n):
  print(l3[i][2])

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


complex<int> Mov(char dir){
	char a[4] = {'N','W','S','E'};
	int dx[4] = {0,-1,0,1};
	int dy[4] = {1,0,-1,0};
	for(int i=0;i<4;i++){
		if(a[i]==dir){
			complex<int> mov(dx[i],dy[i]);
			return mov;
		}
	}
}

bool solve(){
	while(1){
		int jw[22][22] = {0};
		complex<int> rob(10,10);
		int n;
		cin>> n;
		if(!n) break;
		for(int i=0;i<n;i++){
			int x,y;
			cin>> x>> y;
			jw[x][y]++;
		}
		int m;
		cin>> m;
		int cnt=0;
		if(jw[10][10]){
			jw[10][10] = 0;
			cnt++;
		}
		for(int i=0;i<m;i++){
			char dir;
			int d;
			cin>> dir>> d;
			for(int j=0;j<d;j++){
				rob += Mov(dir);
				int x = rob.real();
				int y = rob.imag();
				if(jw[x][y]){
					jw[x][y] = 0;
					cnt++;
				}
			}
		}
		
		if(cnt==n){
			cout<< "Yes"<< endl;
		}else{
			cout<< "No"<< endl;
		}
	}
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

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

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

int main(){
    int n,m;
    cin >> n >> m;
    int total_task = 0;
    rep(i,m){
        int a;
        cin >> a;
        total_task += a;
    }
    if(n >= total_task){
        cout << n - total_task << endl;
    }else{
        cout << -1 << endl;
    }
    
    
    
}


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

using namespace std;

const int INF = 1 << 30;

int solve(const vector<int>& x, const vector<int>& y, const vector<char>& u, char s, char t, auto f, auto g){
    const int N = x.size();
    int res = INF;
    vector<vector<pair<int, char>>> vv(400001);
    for(int i=0;i<N;i++){
        if(u[i] != s && u[i] != t) continue;
        vv[f(x[i], y[i])].emplace_back(g(x[i], y[i]), u[i]);
    }
    for(auto& v : vv){
        if(v.size() < 2) continue;
        sort(v.begin(), v.end());
        for(int i=0;i+1<v.size();i++){
            if(v[i].second == s && v[i+1].second == t){
                res = min(res, 5 * (v[i+1].first - v[i].first));
            }
        }
    }
    return res;
}

int main(){
    int N; cin >> N;
    vector<int> X(N), Y(N);
    vector<char> U(N);
    for(int i=0;i<N;i++) cin >> X[i] >> Y[i] >> U[i];
    auto x = [](int a, int b){ return a; };
    auto y = [](int a, int b){ return b; };
    auto add = [](int a, int b){ return a+b; };
    auto sub = [](int a, int b){ return a-b+200000; };
    int res = INF;
    res = min(res, solve(X, Y, U, 'R', 'L', y, x));
    res = min(res, solve(X, Y, U, 'U', 'D', x, y));
    res = min(res, solve(X, Y, U, 'R', 'D', sub, add));
    res = min(res, solve(X, Y, U, 'U', 'L', sub, add));
    res = min(res, solve(X, Y, U, 'R', 'U', add, sub));
    res = min(res, solve(X, Y, U, 'D', 'L', add, sub));
    if(res < INF){
        cout << res << endl;
    } else {
        cout << "SAFE" << endl;
    }
}

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

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

    int A;
    int counter = 0;
    rep (i,N){
        cin >> A;
        if (A % 2 == 1) continue;
        else if (A % 3 == 0 || A % 5 == 0) continue;
        else {
            counter++;
            break;
        }
    }

    if (counter == 0) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
// ABC152_C
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <cstring>  // std::memset
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define repr(i, n) for (ll i=n-1; i >= 0; i++)  // n-1 ~ 0
#define rep1(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define all(vec) (vec).begin(), (vec).end()
#define sum(vec) accumulate(all(vec), 0LL)  // 0 は初期値
#define min_vec(vec) min_element(all(vec))  // iterator: * を先頭につける
#define max_vec(vec) max_element(all(vec))  // iterator: * を先頭につける
#define idx(vec, element_iter) distance((vec).begin(), element_iter)
const ll INF = 1LL<<60;  // 10^18（const int inf = 1<<29;）
const double PI = acos(-1);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    // input(sunippets: inpv, inpn, inps)
    ll N;
    cin >> N;
    vector<ll> vec(N);
    rep(i, N) cin >> vec[i];
    
    // calculation
    ll now_min = vec[0], res = 1;
    
    for (ll i = 1; i < N; i++) {
        if (vec[i] <= now_min) {
            res++;
            now_min = vec[i];
        }
    }
    cout << res << "\n";
    
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;


long long N, K;
long long P[200002] = {0};
long double E[200002] = {0.0};
long double S[200002] = {0.0};

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> K;

	for(int i=1; i<=N; i++){
		cin >> P[i];
	}

	for(int i=1; i<=N; i++){
		long long tmp = 0;
		for(int j=1; j<=P[i]; j++){
			tmp += j;
		}
		long double exp = (long double)tmp / (long double)P[i];
		E[i] = exp;
		if(i == 1){
			S[i] = exp;
		}
		else{
			S[i] = S[i-1] + exp;
		}
	}
	long double ans = 0.0;

	for(int i=1; i<=N-K+1; i++){
		long double tmp = S[i+K-1] - S[i-1];
		if(tmp > ans) ans = tmp;
	}

	printf("%.9Lf\n", ans);
	return 0;
}

Measured memory_bytes: 11524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N,M;
    cin >> N >> M;
    if(N>M){
        swap(N,M);
    }
    if(N == 1){
        cout << (M == 1?1:M-2) << "\n";
    }else{
        cout << (M-2)*(N-2) << "\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, n)
    {
        ll x; cin >> x;
        while(x%2 == 0) x/=2, ans++;
    }
    cout << ans;

}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let n = input!(usize);
    let x = input!(usize; n);

    let mut sorted_x = x.clone();
    sorted_x.sort();
    for i in 0..n {
        if x[i] < sorted_x[n / 2] {
            println!("{}", sorted_x[n / 2]);
        } else {
            println!("{}", sorted_x[(n / 2) - 1]);
        }
    }
}

Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
#define isprime(x) (!np[x]&&(x&1))
#define MUHAMMED_HISHAM ios_base::sync_with_stdio(false);cin.tie(NULL);/*const int mxxx = 100005;
bool np[mxxx];
int si, primes[mxxx];
void sieve()
{
    si = 0;
    np[0] = np[1] = 1;
    for (long long i = 3; i * i <= mxxx; i += 2)
    {
        if (np[i] == 0)
        {
            for (long long j = i * i; j < mxxx; j += (i * 2))
                np[j] = 1;
        }
    }
    primes[si++] = 2;
    for (int i = 0; i < mxxx; i++)
    {
        if (np[i] == 0 && i % 2)
            primes[si++] = i;
    }
}
////////////////prime factorization/////////////////////////
void primeFactors(int n)
{
    while (n % 2 == 0)
    {
        cout << 2;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            cout << i;
            n = n / i;
        }
    }
    if (n > 2)
    {
        cout << n;
    }

}

/////////////////////////power////////////////constant, power
long long  power(long long   x, long long  y)
{
    long long   temp;
    if (y == 0)
        return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if (y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}


long long  fast_power(long long  x, long long  n, long  mood)
{
    if (n == 0)return 1;
    else  if (n % 2 == 0)return fast_power(x * x, n / 2, mood);
    else  return (x * fast_power((x * x) % mood, (n - 1) / 2, mood));
}

/*

ll solve(ll i,ll last,ll cap)
{

    if(i>n)
    {
        // cout<<cap<<endl;
        if(cap==0)
        {
            return 0;
        }
        else return 1e9+100;
    }
    ll &ret=dp[i][last][cap];
    if(ret!=-1)
    {
        return ret;
    }
    ret=1e9+100;
    if(last==0)return ret=min(solve(i+1,i,cap-1),solve(i+1,last,cap));
    return ret=min((cap>0)?solve(i+1,i,cap-1)+(a[i]+a[last])*(i-last):100000500,solve(i+1,last,cap));
}

long double   fibonacci(long double n)
{
    long double  zzz=1/sqrt(5);
    long double  xxx=(1+sqrt(5))/2;
    long double  yyy=(1-sqrt(5))/2;
    //cout<<zzz<< "  "<<xxx<<" "<<yyy<<" ";
    return     zzz*(pow(xxx,n)-pow(yyy,n));

}*/
//////////////////////////////////////////////////////////////////

int n;
int arr[100001];
const int sizee=1e6+1;
long long  dp[sizee];
long long  mini(int i,long long cost)
{
    if (i==n-1) return 0;
    long long & ret=dp[i];
    if (ret!=-1)return ret;
    long long  far=100000000000;
    if (i<=n-3)far=mini(i+2,cost+abs(arr[i]-arr[i+2]))+abs(arr[i]-arr[i+2]);
    return ret=min(mini(i+1,cost+abs(arr[i]-arr[i+1]))+abs(arr[i]-arr[i+1]),far);
}
int main()
{
    MUHAMMED_HISHAM
    cin>>n;
    for (int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    memset(dp,-1,sizeof dp);
    cout<<mini(0,0);
    return 0;
}


Measured memory_bytes: 14920
n = input()
if (len(n) == 1):
    print(int(n))
elif (len(n) == 2):
    print(9)
elif (len(n) == 3):
    print(int(n)-99+9)
elif (len(n) == 4):
    print(909)
elif (len(n) == 5):
    print(909 + int(n) - 9999)
else:
    print(90909)

Measured memory_bytes: 3060
// daughter of 671D codeforces
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 1;

struct line {
	int l, r, w;
	bool operator < (const line &o) {
		return r < o.r;
	}
} lie[N];

int n, m;
ll dp[N];
vector<int> cur[N];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	for (int i = 1, l, r, w; i <= m; i++) {
		cin >> l >> r >> w;
		lie[i] = {l, r, w};
		cur[l].push_back(i);
	}
	memset(dp, 0x3f3f3f3f, sizeof dp);
	set<pair<ll, int>> active;
	ll ans = LLONG_MAX;
	lie[0] = {1, 1, 0};
	active.insert({0, 0});
	for (int i = 1; i <= n; i++) {
		while (!active.empty() && lie[active.begin()->second].r < i) {
			active.erase(active.begin());
		}
		for (auto& id : cur[i]) {
			if (active.empty()) {
				cout << -1;
				return 0;
			}
			auto t = active.begin();
			dp[id] = min(dp[id], t->first + lie[id].w);
			if (lie[id].r == n) {
				ans = min(ans, dp[id]);
			}
		}
		for (auto& id : cur[i]) {
			active.insert({dp[id], id});
		}
	}
	if (ans == LLONG_MAX) cout << -1;
	else cout << ans;
}

Measured memory_bytes: 40448
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        for j in range(W):
            if (i+j)%2==0:
                print('#',end='')
            else:
                print('.',end='')
        print()
    print()



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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	int h;
	int n;
	int a;
	cin >> h >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		h -= a;
	}
	
	if (h <= 0)
		cout << "Yes";
	else
		cout << "No";

	return 0;	
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> v(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    v.at(i) = make_pair(a, b);
  }
  sort(v.begin(), v.end());
  int salary = 0, jobs = 0;
  priority_queue<int> q;
  for (int i = 0; i < n; i++) {
    if (v.at(i).first > m) break;
    while (jobs < v.at(i).first - 1) {
      if (!q.empty()) {
        salary += q.top();
        q.pop();
      }
      jobs++;
    }
    q.push(v.at(i).second);
  }
  while (jobs < m) {
    if (!q.empty()) {
      salary += q.top();
      q.pop();
    }
    jobs++;
  }
  cout << salary << endl;
}


Measured memory_bytes: 1660
N, M = map(int, input().split())
A = list(map(int, input().split()))

CList = []

for _ in range(M) :
    B, C = map(int, input().split())
    tuple = (B, C)
    CList.append(tuple)

for i in range(N) :
    CList.append((1, A[i]))

CList = sorted(CList, key=lambda t: t[1], reverse=True)

#print(CList)
ans = 0
sum = 0

for l in CList :
    ans += l[0] * l[1]
    sum += l[0]
    if sum >= N :
        ans -= l[1] * (sum - N)
        break

print(ans)


Measured memory_bytes: 33612
"use strict";

// read lines from stdin
const input = parseInt(require("fs")
  .readFileSync("/dev/stdin", "utf8"), 10);

const first = Math.floor(input / 100);
const last = input % 100;

function canReadAsMonth(num) {
  return num > 0 && num < 13;
}

if (canReadAsMonth(first) && canReadAsMonth(last)) {
  console.log("AMBIGUOUS");
} else if (!canReadAsMonth(first) && canReadAsMonth(last)) {
  console.log("YYMM");
} else if (canReadAsMonth(first) && !canReadAsMonth(last)) {
  console.log("MMYY");
} else {
  console.log("NA");
}


Measured memory_bytes: 21064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = (int)1e9 + 7;
int add(int x, int y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int mult(int x, int y) {
	return ((ll)x * y) % MOD;
}

const int N = 303;
int n;
bool used[2 * N];
int a[N];
int m;
int dp[2][N][N];
int k;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	k = n;
	for (int i = 0; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x == -1) swap(x, y);
		if (x == -1) {

		} else if (y == -1) {
			a[m++] = x;
		} else {
			used[x] = used[y] = 1;
			k--;
			continue;
		}
	}
	for (int i = 0; i < m; i++) {
		int x = 0;
		for (int j = 1; j < a[i]; j++)
			if (!used[j])
				x++;
		a[i] = x;
	}
	n = k;
	for (int i = 0; i < 2 * n; i++)
		used[i] = 0;
	for (int i = 0; i < m; i++)
		used[a[i]] = 1;

	dp[0][0][0] = 1;
	for (int i = 0; i < 2 * n; i++) {
		for (int x = 0; x <= n; x++)
			for (int y = 0; y <= n; y++)
				dp[1][x][y] = 0;
		for (int x = 0; x <= n; x++)
			for (int y = 0; y <= n; y++) {
				if (dp[0][x][y] == 0) continue;
				if (used[i]) {
					dp[1][x][y + 1] = add(dp[1][x][y + 1], dp[0][x][y]);
					if (x > 0)
						dp[1][x - 1][y] = add(dp[1][x - 1][y], mult(x, dp[0][x][y]));
				} else {
					dp[1][x + 1][y] = add(dp[1][x + 1][y], dp[0][x][y]);
					dp[1][x][y + 1] = add(dp[1][x][y + 1], dp[0][x][y]);
					if (y > 0)
						dp[1][x][y - 1] = add(dp[1][x][y - 1], dp[0][x][y]);
				}
			}
		for (int x = 0; x <= n; x++)
			for (int y = 0; y <= n; y++)
				dp[0][x][y] = dp[1][x][y];
		/*
		for (int j = 1; j <= n; j++) {
			dp[0][0][0] = add(dp[0][0][0], dp[0][j][0]);
			dp[0][j][0] = 0;
		}
		*/
	}
	int ans = dp[0][0][0];
	for (int i = 1; i <= n - m; i++)
		ans = mult(ans, i);
	printf("%d\n", ans);

	return 0;
}


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

int main() {
  int m, d;
  scanf("%d %d", &m, &d);
  int ans = 0;
  for (int d1 = 2; d1 <= 9; d1++)
    for (int d2 = 2; d2 <= 9; d2++)
      if (d1 * d2 <= m && d1 * 10 + d2 <= d)
        ans++;
  printf("%d\n", ans);
  return 0;
}

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

using namespace std ;

const int N=2e3+10 ;

char s[N][N] ;
int l[N][N] , r[N][N] , u[N][N] , d[N][N] ;
int n , m ;
int main ()
{
    int i , j , res=0 ;
    scanf("%d%d",&n,&m);
    for ( i=1 ; i<=n ; i++ ) scanf(" %s ",s[i]+1);
    for ( i=1 ; i<=n ; i++ ) 
        for ( j=1 ; j<=m ; j++ ) 
            if ( s[i][j]=='.' ) l[i][j]=l[i][j-1]+1,u[i][j]=u[i-1][j]+1;
            else l[i][j]=u[i][j]=0;
    for ( i=n ; i>=1 ; i-- ) 
        for ( j=m ; j>=1 ; j-- ) 
            if ( s[i][j]=='.' ) r[i][j]=r[i][j+1]+1,d[i][j]=d[i+1][j]+1;
            else r[i][j]=d[i][j]=0;
    for ( i=1 ; i<=n ; i++ ) 
        for ( j=1 ; j<=m ; j++ ) 
            if ( s[i][j]=='.' ) res=max(res,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
    printf("%d\n",res);
    return 0 ;
}

Measured memory_bytes: 67200
a, b, c, k = map(int, input().split())
ans = 0
if a >= k:
  ans += k
  print(ans)
  exit()
else:
  ans += a
  k -= a
if b >= k:
  print(ans)
  exit()
else:
  k -= b
if c >= k:
  ans -= k
else:
  ans -= c
print(ans)


Measured memory_bytes: 9188
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll a[11000], b[11000],c = 0,d = 0;

int main(){
	int n; cin >> n;
	REP(i, n)cin >> a[i]; 
	REP(i, n)cin >> b[i]; 
	REP(i, n) {
		if (a[i] > b[i])c += (a[i] - b[i]);
		else d += b[i] - a[i] - (b[i] - a[i]) % 2;
	}
	cout << (c * 2 <= d ? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,mod=998244353,dp[200009],fen[200009],xar[200009],pas,dpp[200009];
pair <long long, long long> p[200009];
void upd(long long q, long long w){
    while(q<=200000){
        if(fen[q]<w) fen[q]=w;
        q=q+(q&(-q));
    }
}
long long read(long long q){
    long long w=0;
    while(q>=1){
        if(w<fen[q]) w=fen[q];
        q=q-(q&(-q));
    }
    return w;
}
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a;
    xar[0]=1;
    for(b=1; b<=a+2; b++){
        xar[b]=xar[b-1]*2;
        xar[b]%=mod;
    }
    for(b=1; b<=a; b++) cin>>p[b].first>>p[b].second;
    sort(p+1,p+a+1);
    p[a+1].first=1000000009;
    for(b=a; b>=1; b--){
        p[b].second--;
        c=lower_bound(p+1,p+a+1,make_pair(p[b].first+p[b].second+1LL,0LL))-p;
        c--;
        dp[b]=read(c);
        if(dp[b]<b) dp[b]=b;
        upd(b,dp[b]);
        //cout<<dp[b]<<" ";
    }
    dpp[a+1]=1;
    for(b=a; b>=1; b--){
        dpp[b]=dpp[b+1]+dpp[dp[b]+1];
        dpp[b]%=mod;
    }
    cout<<dpp[1];
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <tuple>
using namespace std;

int N, M, C[100009];

int main() {
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		int A; cin >> A;
		for (int j = 0; j < A; j++) { int c; cin >> c; C[c]++; }
	}
	int cnt = 0;
	for (int i = 0; i <= 100000; i++) {
		if (C[i] == N) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main2():
	n = int(input())
	#b , c = tin()
	#s = input()	
	mt=[input() for _ in range(n)]
	
	tt=[]
	for i in range(n):
		l=[]
		for s in mt:
			l.append(s[i])
		tt.append(''.join(l+l))
	pa(tt)
	ret = 0
	for ai in range(n):
		for s,t in zip(mt, tt):
			pa((s, t[ai:ai+n]))
			if t[ai:ai+n] != s:
				break
		else:
			ret += n
	return ret
	
def is_s(a,mt):
	pass
	#pa(a)
	n=len(mt)
	for i in range(n):
		for j in range(n):
			#pa((mt[i+a][j], mt[j][i+a]))
			if mt[(i+a)%n][j] != mt[(j+a)%n][i]:
				return False
	return True
	
def main():
	n = int(input())
	#b , c = tin()
	#s = input()	
	mt=[list(input()) for _ in range(n)]
	ret = 0
	for i in range(n):
		if is_s(i, mt):
			ret += n
	return ret
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 76996
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    System.out.println(gcd(x, y));
  }

  public static int gcd(int a, int b) {
    if (b == 0) {
      return a;
    }
    return gcd(b, a % b);
  }
}


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

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

  int n;
  cin >> n;
  string s = to_string(n);
  bool ans = false;
  for (int i = 0; i < s.size(); i++)
  {
    if (s.at(i) == '7')
    {
      ans = true;
    }
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

int main(){
    char s[8]={0};
    scanf("%s",s);
    if(s[1]=='B') s[1]='R';
    else s[1]='B';
    print(s);
    output();
    return 0;
};

Measured memory_bytes: 3684
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <math.h>
#include <cstdio>
#include <iomanip>
typedef  long long ll;
using namespace std;

int main(void) {
	int n;
	int s[1000];
	cout << fixed << setprecision(10);

	while (true)
	{
		cin >> n;
		if ( n == 0) break;
		double m = 0, a, b = 0;

		for (int i = 0; i < n; i++)
		{
			cin >> s[i];
			m += s[i];
		}
		m /= n;
		for (int i = 0; i < n; i++)
		{
			b += (s[i] - m) * (s[i] - m);
		}
		
		a = sqrt(b/n);
		cout << a << endl;
	}

	return 0;
}


Measured memory_bytes: 3236
#include<cstdint>
#include<limits>
#include<cstdbool>
#include<cmath>
#include<iostream>
#include<vector>
#include<array>
#include<list>
#include<string>
#include<sstream>
#include<algorithm>

int main(){
	int n;
	std::cin>>n;
	std::cin.get();
	std::vector<int> x;
	x.reserve(n);
	std::string buff;
	getline(std::cin,buff);
	std::stringstream ss(buff);
	int temp;
	while(!ss.eof()){
		ss>>temp;
		x.push_back(temp);
	}
	std::sort(x.begin(), x.end());
	std::cout<<x[n/2]-x[n/2-1];
	return 0;
}


Measured memory_bytes: 1924
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
a_list = list(map(int, input().split()))
ans = 0
total = 0
mod = 10 ** 9 + 7
for i in range(n):
    total += a_list[i]
    if total >= mod:
        total = total % mod

for i in range(n - 1):
    total -= a_list[i]
    if total < 0:
        total += mod
    ans += a_list[i] * total
    if ans >= mod:
        ans = ans % mod
print(ans)

Measured memory_bytes: 31744
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

void comb(vvll &v) {
    rep(i,v.size()) {
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for (int k = 1; k < v.size(); k++) {
        for (int j = 1; j < k; j++) {
            v[k][j] = v[k-1][j-1] + v[k-1][j];
        }
    }
}

int main() {
    int N, a, b; cin >> N >> a >> b;
    int A = a;
    map<ll,int,greater<ll>> mp;
    rep(i,N) {
        ll v; cin >> v;
        mp[v]++;
    }
    vvll v(51,vll(51,0));
    comb(v);
    ll choose = 0;
    ll sum = 0;
    double mean;
    P p_begin = *mp.begin();
    if (a <= p_begin.second) {
        for (int i = a; i <= min(p_begin.second,b); i++) {
            choose += v[p_begin.second][i];
        }
        mean = p_begin.first;
    } else {
        for (P p : mp) {
            ll value = p.first;
            int ct = p.second;
            if (a > ct) {
                a -= ct; 
                sum += value * ct;
             } else {
                sum += a * value;
                choose += v[ct][a];
                mean = (double)sum / A;
                break;
            }
        }
    }
    printf("%.10f\n%lld\n",mean,choose);

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using static System.Console;

namespace ABC128A
{
    static class Program
    {
        static void Main(string[] args)
        {
            var n = ReadLine().SplitTryParseToList<int>();

            var a = (n[0] * 3 + n[1]) / 2;
            WriteLine(a);
        }

        public static T TryParse<T>(this String input)
        {
            try
            {
                var converter = TypeDescriptor.GetConverter(typeof(T));
                if (converter != null)
                {
                    return (T)converter.ConvertFromString(input);
                }
                else
                {
                    throw new InvalidCastException("");
                }
            }
            catch
            {
                throw new InvalidCastException(typeof(T) + " is not supported.");
            }
        }

        public static List<T> SplitTryParseToList<T>(this String input)
        {
            return input.Split().Select(n => n.TryParse<T>()).ToList();
        }

        public static List<T> ListSwap<T>(this List<T> list, Int32 index1, Int32 index2)
        {
            var t = list[index1];
            list[index1] = list[index2];
            list[index2] = t;
            return list;
        }

        public static List<Tuple<T, int>> DuplicateCount<T>(this IEnumerable<T> list)
        {
            return list
                .GroupBy(i => i)
                .Where(g => g.Any())
                .Select(g => Tuple.Create(g.Key, g.Count()))
                .ToList();
        }
        public static List<Tuple<T, int>> DuplicateSort<T>(this IEnumerable<Tuple<T, int>> list)
        {
            return list.OrderByDescending((x) => x.Item2).ToList();
        }
        public static List<T> ReadLineOne<T>(int n)
        {
            var list = new List<T>();
            foreach (var i in Enumerable.Range(1, n))
            {
                list.Add(Console.ReadLine().TryParse<T>());
            }
            return list;
        }
        public static void PrintAll<T>(this IEnumerable<T> list)
        {
            foreach (var i in list)
            {
                Console.Write($"{i} ");
            }

            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 14432
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
          string[] Inputline1 = Console.ReadLine().Split(' ');
          string[] Inputline2 = Console.ReadLine().Split(' ');
          int K = int.Parse(Inputline1[0]);
          int N = int.Parse(Inputline1[1]);
          var list = new List<int>();
          for(int i = 0; i < N; i++)
          {
			int num = int.Parse(Inputline2[i]);
            list.Add(num);
          }
          
          int num2 = 0;
          for(int i = 0; i < N - 1; i++)
          {
          	int s = list[i + 1] - list[i];
            if(num2 < s)
            {
             num2 = s; 
            }
          }
          int end = (K - list[N - 1]) +  (list[0] - 0);
          if(num2 < end)
          {
          	num2 = end;
          }
          Console.WriteLine(K - num2);
        }
    }
}


Measured memory_bytes: 35676
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int a, b;
	scanf("%d%d", &a, &b);
	printyn((a % 500) <= b);
	
	Please AC;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int cnt = 0;
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        if ((500 * i + 100 * j + 50 * k) == X) cnt++;
      }
    }
  }
  print(cnt);
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char **argv)
{
    int N;
    int T, A;
    
    std::cin >> N;
    std::cin >> T;
    std::cin >> A;

    float diff = 1000000000;
    int pt = -1;
    for(int i = 0; i < N; i++){
        int Hi;
        std::cin >> Hi;
        float t = T - Hi * 0.006;
        float nd = t - A;
        nd = nd > 0 ? nd : -nd;
        if(nd < diff){
            diff = nd;
            pt = i+1;
        }
    }
    std::cout << pt << std::endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
constexpr ll INF = 1LL<<60;

int main() {
    ll n;
    cin >> n;
    vector<ll> c(n);
    REP(i, n) cin >> c[i], c[i]--;
    vector<vector<ll>> g(n);
    REP(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }    

    ll num = 0;
    vector<ll> cnt(n), ans(n, n*(n-1)/2);
    auto dfs = [&](auto &&self, ll v, ll p) -> ll {
        ll ret = 1, hold = cnt[c[v]];
        for(auto to: g[v]) if(to!=p) {
            ll pre = num-cnt[c[v]];
            ret += self(self, to, v);
            ll nxt = num-cnt[c[v]];
            ans[c[v]] -= (nxt-pre)*(nxt-pre-1)/2;
        }
        cnt[c[v]] = hold + ret;
        num++;
        return ret;
    };
    dfs(dfs, 0, -1);
    REP(i, n) ans[i] -= (n-cnt[i])*(n-cnt[i]-1)/2;
    REP(i, n) ans[c[i]]++;

    REP(i, n) cout << ans[i] << "\n";   

    return 0;
}


Measured memory_bytes: 37484
#include<stdio.h>
#include <unistd.h>
#include <stdlib.h>

int totonoe(int *,int);
int size=0;
int main(){
  int i,a[2000001],now,tmp;
  char c[8];
  while(1){
    scanf("%s",c);
    if(c[2] == 'd')
      break;
    if(c[0] == 'i'){
      scanf("%d",&now);
      size++;
      a[size] = now;
      for(now=size;now > 1;now/=2){
	if(a[now] > a[now/2]){
	  tmp = a[now];
	  a[now] = a[now/2];
	  a[now/2] = tmp;
	}else
	  break;
      }
    }else{
      printf("%d\n",a[1]);
      a[1]=a[size];
      size--;
      if(size > 1){
	for(i=size;i>1;i/=2)
	  totonoe(a,i/2);
      }
    }
    /*      printf("---%s---\n",c);
    for(i=1;i<size+1;i++){
      printf(" %d",a[i]);
    }
      printf("\n");
    
    */	
  }


}
int totonoe(int *a,int root){
  int tmp,b=1;
  if(size>=root*2)
    if(a[root*2]>a[root])
      b*=2;
  if(size>=root*2+1)
    if(a[root*2+1]>a[root])
      b*=3;
  if (b%2 == 0 && b%3 ==0){
    if(a[root*2]>a[root*2+1]){
      tmp=a[root*2];
      a[root*2] = a[root];
      a[root] = tmp;
      totonoe(a,root*2);
    }else{
      tmp=a[root*2+1];
      a[root*2+1] = a[root];
      a[root] = tmp;
      totonoe(a,root*2+1);
    }
    
  }else if(b%2 == 0){
      tmp=a[root*2];
      a[root*2] = a[root];
      a[root] = tmp;
      totonoe(a,root*2);


  }else if(b%3 ==0){
      tmp=a[root*2+1];
      a[root*2+1] = a[root];
      a[root] = tmp;
      totonoe(a,root*2+1);


  }
  return 0;
}



Measured memory_bytes: 5660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int V[55];
    for(int i = 1; i <= N; i++) cin >> V[i];
    int ans = 0;
    for(int L = 0; L <= K; L++) {
        for(int R = 0; L + R <= K; R++) {
            if(L + R > N) continue;
            int rest = K - L - R;
            vector<int> now;
            for(int i = 1; i <= L; i++) now.push_back(V[i]);
            for(int i = N; i >= N - R + 1; i--) now.push_back(V[i]);
            sort(now.begin(), now.end(), greater<int>());
            //if(L > 0 || R > 0) cerr << L << " " << R << " " << rest << " "<< now.back() << endl;
            for(int time = 1; time <= rest; time++) {
                if(now.empty()) break;
                if(now.back() >= 0) break;
                now.pop_back();
            }
            int nowval = 0;
            for(int i = 0; i < now.size(); i++) nowval += now[i];
            //cerr << L << " "<< R << " " << nowval << endl;
            chmax(ans, nowval);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#-*-coding:utf-8-*-

def main():
    #入力
    lists = list(map(int, input().split()))
    
    total_sum = 0

    #Nまでの数字の内，各桁の和がA以上B以下のものを足し合わせる
    for i in range(1, lists[0]+1):
        degit_sum = sum(map(int, str(i)))
        if degit_sum >= lists[1] and degit_sum <= lists[2]:
            total_sum += i

    print('{}'.format(total_sum))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

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

int main()
{
  string S;
  cin >> S;
  vector<char> jdg(2);
  vector<int> count(2);

  jdg[0] = S[0];
  count[0] = 1;

  rep(i,1,4){
    int flg = 0;
    REP(j,2){
      if( S[i] == jdg[j] ){
        count[j]++;
        flg = 1;
        break;
      }
    }

    if(flg == 0){
      jdg[1] = S[i];
      count[1] = 1;
    }
  }

  if(count[0] == 2 && count[1] == 2){
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256