akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//using
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;

//関数マクロ
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl

//定数マクロ
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);

//テンプレート関数
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; }
//intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); } //c++17からある
//intl lcm(intl a,intl b){ return a / gcd(a, b) * b; } //c++17からある

//自作テンプレート関数
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}//Yes,Noの出力を楽にするよう
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}//上の関数のYes,Noを任意の文字列でできるようにしたもの
intl kai(intl k){ intl a = 1; for(int i = 2; i <= k; i++){ a *= i; } return a; }//k!を求める関数,O(N)
intl digit10(intl a){ intl b = 0; do{ a /= 10; b++; }while(a); return b; }//aを10進数で表したときの桁数を求める関数,桁数回の演算だからだいたいO(logN)くらい?



signed main(){
    cout << fixed << setprecision(10);
    int d;
    cin >> d;
    int c[26];
    rep(i,26)cin >> c[i];
    int s[d][26];
    rep(i,d){
        rep(j,26)cin >> s[i][j];
    }
    int last_day[26];
    m0(last_day);
    intl ans = 0;
    rep(i,d){
        int idx = -1;
        int mx = -INF;
        rep(j,26){
            int ans0 = ans;
            ans0 += s[i][j];
            rep(k,26){
                if(j != k)ans0 -= (c[k] * ((i + 1) - last_day[k])); 
            }
            if(chmax(mx,ans0))idx = j;
            //debug(ans0);
        }
        ans += s[i][idx];
        last_day[idx] = i + 1;
        rep(j,26){
            ans -= (c[j] * ((i + 1) - last_day[j])); 
        }
        cout << idx + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define pb push_back
#define __ ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() {
 //   __

    ll n ;
    cin >> n ;

ll    x = ( (n+999)/1000) * 1000 - n ;
    cout << x << endl ;

    return 0 ;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
int main(){
    ll a,b,c,k,ans=0;
    cin>>a>>b>>c>>k;
    if(k<a){
        cout<<k<<endl;
        return 0;
    }
    if(a<=k){
        ans+=a;
        k-=a;
    }
    if(b>k){
        cout<<ans<<endl;
        return 0;
    }
    if(b<=k){
        k-=b;
    }
    ans-=k;
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
A, B, K = map(int, input().split())

if (A + K) - (B - K) > 0:
    for i in range(A, B + 1):
        print(i)
else:
    for k in range(A, K + A):
        print(k)
    for k in range(B - K + 1, B + 1):
        print(k)

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int check(const char *name, const char *old){
	char p1, p2;
	int wid = 0, o_length = strlen(old), n_length = strlen(name);

	rep(i, o_length){
		p1 = old[i];
		if(p1 != name[0]) continue;
		for(int j=i+1; j<o_length; j++){
			p2 = old[j];
			if(p2 != name[1]) continue;
			wid = j-i;

			for(int k=0; k<n_length; k++){
				if(i+wid*k > o_length || name[k] != old[i+wid*k]) break;
				if(k == n_length-1){
					return 1;
				}
			}
		}
	}
	return 0;
}

int main(){
	int N;
	int counter = 0;
	char name[26], old[101];

	cin >> N; cin.ignore();
	cin >> name; cin.ignore();

	rep(i, N){
		cin >> old; cin.ignore();

		counter += check(name, old);
	}
	cout << counter << endl;

	return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0, ed_##i = n; i < ed_##i; i++)
#define FOR(i, n) for(int i = 1, ed_##i = n; i <= ed_##i; i++)
#define bit(x) (1 << (x))
#define bitl(x) (1LL << (x))
#define sqr(x) ((x) * (x))
#define cnti(x) (__builtin_popcount(x))
#define cntl(x) (__builtin_popcountll(x))
#define clzi(x) (__builtin_clz(x))  // Leading zeros
#define clzl(x) (__builtin_clzll(x))
#define ctzi(x) (__builtin_ctz(x))
#define ctzl(x) (__builtin_ctzll(x))

#ifdef QWERTIER
#define err(x) cerr << #x << " : " << x << endl
#else
#define err(x)
#endif

typedef long long LL;
using namespace std;

typedef pair<int,int> pii;
#define MP make_pair

int main(){
#ifdef QWERTIER
  freopen("in.txt","r",stdin);
#endif
  int n;
  scanf("%d", &n);
  map<int, int> cnt;
  FOR (i, n) {
    int a;
    scanf("%d", &a);
    cnt[a]++;
  }
  LL max1 = 0, max2 = 0;
  for (auto it = cnt.rbegin(); it != cnt.rend(); ++it) {
    auto x = *it;
    if (x.second >= 4) {
      if (max1 < x.first)
        max1 = x.first;
      if (max2 < x.first)
        max2 = x.first;
    } else if (x.second >= 2) {
      if (max1 < x.first)
        max1 = x.first;
      else if (max2 < x.first)
        max2 = x.first;
    }
  }
  cout << max1 * max2;
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define fi first
#define se second
#define mk make_pair
using namespace std;
const int MAXN = 2e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
typedef long long LL;
typedef pair<int, int> PII;
double p[MAXN], sum[MAXN];


int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    sum[0] = 0;
    for(int i = 1; i <= n; ++i){
        scanf("%lf", &p[i]);
        p[i] = (1.0 + p[i]) / 2.0;
        sum[i] = sum[i-1] + p[i];
    }
    double ans = 0;
    for(int i = 1; i <= n - k + 1; ++i){
        ans = max(ans, sum[i + k - 1] - sum[i - 1]);
    }
    printf("%.10f\n", ans);
    return 0;
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

    string s;

    cin >> s;

    if(s[0] == '7' || s[1] == '7' || s[2] == '7'){
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 3628
# coding: utf-8
# Your code here!

S = int(input())
lis = []
for item in range(0,int(S)):
    tmp = input()
    lis.append(int(tmp))
ls = sorted(lis)
#print(ls)
#print(ls[int(S/2)])
i = 1
lo = 0
hg = int(S)-1
ans2 = 0
if True:#S % 2 == 1 :
    ans =  ls[hg]- ls[int(S/2-0.5)]
    #print(ans)
    for k in range(0,int(S/2)+1):
        #print(i)
    # TODO: write code...
    # TODO: write code...
    # TODO: write code...
        #if(k != 0):
        #    hg-=1
        if(i == int(S)-1):
            break
        ans = ans + ls[hg] - ls[lo]
        i+=1
        #print(ls[hg],ls[lo])
        hg-=1
        #print(i)
        #print(ans)
        if(i == int(S)-1):
            break
        ans = ans + ls[hg] - ls[lo]
        #print(ls[hg],ls[lo])
        lo+=1
        i+=1
        #print(ans)
tmp1 = ans


if S % 2 == 1:
    ls = sorted(lis,reverse=True)
    #print(ls)
    lo = 0
    hg = int(S)-1
    ans2 =  ls[int(S/2)]-ls[hg]
    #print(ans2)
    i = 1
    for k in range(0,int(S/2)+1):
        #print(i)
    # TODO: write code...
    # TODO: write code...
    # TODO: write code...
        #if(k != 0):
        #    hg-=1
        if(i == int(S)-1):
            break
        ans2 = ans2 + ls[lo]-ls[hg]
        i+=1
        #print(ls[hg],ls[lo])
        hg-=1
        #print(i)
        #print(ans)
        if(i == int(S)-1):
            break
        ans2 = ans2 +  ls[lo]-ls[hg]
        #print(ls[hg],ls[lo])
        lo+=1
        i+=1




print(max(ans2,tmp1))
 #   hg-=1
 #   print(ls[hg] , ls[lo])
 #   ans= ans + (ls[hg] - ls[lo])
 #   print(ans)
 #   ans = ans + (ls[hg] - ls[lo])
 #   lo+=1
 #   hg-=1
 #   print(ls[hg] , ls[lo])
 #   print(ans)


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

int n;
long long cnt[4001][4001];
long long recv[4001][4001];

long long F[100001];
long long invF[100001];
long long mod = 1000000000 + 7;

long long power(long long a, long long b)
{
	long long ret = 1;
	while(b)
	{
		if(b&1)
			ret = (ret * a) % mod;
		a = (a * a) % mod;
		b /= 2;
	}
	return ret;
}


long long inv(long long x)
{
	return power(x, mod - 2);
}


long long C(int a, int b)
{
	long long ret = F[a];
	ret *= invF[b];
	ret %= mod;
	ret *= invF[a-b];
	ret %= mod;
	return ret;
}

int MAIN()
{
	F[0] = invF[0] = 1;
	for(int i = 1; i <= 100000; i++)
	{
		F[i] = (F[i-1] * i) % mod;
		invF[i] = inv(F[i]);
	}

	long long sum = 0;
	memset(cnt, 0, sizeof(cnt));
	memset(recv, 0, sizeof(recv));
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		int x, y;
		cin >> x >> y;
		cnt[2000-x][2000-y] ++;
		recv[2000+x][2000+y] ++;
		sum -= C(2*x+2*y,2*x);
		sum %= mod;
		sum += mod;
		sum %= mod;
	}
	
	for(int i = 0; i <= 4000; i++)
		for(int j = 0; j <= 4000; j++)
		{
			if(i > 0)
				cnt[i][j] = (cnt[i][j] + cnt[i-1][j]) % mod;
			if(j > 0)
				cnt[i][j] = (cnt[i][j] + cnt[i][j-1]) % mod;
		}
	
	for(int i = 0; i <= 4000; i++)
		for(int j = 0; j <= 4000; j++)
		{
			sum += (cnt[i][j] * recv[i][j]) % mod;
			sum %= mod;
		}
	sum *= inv(2);
	sum %= mod;
	cout << sum << endl;
	
	return 0;
}

int main()
{
	int start = clock();
	#ifdef LOCAL_TEST
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	ios :: sync_with_stdio(false);
	cout << fixed << setprecision(16);
	int ret = MAIN();
	#ifdef LOCAL_TEST
		cout << "[Finished in " << clock() - start << " ms]" << endl;
	#endif
	return ret;
}


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

using namespace std;

const int N = 1e2 + 5, M = 1e6 + 6, OO = 0x3f3f3f3f;

long long n, k;

int main()
{
	cin >> n >> k;
	if(n % k == 0)
		puts("0");
	else if(n < k)
		cout << min(n, abs(n - k)) << endl;
	else
		cout << min(n - k, abs(n - k * ((n / k) + 1))) << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s1: String,
        s2: String,
        s3: String,
    }
    println!("A{}C", s2.chars().nth(0).unwrap());
} 


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define MOD 1000000007ll
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
int a[200100],b[200100];
int A[200100],B[200100];
int solve(int k){
	int K = (1<<k);
	for(int i=0;i<N;i++)B[i]=b[i]%K;
	sort(B,B+N);
	int res = 0;
	for(int i=0;i<N;i++){
		if(N%2==1){
			if((a[i]>>k)&1)res^=1;
			if((b[i]>>k)&1)res^=1;
		}
		int idx = lower_bound(B,B+N,K-(a[i]%K))-B;
		res ^= ((N-idx)&1);
	}
	return res;
}
int main(){
	scanf("%d",&N);
	int ans = 0;
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<N;i++){
		scanf("%d",&b[i]);
	}
	for(int i=0;i<30;i++){
		ans += solve(i)<<i;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
n = int(input())
adj_list = [ [0]*n for _ in range(n) ]

for _ in range(n):
    lst = list(map(int, input().split()))
    
    x = lst[0] - 1
    
    if lst[1] == 0:
        continue
    
    for y in lst[2:]:
        adj_list[x][y-1] = 1
    
for r in adj_list:
    print(" ".join([ str(v) for v in r]))


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

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> A(M);
  rep (i,M) {
    cin>>A.at(i);
    A.at(i)--;
  }
  
  vector<long> dp(N+10);
  dp.at(0)=1;
  dp.at(1)=2;
  if(M>0){
    if(0==A.at(0)){
      if(M>1&&A.at(1)==1){
        dp.at(0)=0;
        dp.at(1)=0;
        
      }
      else {
        dp.at(0)=0;
        dp.at(1)=dp.at(0)+1;
        
      }
    }
    else if(A.at(0)==1){
      dp.at(0)=0;
      dp.at(1)=1;
            
    }
  }
  int INF=1000000007;
  rep(i,M){
    if(A.at(i)>=1){
    dp.at(A.at(i))=INF;
    }
  }
  rep2(i,2,N) {
    if(dp.at(i)!=INF){
      dp.at(i)=(dp.at(i-1)+dp.at(i-2))%1000000007;
    }
    else{
      dp.at(i)=0;
    }
    

  }
  
  cout<<dp.at(N-1)<<endl;
  
}



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






int main() {
	ios_base::sync_with_stdio(false);

	int can[101] = {0};
	for (int i = 1; i < 10; ++i) for (int j = 1; j < 10; ++j) can[i*j] = true;
	int n;
	cin >> n;
	if (can[n]) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = __int64_t;

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

void solve(){
  int n;
  double x, sum=0;
  string u;
  cin >> n;
  rep(i, n){
    cin >> x >> u;
    if(u == "BTC"){
      sum += 380000.0 * x;
    }else{
      sum += x;
    }
  }
  printf("%lf\n", sum);
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
now = 1
brok = 0
for i in range (n):
    if(A[i] != now):
        brok += 1
    else:
        now += 1
if(now == 1):
    print(-1)
else:
    print(brok)
        


Measured memory_bytes: 26268
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
int main() {
    string s,t,u;
    ll a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(s==u)a--;
    else b--;
    cout<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
x, y = map(int, input().split())

s = s.split("T")
s_x = []
s_y = []
for i in range(0,len(s),2):
    s_x.append(s[i])
for i in range(1,len(s),2):
    s_y.append(s[i])
x_cou = []
y_cou = []
for i in range(len(s_x)):
    x_cou.append(s_x[i].count("F"))
for j in range(len(s_y)):
    y_cou.append(s_y[j].count("F"))

if sum(x_cou) < abs(x) or sum(y_cou) <abs(y):
    print("No")
    exit()

x = x - x_cou[0]
x_list = set([0])
for i in range(len(x_cou)-1,0,-1):
    new_xlist = set()
    for j in range(len(x_list)):
        k = x_list.pop()
        new_xlist.add(k + x_cou[i])
        new_xlist.add(k - x_cou[i])
    x_list = new_xlist

y_list = set([0])
for i in range(len(y_cou)-1,-1,-1):
    new_ylist = set([])
    for j in range(len(y_list)):
        l = y_list.pop()
        new_ylist.add(l + y_cou[i])
        new_ylist.add(l - y_cou[i])
    y_list = new_ylist

if x in x_list and y in y_list:
    print("Yes")
else:
    print("No")


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

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  if (a == b && a == c && b == c || a != b && a != c && b != c) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#pragma GCC optimize ("trapv")
using namespace std;

#define pii pair<int, int>
#define pll pair<long long, long long>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define DEBUG 1
#define cerr if (DEBUG) cerr
#define test cerr << "hi\n";

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<long long>(l, r)(rng)
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OST;

#define INF 0x3f3f3f3f3f3f3f3f
#define MAXN 500005
//#define MOD 998244353LL
#define MOD 1000000007LL

int n, m;
vector<int> p[MAXN];

void solve() {
    cin >> n >> m;
    for (int i = 0, a, b; i < n; i++) {
        cin >> a >> b;
        if (m-a >= 0) {
            p[m-a].pb(b);
        }
    }

    priority_queue<int> q;
    long long ans = 0;
    for (int i = m; i >= 0; i--) {
        for (int x : p[i])
            q.push(x);
        if (q.size()) {
//            cerr << "take " << q.top() << " on day " << i << '\n';
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << '\n';
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    auto start_time = clock();
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
//    cin >> t;
    for (int no = 1; no <= t; no++) {
//        cout << "Case #" << no << ": ";
        solve();
    }

#ifdef LOCAL
    cerr << "TIME ELAPSED: " << double(clock() - start_time) / CLOCKS_PER_SEC << '\n';
#endif
}

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

int main() {
    int n;
    cin >> n;
    deque<int> deq;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        if (n % 2 == 0) {
            if (i % 2 == 0) {
                deq.push_back(a);
            } else {
                deq.push_front(a);
            }
        } else {
            if (i % 2 == 0) {
                deq.push_front(a);
            } else {
                deq.push_back(a);
            }
        }
    }

    while (!deq.empty()) {
        cout << deq.front() << " ";
        deq.pop_front();
    }
    cout << endl;
    return 0;
}

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

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];

int main(void){

  cin.tie(0);
  ios::sync_with_stdio(false);

  int W, a, b;
  cin >> W >> a >> b;

  cout << max(max(b-a-W, a-b-W), 0) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });


void solve(long long A, long long B){
	ll res = 0;
	if (A<=5) res = 0;
	else if (6<=A && A<=12) res = B/2;
	else res = B;
	cout << res << "\n";
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
# A
a, b = map(int, input().split())

p = [2,3,4,5,6,7,8,9,10,11,12,13,1]
if p.index(a) < p.index(b):
    print('Bob')
elif p.index(a) > p.index(b):
    print('Alice')
elif p.index(a) == p.index(b):
    print('Draw')

Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.trim_right().to_string()
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let n = parse_line!(usize);

    let mut sum = 0;

    for i in 0..=n {
        if i % 3 != 0 && i % 5 != 0 {
            sum += i
        }
    }

    println!("{}", sum);
}


Measured memory_bytes: 2108
S = str(input())
S = S.replace("BC","D")
A_count = 0
ans = 0

for i in range(len(S)):
  if S[i] == 'A':
    A_count += 1
  elif S[i] == 'D':
    ans += A_count
  else:
    A_count = 0
print(ans)

Measured memory_bytes: 3500
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = in.nextInt();
            }

            int countMinus = 0;
            int minValue = (int) 1e9 + 2;
            long sum = 0;
            for (int i = 0; i < N; i++) {
                if (A[i] < 0) {
                    countMinus++;
                }
                minValue = Math.min(minValue, Math.abs(A[i]));
                sum += Math.abs(A[i]);
            }

            System.out.println(countMinus % 2 == 0 ? sum : (sum - 2 * minValue));
        }
    }

}


Measured memory_bytes: 50124
#include <stdio.h>

#define MIN(a, b)	((a) < (b) ? (a) : (b))
int main(void)
{
	int N, A, B;
	int P[3] = {0, 0, 0};
	int tempP;
	int i;
	int min;
	
	scanf("%d%d%d", &N, &A, &B);
	for(i = 0; i < N; i++){
		scanf("%d", &tempP);
		if (tempP <= A){
			P[0]++;
		}
		else if(tempP <= B){
			P[1]++;
		}
		else {
			P[2]++;
		}
	}
	
	min = MIN(P[0], P[1]);
	min = MIN(min, P[2]);
	
	printf("%d", min);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
 
using namespace std;
 
typedef long long ll;
 
const ll MAX = 100001;
const ll INF = (1LL<<50);
struct Spell{
  string name,tar;
  ll MP,Dam;
  Spell(){}
  Spell(string n, ll m, string t, ll d):name(n),MP(m),tar(t),Dam(d){}
};
 
ll dp[2][MAX];
vector<ll> Enemy;
vector<Spell> V[2];
ll N;
 
void init(){
  fill(dp[0],dp[0]+2*MAX,INF);
 
  //for(ll i = 0; i < 2; i++) for(ll j = 0; j < MAX; j++) dp[i][j] = INF;
  V[0].clear();
  V[1].clear();
  Enemy.clear();
}
 
void input(){
 
  while(N--){
    ll in;
    cin >> in;
    Enemy.push_back(in);
  }
 
  ll m;
  cin >> m;
  while(m--){
    Spell s;
    cin >> s.name >> s.MP >> s.tar >> s.Dam;
    if(s.tar == "All") V[0].push_back(s);
    else V[1].push_back(s);
  }
 
}
 
 
void make(){
 
  dp[0][0] = dp[1][0] = 0;
 
  for(ll x = 0; x < 2; x++){
    for(ll i = 0; i < MAX; i++){
      if(dp[x][i] == INF) continue;
      for(ll j = 0; j < V[x].size(); j++){
        ll nex = min(i+V[x][j].Dam,100000LL);
        ll cos = dp[x][i]+V[x][j].MP;
        dp[x][nex] = min(dp[x][nex],cos);
      }
    }
  }
   
  ll mincos[2];
  mincos[0] = dp[0][MAX-1];
  mincos[1] = dp[1][MAX-1];
   
  for(ll i = MAX-1; i >= 0; i--){
    mincos[0] = min(mincos[0],dp[0][i]);
    mincos[1] = min(mincos[1],dp[1][i]);
    dp[0][i] = min(dp[0][i],mincos[0]);
    dp[1][i] = min(dp[1][i],mincos[1]);
  }
}
 
void solve(){
 
  ll ans = INF;
 
  for(ll i = 0; i < MAX; i++){
 
    ll cos = dp[0][i];
    for(ll j = 0; j < Enemy.size(); j++){
      ll need = max(Enemy[j]-i,0LL);
      cos+=dp[1][need];
 
      //    cout << "cos " << dp[1][need] << endl;
    }
    ans = min(ans,cos);
  }
  cout << ans << endl;
}
 
 
int main(){
 
  while(cin >> N && N){
    init();
    input();
    make();
    solve();
  }
  return 0;
}

Measured memory_bytes: 2824
import re

N = int(input())

numList = []
def plusNum(num, N):
    if num > N:
        return
    numList.append(num)
    for i in [3, 5, 7]:
        plusNum(int(str(num) + str(i)), N)

for num in [3, 5, 7]:
    plusNum(num, N)

ans = 0
for num in numList:
    num_str = str(num)
    count_3 = 0
    count_5 = 0
    count_7 = 0
    for i in range(len(num_str)):
        if num_str[i] == "3":
            count_3 += 1
        elif num_str[i] == "5":
            count_5 += 1
        elif num_str[i] == "7":
            count_7 += 1
        if count_3 >= 1 and count_5 >= 1 and count_7 >= 1:
            ans += 1
            break

print(ans)

Measured memory_bytes: 4448
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int asc(const void *a,const void *b){
    return (*(char*)a-*(char*)b);
}
int main(void){
    int n,i;
    scanf("%d",&n);
    char s[n][11];
    /* 入力しa~z順の並び替え */
    for(i=0;i<n;i++){
        scanf("%s",&s[i]);
        qsort(s[i],10,sizeof(char),asc);
    }
    /* 全体の並び替え */
    qsort(s,n,11,strcmp);
    /* 組み合わせの数を求める */
    long long c=0,ans=0;    //32bitに収まらない可能性考慮
    for(i=1;i<n;i++){
        if(strcmp(s[i],s[i-1])==0){
            c++;
            ans+=c;
        }
        else c=0;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 2300
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
#define MOD 998244353
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

#define MAX 1000000000000

int main(void) {
	ll n, d; cin >> n >> d;
	int ans=0;
	rep(i, n) {
		ll x, y; cin >> x >> y;
		if (x*x + y * y <= d*d) {
			ans++;
		}
	}

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


Measured memory_bytes: 3632
#include <stdio.h>

int 
main(){
	
	int N;
	scanf("%d",&N);

	int i,cnt=0;
	
	//10000�`99999
	if(N==  100000){
		cnt += 99999 - 10000 +1;
	}
	else if(N<100000 && N>=10000)
	{
		cnt += N-10000 + 1;
	}
	//100�`999
	if(N>=1000){
		cnt += 999-100+1;
	}
	else if(N<1000&&N>=100)cnt += N-100+1;
	
	// 1~9
	if(N>=10){
		cnt += 9;
	}
	else if(N<10)cnt += N%10;
	
	

	printf("%d\n",cnt);
 return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
#include<type_traits>
#include<numeric>
#include<array>
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

const int mod = 1000000007;
const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
}

int main(){

    int N;cin >> N;

    vector<double> prob(N+1,0);
    REP(i,N) cin >> prob[i+1];
    
    auto dp = make_vec<double>(N+1,N+1);
    fill_v(dp,0.0);
    dp[0][0]=1;

    for(int i=1;i<=N;i++){
        for(int j=0;j<=i;j++){
            dp[i][j] = dp[i-1][j] * (1.0-prob[i]);
            if(j>0) dp[i][j] += dp[i-1][j-1] * prob[i];
        }
    }

    double ans=0.0;
    for(int i=N/2+1;i<=N;i++) ans += dp[N][i];

    printf("%.12f\n",ans);

    return 0;
}

Measured memory_bytes: 70656
#include<stdio.h>
int main(void){
int m,f,r;
int kekka;
while(1){
scanf("%d %d %d",&m,&f,&r);
kekka=m+f;
if(m==-1&&f==-1&&r==-1){break;}
else{
if((m==-1||f==-1)||(kekka<30)){
printf("F\n");
}else if(kekka<50){
if(r<50){printf("D\n");}
else{printf("C\n");}
}else if(kekka<65){
printf("C\n");
}else if(kekka<80){
printf("B\n");
}else{
printf("A\n");
}
}
}
return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000
using namespace std;
bool check(char x)
{
    if (x == 'a' || x == 'i' || x == 'u' || x == 'e' || x == 'o')
        return true;
    else
        return false;
}
int main()
{
    int n;
    while (cin >> n)
    {
        if (n == 0)
            break;
        vector<string> str;
        string s[100];
        char ch[100];
        rep(i, n)
        {
            cin >> s[i];
            int pos = 0;
            rep(j, s[i].size())
            {
                if (j == 0)
                {
                    ch[pos] = s[i][j];
                    pos++;
                }
                if (check(s[i][j]))
                {
                    ch[pos] = s[i][j + 1];
                    pos++;
                }
            }
            string tmp(ch, pos);
            str.push_back(tmp);
        }
        int k = 51;
        int ans = -1;
        while (k--)
        {
            vector<string> code;
            rep(i, str.size())
            {
                if (str[i].size() < k)
                    code.push_back(str[i]);
                else
                    code.push_back(str[i].substr(0, k));
            }
            bool flag = false;
            rep(i, code.size())
            {
                for (int j = i + 1; j < code.size(); j++)
                {
                    if (code[i] == code[j])
                        flag = true;
                }
            }
            if (flag == false)
                ans = k;
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
//define
typedef pair<int,int>pi;
#define int long long
#define elif else if
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define vint vector<int>
#define vvint vector<vector<int>>
#define vtr vector<string>
#define vvtr vector<vector<string>>
#define vhar vector<char>
#define vvhar vector<vector<char>>
#define mod 100000007
#define elif else if
#define str string
int digitsum(int a){
  int b=0;
  while(a){
    b+=a%10;
    a/=10;
  }
  return b;
}
signed main(){
  int N,M,O,P=0,c=0,co=0,cou=0,minN=mod;
  double D,Do;
  char C,Ca;
  str S,T;
  cin>>N;
  vint slime(N);rep(0,N)cin>>slime[i];
  rep(0,N-1){
    if(slime[i]==slime[i+1]){
      slime[i+2]!=slime[i]+2?slime[i+1]=slime[i]+2:slime[i+1]=slime[i]+3;
      c++;
    }
  }
  cout<<c<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t; cin >> s >> t;
    int ans = 0;
    REP(i,3) ans += (s[i]==t[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
cnt = [0]*3
for a in A:
    b = a%4
    if b==0:
        cnt[2] += 1
    elif b==2:
        cnt[1] += 1
    else:
        cnt[0] += 1
if (N-2*cnt[2]-1) <= max(0,cnt[1]-1):
    print("Yes")
else:
    print("No")

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

using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> dist(6);
  for(int i=0;i<n;i++){
    double data;
    cin>>data;
    for(int j=0;j<dist.size();j++){
      if((j?(160+5*j):0)<=data&&data<((j==dist.size()-1)?data+1:(165+5*j)))
        dist[j]++;
    }
  }

  for(int i=0;i<dist.size();i++){
    cout<<i+1<<":";
    for(int j=0;j<dist[i];j++) cout<<'*';
    cout<<endl;
  }
}

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

int main() {
  int K, S; cin >> K >> S;

  int ans{};
  for (int X{0}; X <= K; ++X) {
    for (int Y{0}; Y <= K; ++Y) {
      int Z = S - X - Y;
      if (0 <= Z && Z <= K) ++ans;
    }
  }

  cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int H, W, ttl=0, cnt=0, ans=0; cin >> H >> W;
  vector<vector<int>> Map(H, vector<int>(W));
  char c;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> c;
      if(c=='.') {Map[i][j]=-1; ttl++;}
      else Map[i][j]=-2;
    }
  }
  Map[0][0]=0;
  int dy[4] = {1, 0, -1, 0};
  int dx[4] = {0, 1, 0, -1};
  queue<int> qy; queue<int> qx;
  qy.push(0); qx.push(0);
  while(!qy.empty()) {
    int y = qy.front(), x= qx.front();
    qy.pop(); qx.pop();
    cnt = Map[y][x] + 1;
    for (int i=0; i<4; i++) {
      int ytmp=y+dy[i], xtmp=x+dx[i];
      if (ytmp<0||ytmp>=H||xtmp<0||xtmp>=W) continue;
      else if (Map[ytmp][xtmp]==-1) {
        Map[ytmp][xtmp]=cnt;
        qy.push(ytmp); qx.push(xtmp);
        if (ytmp==H-1 && xtmp==W-1) {
          ans+=cnt;
          while(!qy.empty()) qy.pop();
          break;
        }
      }
    }
  }
  if (ans==0) cout << -1 << "\n";
  else cout << ttl-ans-1 << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a[4];
    int b;
    int s;
    int t;
    int i;
    scanf("%d",&b);

    a[0]=b/1000;
    a[1]=b/100-a[0]*10;
    a[2]=b/10-a[0]*100-a[1]*10;
    a[3]=b-(a[0]*1000+a[1]*100+a[2]*10);

    s=a[0]*10+a[1];
    t=a[2]*10+a[3];

    if(s>12&&t>12){
        printf("NA");
    }
    if(s==00&t==00){
        printf("NA");
    }
    if(s<13&&t<13&&s!=0&&t!=0){
        printf("AMBIGUOUS");
    }
    if(s<13&&t>12){
        if(s==0){
            printf("NA");
        }else{
        printf("MMYY");
        }
    }
    if(s>12&&t<13){
        if(t==00){
            printf("NA");
        }else {
        printf("YYMM");
        }
    }
    if(t==00&&s<13&&s>00){
        printf("MMYY");
    }
    if(s==00&&t<13&&t>00){
        printf("YYMM");
    }
}
    

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

int a, b, c;

int main(){

    cin>>a>>b>>c;
    if(a==b&&b==c) cout<<1<<endl;
    else if(a!=b&&a!=c&&b!=c) cout<<3<<endl;
    else cout<<2<<endl;
    return 0;

}


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

int main() {
    int n, r;
    scanf("%d%d", &n, &r);
    if (n<10)
        printf("%d\n", r + (100*(10-n)));
    else
        printf("%d\n", r);
    return 0;
}


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

int main() {
  int N, a, b, c, d;
  cin >> N;
  
  a = N / 1000;
  b = (N % 1000) / 100;
  c = ((N % 1000) % 100) / 10;
  d = ((N % 1000) % 100) % 10;
  
  if((a == b && b == c) || (b == c && c == d)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>

using namespace std;
int main(){
  string s;
  cin >> s;

  int i = 0;
  int j = 8;
  string hoge;
  int ans = 0;
  while(s[i]!='\0'){
    if(s[i]!='/'){
      //cout << s[i] << endl;
      ans += (s[i]-'0')*pow(10, j-1);
      j--;
    }
    i++;
  }

  if(ans>20190430){
    cout << "TBD" << endl;
  } else {
    cout << "Heisei" << endl;
  }

  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

static uint64_t
gcd (
  uint64_t a,
  uint64_t b
  )
{
  if ( b == 0 )
    return ( a );

  return gcd ( b, a % b );
}

int
main (
  int   argc,
  char *argv[ ]
  )
{
  uint64_t res;
  int n;
  int i;

  scanf ( "%d%llu", &n, &res );
  for ( i = 1; i < n; ++i )
  {
    uint64_t d;

    scanf ( "%llu", &d );
    res = gcd ( res, d );
  }
  for ( i = 1; i <= res; ++i )
  {
    if ( res % i == 0 )
      printf ( "%d\n", i );
  }

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL ans;
const int maxn=2e5+10;
int a[maxn],hs[maxn];
int st[maxn],l[maxn],r[maxn];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]),hs[a[i]]=i;
	int top=0;
	for(int i=1;i<=n;++i){
		while(top&&st[top]>a[i])--top;
		st[++top]=a[i];
		if(top==1)l[i]=0;
		else l[i]=hs[st[top-1]];
	}
	top=0;
	for(int i=n;i>=1;--i){
		while(top&&st[top]>a[i])--top;
		st[++top]=a[i];
		if(top==1)r[i]=n+1;
		else r[i]=hs[st[top-1]];
	}
	for(int i=1;i<=n;++i){
		ans+=1LL*((LL)(i-l[i]))*((LL)(r[i]-i))*((LL)a[i]);
	}
	cout<<ans<<endl;
	return 0;
}

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

#define MOD 1000000007
#define ll long long int




int main(){
    ll i,j,k,m,n,flag=0,t,x,b,c,d,u,v,sum=0,y,fsum,ssum,ans=0,cnt,l=0;
    cin>>n>>m;
    while(m--){
        cin>>k;
        sum+=k;
    }
    if(n-sum>=0){
        cout<<n-sum<<endl;
    }
    else{
        cout<<-1<<endl;
    }
    
    
  //  cout<<"Yes"<<endl;
  //  cout<<"No"<<endl;
       
     
       
    
    
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;
typedef pair<int,int> pie;
const int nax = 2e5+5;
vector<int> vertices[nax];
bool visited[nax];
void dfs(int u) {
	if(visited[u]) return;
	visited[u] =1;
	for(auto it:vertices[u]) {
		if(!visited[it]) {
			dfs(it);
		}
	}
}
int main() {
	int n,m;
	cin >> n >> m;
	for(int i=1;i<=m;i++) {
		int u,v;
		cin >> u >> v;
		vertices[u].push_back(v);
		vertices[v].push_back(u);
	}
	//visited[1] = 1;
	dfs(1);
	bool ok = 1;
	for(int i=1;i<=n;i++) {
		if(!visited[i]) {
			ok = 0;
			break;
		}
	}
	if(!ok) {
		cout<<"No\n";
		return 0;
	}
	vector<int> ans(n+10,-1);
	ans[1] = 1;
	queue<int> q;
	q.push(1);
	while(!q.empty()) {
		int u = q.front();
		q.pop();
		for(auto it:vertices[u]) {
			if(ans[it] == -1) {
				ans[it] = u;
				q.push(it);
			}	
		}
	}
	cout<<"Yes\n";
	for(int i=2;i<=n;i++) {
		cout<<ans[i]<<"\n";
	}
}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

const int N = 4e2 + 5;

const int inf = 1e15;

int n, a[N], dp[N][N], sum[N];

int solve(int l, int r) {
    if(l == r)
        return 0;
    if(dp[l][r] != inf) return dp[l][r];
    for(int i = l + 1; i <= r; i++)
        dp[l][r] = min(solve(l, i - 1) + solve(i, r) + sum[r] - sum[l - 1], dp[l][r]);
   // cout << dp[l][r] << " " << l << " " << r << "\n";
    return dp[l][r];
}

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++)
            dp[i][j] = inf;
    }
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        sum[i] = a[i];
        sum[i] += sum[i - 1];
    }
    cout << solve(1, n);
}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;


int main(){

  ll a,b,c;cin>>a>>b>>c;
  string k;cin>>k;
  int num=k[k.size()-1]-'0';

  if(num%2==0)out(a-b)
  else out(b-a)

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
//cin,coutより遅いので注意
template <class T = int>
void in() //in<string>();とか書く intのときはそのままin();
{
    T x;
    cin >> x;
    return (x);
}
template <class T>
void print(T &x) { cout << x << "\n"; }

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a + b + c) - max({a, b, c}) << "\n";
}

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

using namespace std;

int main()
{
    int n,c;
    cin >> n >> c;
    int tmp=0;
    int h=n+1;
    for(int i=0;i<c;i++){
        int a;
        cin >>a;
        tmp+=a;
    }
    int ans=tmp%h?(tmp/h)+1:(tmp/h);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3120
import java.util.Scanner;
import java.util.Arrays;

public class Main { //HDL-style Disjoint Set
	static int N; // int_maxsize > 10000 (constrain)
	static int Q; // int_maxsize > 110000 (worstcase = 10000initial set  + 100000 new set)
	static boolean Com; //com only have two kind;
	static int V1;
	static int V2;
	static int[] S;
	static Scanner scanner;
	public static void main(String[] args){
		scanner = new Scanner(System.in);
		N = scanner.nextInt();
		N = 100000;
		S = new int[N];
		reset();
		Q = scanner.nextInt();
		FSM();
	}
	//end of main
	private static void reset(){
		Com = false;
		V1 = 0;
		V2 = 0;
		for(int i = 0; i<N; i++){
			S[i]=i;
		}
	}
	//end of reset
	private static void FSM(){
		while(Q>0){
			fetch();
			dispatch();
			Q--;
		}
	}
	//end of FSM
	private static void fetch(){
		Com = (scanner.nextInt() > 0)?true:false;
		V1 = scanner.nextInt();
		V2 = scanner.nextInt();
	}
	//end of feteh
	private static void dispatch(){
		if(Com){
			same();
		}else {
			unite();
		}
	}
	//end of dispatch
	private static void unite(){
		if(S[V1] == S[V2]){
			return;
		}else{
			merge();
		}
	}
	//end of unite
	private static void same(){
		if(S[V1] == S[V2]){
			System.out.println(1);
		}else{
			System.out.println(0);
		}
	}
	//end of same
	private static void merge(){
		V1 = S[V1];// use variable 1 to store the set code of V1
		V2 = S[V2];// use variable 2 to store the set code of V2
		for(int i = 0; i< N;i++)
		{
			if(S[i] == V1){
				S[i] = V2;
			}else{
				continue;
			}
		}
	}
}	



Measured memory_bytes: 99164