akhauriyash/Code-Regression huggingface dataset:
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {

	string s; cin >> s;

	for4 (i, 0ll, (lld) s.length(), 2) {
		cout << s[i];
	}

	return;
}


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

	lld T3X0 = 0, T353 = 1;

	// TESTCASES()
	solveEachTest(T353 - T3X0);
	return 0;
}
// Random Thought :  null

Measured memory_bytes: 3716
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  // "math"
)

// 行単位で読み込む場合
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Scan()
  N, _ := strconv.Atoi((strings.Split(sc.Text(), " "))[0])
  sc.Scan()
  D, _ := strconv.Atoi((strings.Split(sc.Text(), " "))[0])
  X, _ := strconv.Atoi((strings.Split(sc.Text(), " "))[1])

  count := X

  for i := 0; i < N; i++ {
    sc.Scan()
    A, _ := strconv.Atoi((strings.Split(sc.Text(), " "))[0])
    for j := 0; j < D; j += A {
      count++
    }
  }

  fmt.Println(count)

}

Measured memory_bytes: 640
#include <cstdio>

using namespace std;

int a, b;

int main () {
    scanf("%d%d", &a , &b);
    if(a>0) printf("Positive\n");
    else if(b >= 0) printf("Zero\n");
    else if((a & 1) ^ (b & 1)) printf("Positive\n");
    else puts("Negative\n");
    return 0;
}

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

using namespace std;
#define int long long
signed main() {
    int n;
    cin >> n;
    int cnt = 0;
    int i;
    for(i=1;i<=n;i++)
    {
        int x;
        cin >> x;
        if(x%2 == 1 && i%2 == 1)
            cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 3632
n,m = map(int,input().split())
S = [list(map(int,input().split())) for _ in range(m)]
K = [s[0] for s in S]
S = [s[1:] for s in S]
P = list(map(int,input().split()))

from itertools import product
ans = 0
for d in product([0,1],repeat=n):  
  count = 0
  for mi in range(m):
    on = sum([d[S[mi][si]-1]==1 for si in range(K[mi])])    
    if on % 2 == P[mi]:
      count += 1        
  if count == m:
    ans += 1  
  
print(ans)  

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int a,b,c,k,i,m,sum;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    if(a>b){
        if(a>c){
            m=a;
        }
        else{
            m=c;
        }
    }
    else{
        if(b>c){
            m=b;
        }
        else{
            m=c;
        }
    }
    sum=a+b+c-m;
    for(i=0;i<k;i++){
        m=2*m;
    }
    printf("%d\n",m+sum);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <utility>
using namespace std;

#define endl '\n'
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
typedef pair<int, int> ii;
typedef long long LL;
typedef long double LD;


int main(int argc, char *argv[]){
    string s;
    while(cin>>s){
        string res = "";
        for(int i=0;i<4;i++){
            res.push_back(s[i]);
        }
        res.push_back(' ');
        for(int i=4;i<s.length();i++) res.push_back(s[i]);
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string> 
using namespace std;
string s,s2;
int main()
{
	cin>>s;
	for(int i=s.size()-1;i>=0;i--)
	{
		if(s[i]=='b') s2+='d';
		else if(s[i]=='d') s2+='b';
		else if(s[i]=='q') s2+='p';
		else s2+='q';
	}
	if(s2==s) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}
/*

*/


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var n int
	var l []int

	fmt.Scanf("%d", &n)
	l = make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &l[i])
	}

	isNg := false

	for i := n - 1; i > 0; i-- {
		diff := l[i-1] - l[i]
		if diff == 1 {
			l[i-1]--
		}
		if diff > 1 {
			isNg = true
			break
		}
	}

	if !isNg {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")
	}
}


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

using namespace std;

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

    cout << a << ":";

    vector<int> r;
    int j = 2;
    while (true) {
        if (a == 1) {
            break;
        }
        if (a % j == 0) {
            r.push_back(j);
            a /= j;
        }
        else {
            j += 1;
        }
        if (j *j > a) {
            r.push_back(a);
            break;
        }
    }
    for (int i : r) {
        cout << ' ' << i;
    }
    cout << endl;
}

Measured memory_bytes: 3152
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

#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;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e15 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

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

    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt", "w", stdout);
    // #endif
   int n, k;
   cin >> n >> k;
   int a = n%k;
   cout << min(a, abs(a-k)) << '\n';
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(H: int, W: int):
    if H == 1 or W == 1:
        print(1)
        exit()

    if W%2 == 0:
        print(H*W//2)
    else:
        if H%2 == 0:
            print(W*(H//2))
        else:
            print(W*(H//2)+W//2+1)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    solve(H, W)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import sys
input = sys.stdin.buffer.readline

H, W, M = map(int, input().split())

X = [0] * W
Y = [0] * H
Map = []

for _ in range(M):
    h, w = map(int, input().split())
    h -= 1
    w -= 1
    Y[h] += 1
    X[w] += 1
    Map.append((h, w))

MX = max(X)
MY = max(Y)
ans = MX + MY
Xans = set()
Yans = set()
for i, x in enumerate(X):
    if x == MX:
        Xans.add(i)
for i, y in enumerate(Y):
    if y == MY:
        Yans.add(i)
cnt = 0
for h, w in Map:
    if h in Yans and w in Xans:
        cnt += 1
if cnt == len(Xans) * len(Yans):
    ans -= 1
print(ans)


Measured memory_bytes: 195592
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b,k;
  cin>>a>>b>>k;
  if(a+b <= k) cout<<0<<" "<<0<<endl;
  else if(a <= k) cout<<0<<" "<<b-(k-a)<<endl;
  else cout<<(a-k)<<" "<<b<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int N;
int A[2][101];

int main() {
	int N; cin >> N;
	REP(i, 2) REP(j, N) scanf("%d", &A[i][j + 1]);
	REP(i, 2) REP(j, N) A[i][j + 1] += A[i][j];
	
	int ans = 0;
	REP(i, N) chmax(ans, A[0][i + 1] + A[1][N] - A[1][i]);
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void){

	int H, W;
	scanf("%d", &H);
	scanf("%d", &W);

	int i, j;
	char a[1000][1000];

 	for(i = 0; i < H; i++){
   		scanf("%s", a[i]);  
 	}
	
	char b[1000][1000];

	for(i = 0; i < H + 2; i++){
                for(j = 0; j < W + 2; j++){
                        b[i][j] = '#';
                }
        }

	for(i = 1; i < H + 1; i++){
                for(j = 1; j < W + 1; j++){
                        
			b[i][j] = a[i - 1][j - 1];
                }
        }	

	for(i = 0; i < H + 2; i++){
  		 printf("%s\n", b[i]);  
 	}	

	return 0;

}

Measured memory_bytes: 384
A,B,H,x,y = map(int,input().split(" "))
money = 0
if A + B <= H * 2:
    money += A * x
    money += B * y
else:
    if x >= y:
        money += (y * H) * 2
        if A <= H * 2:
            money += (x - y) * A
        else:
            money += (x - y) * (H * 2)
    else:
        money += (x * H) * 2
        if B <= H * 2:
            money += (y - x) * B
        else:
            money += (y - x) * (H * 2)
print(money) 

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
int main() {
	cin >> H >> W;
	vector<string>S(H);
	vector<int> h = { 1,1,1,0,0,0,-1,-1,-1 };
	vector<int> w = { 1,0,-1,1,0,-1,1,0,-1 };
	for (int i = 0; i < H; i++)cin >> S[i];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '.') {
				int tmp = 0;
				for (int k = 0; k < 9; k++) {
					if (i + h[k]<0 || i + h[k]>=H)continue;
					if (j + w[k]<0 || j + w[k]>=W)continue;
					if (S[i + h[k]][j + w[k]] == '#') {
						tmp++;
					}
				}
				S[i][j] = tmp + '0';
			}
		}
	}
	for (int i = 0; i < H; i++)cout << S[i] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define endl '\n'
#define pq priority_queue <pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> 
#define graph1 vector<vector<pair<ll,ll>>>
#define graph vector<vector<ll>>
#define pq1 priority_queue<pair<ll, pair<ll, ll>>, vector<pair<ll, pair<ll,ll>>>, greater<pair<ll, pair<ll, ll>>>>
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loop1(i,a,b) for (int i = a; i >= b; i--)
#define fast ios::sync_with_stdio(0); cin.tie(0);
using namespace std;
ll minn(ll one, ll two, ll three)
{
	if (one < two && one < three)
	{
		return one;
	}
	else if (two < one && two < three)
	{
		return two;
	}
	else
	{
		return three;
	}
}
int main()
{
	fast
		int n, s;
	cin >> n >> s;
	pair <int, int> x[105];
	ll sum = 0;
	loop(i, 0, n)
	{
		cin >> x[i].first;
		cin >> x[i].second;
		sum += x[i].second;
	}
	
	vector<ll> dp(sum + 5,1000000000000);
	dp[0] = 0;

	loop(i, 0, n)
	{
		loop1(j, sum - x[i].second , 0)
		{
			dp[j + x[i].second] = min(dp[j + x[i].second],dp[j] + x[i].first);

		}
	}
	int res = 0;
	loop(i, 0, sum + 1)
	{
		if (dp[i] <= s)
		{
			res = max(res, i);
		}
	}
	cout << res;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int s;
  cin>>s;
  vector<int>v(1000001),d(1000001);
  v[0]=s;
  int i=0;
  while(true){
    if(v[i]%2)
      v[i+1]=3*v[i]+1;
    else
      v[i+1]=v[i]/2;
    d[v[i]]++;
    if(d[v[i]]==2){
      cout<<i+1<<endl;
      return 0;
    }
    i++;
  }
}

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

string N;
int k;
int sum_1 , sum_2;
int cnt = 0 , f_number , s_number , f_loc;

int main ( void )
{
	cin >> N;
	cin >> k;
	if ( k == 1 ) {
		cout << ( N.size ( ) - 1 ) * 9 + N [ 0 ] - 48 << endl;
	} else if ( k == 2 ) {
		if ( N.size ( ) == 1 ) {
			cout << 0 << endl;
			return 0;
		}
		sum_1 += 81 * ( N.size ( ) - 2 ) * ( N.size ( ) - 1 ) / 2;
		sum_1 += ( N.size ( ) - 1 ) * 9 * ( N [ 0 ] - 48 - 1 );
		for ( int i = 1 ; i < N.size ( ) ; i++ ) {
			if ( N [ i ] != '0' ) {
				sum_1 += ( N.size ( ) - i - 1 ) * 9;
				sum_1 += N [ i ] - 48;
				break;
			}
		}
		cout << sum_1 << endl;
	} else {
		if ( N.size ( ) <= 2 ) {
			cout << 0 << endl;
			return 0;
		}
		sum_2 += 81 * ( N [ 0 ] - 48 - 1 ) * ( N.size ( ) - 1 ) * ( N.size ( ) - 2 ) / 2;
		for ( int i = 2 ; i <= N.size ( ) - 2  ; i++ ) {
			sum_2 += 729 * i * ( i - 1 ) / 2;
		}
		for ( int i = 1 ; i < N.size ( ) ; i++ ) {
			if ( N [ i ] != '0' && cnt == 0 ) {
				f_number = N [ i ] - 48;
				sum_2 += ( f_number - 1 ) * ( N.size ( ) - i - 1 ) * 9;
				f_loc = i;
				cnt++;
			} else if ( N [ i ] != '0' && cnt == 1 ) {
				s_number = N [ i ] - 48;
				sum_2 += ( N.size ( ) - i - 1 ) * 9 + s_number;
				break;
			}
		}
		/*
		if ( s_number == 0 && f_number != 0 ) {
			if ( f_loc == N.size ( ) - 2 ) {
				sum_2 += ( N.size ( ) - f_loc - 1 ) * 9 * ( f_number - 1 );
			} else {
				sum_2 += ( N.size ( ) - f_loc - 1 ) * 9 * f_number;
			}
		}*/
		if ( f_number != 0 ) {
			sum_2 += 81 * ( N.size ( ) - 1 - f_loc ) * ( N.size ( ) - 2 - f_loc ) / 2;
		}
		cout << sum_2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
using namespace std;
typedef long long ll;
inline ll min(int x, int y) { return x < y ? x : y; }
const int Maxn = 2e3 + 5;
inline int read()
{
	rg int res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n, m, ans;
int l[Maxn][Maxn], r[Maxn][Maxn], u[Maxn][Maxn], d[Maxn][Maxn];
char s[Maxn][Maxn];
int main()
{
	int a;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		scanf("%s", s[i] + 1);
	for (int i = 1; i <= n; i++)
		for (int 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;
			}
	for (int i = n; i >= 1; i--)
		for (int 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;
			}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if (s[i][j] == '.')
				ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
	cout << ans << endl;
	return 0;
}


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

int main(){
    int l, i=0, a[10000];
    while(cin>>l){
        if(l==0){
            break;
        }
        a[i] = l;
        cout << "Case "<< i+1 << ": " << a[i] << endl;
        i++;
    }
}


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

#define  __  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define  int  long long
#define  endl  '\n'
#define FOR(x,to) for(x=0;x<(to);x++)
const double pi = acos(-1);
const int mod = 1e9 + 7;
//______________________



int32_t main()
{ 
  __
  
    int i,j,k,l,r,x,y,N,K;
    vector<int> V;
    int num=0;
    cin>>N>>K;
    
    
    if(N==1&&K==1) 
    {
        cout<<-1<<endl;
        return 0;
    }

    if(N==1&&K==0) 
    {
        cout<<"0 0 1 1"<<endl;
        return 0;
    }
    if(K>=1<<N) 
    {
        cout<<-1<<endl;
        return 0;
    }
    
    FOR(i,1<<N) 
      if(i!=K) 
        cout<<i<<" ";

    cout<<K<<" ";

    for(i=(1<<N)-1;i>=0;i--) 
        if(i!=K) 
            cout<<i<<" ";
    
    cout<<K;


 return 0;
}

Measured memory_bytes: 1792
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::cmp;
use std::collections::HashMap;

fn main() {
    let n = get!(usize);
    let az: Vec<char> = "abcdefghijklmnopqrstuvwxyz".chars().collect();
    let c2i = az.iter().cloned().enumerate().map(|(i, e)| (e, i)).collect::<HashMap<_, _>>();
    let mut chars = vec![50; 26];

    for _ in 0..n {
        let mut cs = vec![0; 26];
        for c in get!(String).chars() {
            if let Some(i) = c2i.get(&c) {
                cs[*i] += 1;
            }
        }
        for i in 0..26 {
            chars[i] = cmp::min(chars[i], cs[i]);
        }
    }
    let mut s = Vec::new();
    for (i, n) in chars.iter().enumerate() {
        for _ in 0..*n {
            s.push(az[i]);
        }
    }
    println!("{}", s.into_iter().collect::<String>());
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  bool Y = false;
  cin >> N;
  for(int i = 0; i < N;i++){
    string s;
    cin >> s;
    if(s == "Y"){
      Y = true;
    }
  }
  if(Y){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
  
}

Measured memory_bytes: 3628
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#include <atcoder/segtree>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

using namespace std;

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}
template <class Con>
string concat(const Con &c, const string &spr){
	stringstream ss;
	typename Con::const_iterator it = c.begin(), en = c.end();
	bool fst = true;
	for(; it != en; ++it){
		if(!fst){ ss << spr; }
		fst = false;
		ss << *it;
	}
	return ss.str();
}

template <class Con, class Fun>
vector<typename Con::value_type> cfilter(const Con &c, Fun f) {
	vector<typename Con::value_type> ret;
	typename Con::const_iterator it = c.begin(), en = c.end();
	for(; it != en; ++it){
		if(f(*it)){
			ret.emplace_back(*it);
		}
	}
	return ret;
}
#if __cplusplus >= 201103L
template <class Con, class Fun>
auto cmap(const Con &c, Fun f) -> vector<decltype(f(*c.begin()))> {
	vector<decltype(f(*c.begin()))> ret;
	ret.reserve(c.size());
	for(const auto &x: c){
		ret.emplace_back(f(x));
	}
	return ret;
}
#endif


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()
#define tget(t,i) get<i>(t)

#define MOD 1000000007LL
#define EPS 1e-8

int op(int a, int b){ return max(a, b); }
int e(){ return 0; }

void mainmain(){
	const int offset = 10;
	const int size = 300020;

	int n, k;
	scanf("%d%d", &n, &k);
	atcoder::segtree<int,op,e> st(size);
	int ans = 0;
	for(int i = 0; i < n; ++i){
		int x;
		scanf("%d", &x);
		x += offset;
		int t = st.prod(max(x - k, 0), min(x + k + 1, size)) + 1;
		st.set(x, t);
		chmax(ans, t);
	}
	printf("%d\n", ans);
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(const exception &e){
	cerr << "exception: " << e.what() << endl;
	abort();
}
catch(...){
	cerr << "exception" << endl;
	abort();
}


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

const int mod = 1000000007;

int N, K;
int a[110];

int dp[110][100010];

int main() {
    cin >> N >> K;
    for(int i = 1; i <= N; i++)
        cin >> a[i];

    dp[0][0] = 1;
    for(int i = 1; i <= N; i++) {
        // 累積和を取る
        int sum[100010];
        sum[0] = 0;
        for(int j = 0; j <= K; j++)
            sum[j + 1] = (sum[j] + dp[i - 1][j]) % mod;

        for(int j = 0; j <= K; j++)
            // 負の mod に気を付ける
            dp[i][j] = (sum[j + 1] - sum[max(0, j - a[i])] + mod) % mod;
    }

    cout << dp[N][K] << endl;

    return 0;
}

Measured memory_bytes: 41216
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
// UnionFind
// coding: https://youtu.be/TdR816rqc3s?t=726
// comment: https://youtu.be/TdR816rqc3s?t=6822
struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
    ll N,M;
    cin >>N >>M;
    vector<vector<ll>> lang(M);
    for(int i=0;i<N;i++){
        int k;
        cin >>k;
        for(int j=0;j<k;j++){
            int l;
            cin >> l;
            --l;
            lang[l].push_back(i);
        }
    }
    UnionFind uf =UnionFind(N);
    for(int i=0;i<M;i++){
        if(lang[i].size()>1){
            int t = lang[i][0];
            for(int v:lang[i]){
                uf.unite(t,v);
            }
        }
    }
    if(uf.size(0) ==N){
        cout << "YES" << endl;
    }else{
        cout <<"NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 7752
from collections import Counter
M = 10**9 + 7
N = int(input())
A = list(map(int, input().split()))
ac = Counter(A)

def validate():
    uniq = N // 2
    if N % 2 == 1:
        uniq += 1
        if ac[0] != 1:
            return False
    if len(ac) != uniq:
        return False
    for k, v in ac.items():
        if k == 0 and v == 1:
            continue
        if v != 2:
            return False
        if N % 2 == k % 2:
            return False
    return True


def solve():
    if not validate():
        return 0
    return pow(2, N//2, M)


print(solve())


Measured memory_bytes: 14820
#include <stdio.h>

int main(void)
{
    int s1, s2, m1, m2, m3;
    int t;
    int i;
    
    m1 = m2 = 0;
    for (i = 0; i < 10; i++){
        scanf("%d", &t);
        if (t > m1){
            m3 = m2;
            m2 = m1;
            m1 = t;
        }
        else if (t > m2){
            m3 = m2;
            m2 = t;
        }
        else if (t > m3){
            m3 = t;
        }
    }
    s1 = m1 + m2 + m3;
    
    m1 = m2 = 0;
    for (i = 0; i < 10; i++){
        scanf("%d", &t);
        if (t > m1){
            m3 = m2;
            m2 = m1;
            m1 = t;
        }
        else if (t > m2){
            m3 = m2;
            m2 = t;
        }
        else if (t > m3){
            m3 = t;
        }
    }
    s2 = m1 + m2 + m3;
    
    printf("%d %d\n", s1, s2);
    
    return (0);
}

Measured memory_bytes: 0
# ABC095
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
left_median = Y[N // 2 - 1]
right_megian = Y[N // 2]
if left_median == right_megian:
    for i in range(N):
        print(left_median)
else:
    for i in X:
        if i > left_median:
            print(left_median)
        else:
            print(right_megian)

Measured memory_bytes: 25228
X = [[0 for i in range(3)] for j in range(3)]
for x in range(3):
    Y = list(map(int,input().split()))
#    print(Y)
    #print(Y[0])
    for y in range(3):
        X[x][y] = Y[y]
#        print(x,y,X[x][y],Y[y])
#print(X)


N = int(input())
B = []
for x in range(N):
    B.append(int(input()))
#print(X)
#print(B)
for x in B:
    for y in range(3):
        for z in range(3):
            if(X[y][z] == x):
                X[y][z] = True
ans = "No"
for x in range(3):
    if(X[x][0] == True and X[x][1] == True and X[x][2] == True):
        ans = "Yes"
    if(X[0][x] == True and X[1][x] == True and X[2][x] == True):
        ans = "Yes"
if(X[0][0] == True and X[1][1] == True and X[2][2] == True):
    ans = "Yes"
if(X[0][2] == True and X[1][1] == True and X[2][0] == True):
    ans = "Yes"
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n,t,min=1000000009,max=0;
  cin>>n>>t;
  vector<int> a(n);
  std::map<int, int> mp;
  for (int i = 0; i < n; ++i)
  {
    cin>>a[i];
    mp[(min>a[i] ? 0:a[i]-min)]++; 
    max=std::max(max,a[i]-min);
    min=std::min(min,a[i]);
  }
  cout<<mp[max];
}

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

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

    long long ans = 0;

    for(long long i=1; i<N+1; i++){
        if(i%3 != 0 && i%5 != 0){
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val w, h, c = sc.nextInt
    println(w * h * c / gcd(w, h) / gcd(w, h))
  }

  def gcd(i: Int, j: Int): Int = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}




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

int main(void) {
    int a,b,c;
    cin >> a >> b >> c;
    int one = a*10 + b + c;
    int two = a + b*10 + c;
    int the = a + b + c*10;
    cout << max(max(one,two),the) << endl;
    return 0;
}


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

using namespace std;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);
int sub(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);

const int N=500001;

void solve(){
	int n;
	cin>>n;
	vi a(n);
	cin>>a;
	sort(all(a));
	int flag=0;
	for(int i=0;i<n;i++){
		flag^=a[i];
	}
	if(flag)cout<<"No";
	else cout<<"Yes";
	
    
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//cin>>tc;
	for(int _=0;_<tc;_++){
		//cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}

int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}

void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}

int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}

int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;
}


Measured memory_bytes: 640
//JSD
#include<iostream>
#include<vector>
#include<set>
#define ll long long 
#include<algorithm>
using namespace std;
int main(){
	string s; set<char > st;
	int n;
	cin>>n;
	ll d[n];
	for(int i=0;i<n;i++) cin>>d[i];
	sort(d,d+n);
	ll x=d[n/2-1],y=d[n/2];
	if(x==y) cout<<"0";
	else 
	cout<<y-x<<"\n";
	return 0;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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;
}

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

class UnionFind {
    vector<int> data;
    int num;

  public:
    UnionFind(int size) : data(size, -1), num(size) {}
    bool unionSet(int x, int y) {
        x = root(x);
        y = root(y);
        if(x != y) {
            if(data[y] < data[x])
                swap(x, y);
            data[x] += data[y];
            data[y] = x;
            num--;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
    int numSet() {
        return num;
    }
};

void solve() {
    ll n, m;
    cin >> n >> m;
    UnionFind uni(n);
    UnionFind ni(2 * n); //二部グラフ判定

    REP(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        uni.unionSet(a, b);
        ni.unionSet(a, b + n);
        ni.unionSet(b, a + n);
    }

    ll con1 = 0;
    ll con2 = 0; //二部グラフ
    ll con3 = 0;
    ll ans = 0;
    REP(i, n) {
        if(uni.root(i) != i)
            continue;
        if(uni.size(i) == 1) {
            //孤立点
            con1++;
            ans += (n - con1) * 2 + 1;
            continue;
        }
        if(ni.root(i) != ni.root(i + n)) {
            //二部グラフ
            con2++;
        } else {
            con3++;
        }
    }

    ans += con3 * con3;
    ans += con3 * con2 * 2;
    ans += con2 * con2 * 2;

    cout << ans << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 4516
#include<stdio.h>
int main()
{
    int n,n1,n2,i;
    int sum=0,m,nn;
    scanf("%d",&n);
    nn=n;
    while(n!=0){
        m=n%10;
        sum=sum+m;
        n=n/10;
    }
        if(nn%sum==0){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    return 0;
}


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

bool isOK(int x){
  bool a=0,b=0,c=0;
  while(x>0){
    if(x%10==3) a=1;
    if(x%10==5) b=1;
    if(x%10==7) c=1;
    x/=10;
  }
  if(a&&b&&c) return 1;
  else return 0;
}

int u[]={3,5,7};

void dfs(int n, int d, vector<int> &vec){
  if(d==10) return;
  vec.push_back(n);
  for(int tmp=0; tmp<3; tmp++){
    dfs(n*10+u[tmp],d+1,vec);
  }
}

int main(){
  int n;
  cin>>n;
  vector<int> vec,num;
  dfs(3,1,vec);
  dfs(5,1,vec);
  dfs(7,1,vec);
  sort(vec.begin(),vec.end());
  for(auto x : vec){
    if(isOK(x)) num.push_back(x);
  }
  int ans=0;
  for(auto x : num){
    if(x > n) continue;
    ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define L_T_S_K ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
const int mod = 1e9 + 7;
const int N = 1e4 + 9;
int dp[N];

int32_t main(){
 L_T_S_K;
 int H , n;
 cin >> H >> n;
 std::vector<pair <int ,int > > v(n);
 for(int i = 0 ; i < n ;i++){
  cin >> v[i].first >> v[i].second;
 } 
 //dp[i] min spell to deal i damage
 for(int i = 1 ; i <= H ;i++){
  dp[i] = mod;
 }
 for(int i = 1 ; i <= H ;i++){
  for(int j = 0 ; j < n ;j++){
    dp[i] = min(dp[i] , v[j].second + dp[max(0ll ,i - v[j].first)]);
  }
 }
 cout << dp[H];

 return 0;
} 

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

int n;
vec<int> v;

bool bin(int x) {
   int left = 0, right = n;
   while (left < right) {
      int mid = (left+right)/2;
      if (v[mid] > x) {
         right = mid;
      } else if (v[mid] < x) {
         left = mid + 1;
      } else {
         return true;
      }
   }
   return false;
}

int main() {
   cin >> n;
   rep (i, 0, n) {
      int x;
      cin >> x;
      v.push_back(x);
   }
   sort(all(v));

   int q;
   cin >> q;
   int cnt = 0;
   rep (i, 0, q) {
      int x;
      cin >> x;
      // if (bin(x)) cnt++;
      if (binary_search(all(v), x)) cnt++;
   }
   cout << cnt << endl;

   return 0;
}


Measured memory_bytes: 3516
import collections
N=int(input())
A=list(map(int,input().split()))
cnt=collections.Counter(A)
s=0
for key in cnt.keys():
  s+=cnt[key]*(cnt[key]-1)//2
for i in range(N):
  tmp=s
  tmp-=cnt[A[i]]*(cnt[A[i]]-1)//2
  tmp+=(cnt[A[i]]-1)*(cnt[A[i]]-2)//2
  print(tmp)

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

const int MOD = 1e9 + 7;
#define ll long long


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

	vector<int> arr(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}

	int ans = INT32_MAX;
	for (int t = 0; t < n; t++)
	{
		int s1 = 0;
		int s2 = 0;

		for (int i = 0; i < n; i++)
		{
			if (i < t)
			{
				s1 += arr[i];
			}
			else
			{
				s2 += arr[i];
			}
		}

		ans = min(ans, abs(s1 - s2));
	}

	cout << ans << endl;
}

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

struct Card {
    char suit;
    char value;
};

void bubble(struct Card A[],int N) {
    for (int i=0; i<N; i++) {
        for (int j=N-1; j>=i+1; j--) {
            if (A[j].value<A[j-1].value) {
                Card t=A[j];
                A[j]=A[j-1]; 
                A[j-1]=t;
            }
        }
    }
}
void selection(struct Card A[],int N) {
    for (int i=0; i<N; i++) {
        int minj=i;
        for (int j=i; j<N; j++) {
            if (A[j].value<A[minj].value) {
                minj=j; 
            }
        }
        Card t=A[i];
        A[i]=A[minj];
        A[minj]=t;
    }
}
void print(struct Card A[],int N) {
    for (int i=0; i<N; i++) {
        printf("%s%c%c",((i==0)?"":" "),A[i].suit,A[i].value);
    }
    printf("\n");
}
bool isStable(struct Card C1[],struct Card C2[], int N) {
    for (int i=0; i<N; i++) {
        if (C1[i].suit!=C2[i].suit) {
            return false;
        }
    }
    return true;
}
int main() {
    int N;
    cin >> N;
    Card C1[N];
    Card C2[N];
    for (int i=0; i<N; i++) {
        cin >> C1[i].suit >> C1[i].value;
        C2[i]=C1[i];
    }
    bubble(C1,N);
    selection(C2,N);
    print(C1,N);
    printf("Stable\n");
    print(C2,N);
    if (isStable(C1,C2,N)) {
        printf("Stable\n");
    } else {
        printf("Not stable\n");
    }
    return 0;
}

Measured memory_bytes: 3228
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int[] P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = sc.nextInt();
        }
        int[] wake = new int[3];
        for (int i = 0; i < N; i++) {
            if (P[i] <= A) wake[0]++;
            else if (P[i] <= B) wake[1]++;
            else wake[2]++;
        }
        System.out.println(Math.min(Math.min(wake[0], wake[1]), wake[2]));
        sc.close();
    }
}

Measured memory_bytes: 22740
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final char[] chars = scanner.nextLine().toCharArray();
 
        if(isMonth(chars[0],chars[1]) && isMonth(chars[2],chars[3])){
            System.out.println("AMBIGUOUS");
        } else if (isMonth(chars[0], chars[1]) && !isMonth(chars[2], chars[3])) {
            System.out.println("MMYY");
        } else if(!isMonth(chars[0],chars[1]) && isMonth(chars[2],chars[3])){
            System.out.println("YYMM");
        }else{
            System.out.println("NA");
        }
    }
 
    private static boolean isMonth(final char a, final char b) {
        if (a == '0') {
            return !(b ==  '0');
        } else if (a == '1') {
            return b == '0' || b == '1' || b == '2';
        } else {
            return false;
        }
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
const int mod=998244353;
int n,q,x,y,tp;
ll ans;
int l[800001],r[800001],qwq[200001];
int m1[800001],m2[800001];
inline void build(int i,int lf,int rf){
	l[i]=lf,r[i]=rf;
	m1[i]=m2[i]=n-1;
	if(lf==rf){
		qwq[lf]=i;
		return;
	}
	int mid=(lf+rf)>>1;
	build(i<<1,lf,mid),build(i<<1|1,mid+1,rf);
}
inline void modify(int i,int x,int y,int z,int opt){
	if(l[i]>y||r[i]<x) return;
	if(x<=l[i]&&y>=r[i]){
		if(opt) m2[i]=min(m2[i],z);
		else m1[i]=min(m1[i],z);
		return;
	}
	modify(i<<1,x,y,z,opt),modify(i<<1|1,x,y,z,opt);
}
inline int query(int x,int opt){
	x=qwq[x];
	int tp=1ll<<30;
	while(x){
		if(opt) tp=min(tp,m2[x]);
		else tp=min(tp,m1[x]);
		x>>=1;
	}
	return tp;
}
int main(){
	cin>>n>>q;
	build(1,1,n-2);
	ans=1ll*(n-2)*(n-2);
	while(q--){
		scanf("%d%d",&x,&y);
		y--;
		if(x==1){
			tp=query(y,0);
			if(tp>1) ans-=tp-1,modify(1,1,tp-1,y,1);
		}
		else{
			tp=query(y,1);
			if(tp>1) ans-=tp-1,modify(1,1,tp-1,y,0);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 12736
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            (long N, long M) = Slice2<long>();
            if (M <= 2 * N)
            {
                WriteLine(M / 2);
                return;
            }
            WriteLine(N + (M - 2 * N) / 4);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27540
import sys
MOD = 10**9+7
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
used_a = [False for _ in range(n)]
used_b = [False for _ in range(m)]
u_a_num = 0
u_b_num = 0
if len(set(a)) != n or len(set(b)) != m:
	print(0)
	sys.exit()

def search(num):
	x, y = -1, -1
	for i in range(n):
		if a[i] == num:
			x = i
			break
	for i in range(m):
		if b[i] == num:
			y = i
			break
	return x, y

ans = 1
zero_count = n+m
one_hidden = 0
for i in range(n*m, 0, -1):
	x, y = search(i)
	if x>=0 and y>=0:
		if used_a[x] == True or used_b[y] == True:
			ans *= 0
		else:
			used_a[x] = True
			used_b[y] = True
			u_a_num += 1
			u_b_num += 1
	elif x>=0 and y<0:
		ans = (ans*u_b_num) % MOD
		used_a[x] = True
		u_a_num += 1
	elif x<0 and y>=0:
		ans = (ans*u_a_num) % MOD
		used_b[y] = True
		u_b_num += 1
	else:
		ans = (ans* max(0, (u_a_num*u_b_num - (n*m - i)))) % MOD

	if u_a_num+u_b_num == n+m:
		J = i
		break

for j in range(J-1, 0, -1):
	ans = (ans*j) % MOD

print(ans)

Measured memory_bytes: 43884
#include <stdio.h>

void rec(int,int);

int n,q;
int A[20];
int M;

int flag=0;
int B[20];

int main(){
    
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&M);
    
    flag=0;
    rec(0,0);
    
    if ( flag == 1){
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }
  
  return 0;
}

void rec(int a,int b){
  if(flag==1||b>M)return;
  if(a==n){
    if(b==M)flag=1;
  }else{
    rec(a+1,b+A[a]);
    rec(a+1,b);
  }
  
}

Measured memory_bytes: 580
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, A, B;
  cin>>N>>A>>B;
  int tmp;
  int anum=0, bnum=0, cnum=0;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    if(tmp<=A) anum++;
    else if(tmp<=B) bnum++;
    else cnum++;
  }
  cout<<min(anum, min(bnum, cnum))<<endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
    int n,m;
    cin >> n>> m;
    vector<ll> data(n);
    rep(i,0,n){
        cin >> data[i];
    }
    sort(data.begin(),data.end());
    vector<pair<ll,ll>> plus(m);
    rep(i,0,m){
        ll s,t;
        cin >> s>>t;
        plus[i].first = t;
        plus[i].second = s;
    }
    sort(plus.begin(),plus.end());
    reverse(plus.begin(),plus.end());
    //cout<<plus[0].first<<endl;
    ll k = 0;
    rep(i,0,m){
        rep(j,0,plus[i].second){
            if(data[k]<plus[i].first){
                data[k]=plus[i].first;
                k++;
            }else{
                break;
            }
        }
    }
    ll sum = 0;
    rep(i,0,n){
        sum += data[i];
    }
    cout<<sum<<endl;


    return 0;
}


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

using pii = pair<int, int>;
using ll  = long long;
#define rep(i, j) for (int i = 0; i < (int)(j); i++)
#define repeat(i, j, k) for (int i = (j); i < (int)(k); i++)
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " : " << x << endl

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

template <class T>
bool set_max(T &a, const T &b) {
    return a < b ? a = b, true : false;
}
// vector
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &a : v) is >> a;
    return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &t : v) os << "\t" << t;
    return os << endl;
}
// pair
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &v) {
    return os << "<" << v.first << ", " << v.second << ">";
}

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

int sum(int x) {
    int s = 0;
    while(x > 0) {
        s += x % 10;
        x /= 10;
    }
    return s;
}

int main() {    
    string S; cin >> S;
    reverse(all(S));
    vector<int> sum(S.size() + 1);
    ll ans = 0;
    vector<int> cnt(2019+1);    
    cnt[0] = 1;
    ll a = 1;
    rep(i, S.size()) {
        sum[i + 1] = (sum[i]  + (S[i] - '0') * a) % 2019;
        ans += cnt[sum[i+1]];
        cnt[sum[i + 1]]++;        
        a = (a * 10) % 2019;
    }
    //debug(sum);
    //rep(i, sum.size()) cerr << sum[i] << "\t";
    //cerr << endl;
    //rep(i, sum.size()) cerr << 2019 - sum[i] << "\t";
    //cerr << endl;
    cout << ans << endl;                

    return 0;
}


Measured memory_bytes: 4384
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
int main(){
	int n;
	int cnt, max;
	string s;
	cin >> n >> s;
	cnt = 0;
	max = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I')cnt++;
		else cnt--;
		max = std::max(max, cnt);
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256