akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
using namespace std;

int N;

string binary_number(int a) // int型の10進数をstring型の2進数に変換
{
    string b = "";
    for (int i = 1; i <= N; i++)
    {
        b = to_string(a % 2) + b;
        a /= 2;
    }
    return b;
}

int main()
{
    cin >> N;
    int A[20], x[20][20];
    char y[20][20];
    for (int i = 1; i <= N; i++)
    {
        cin >> A[i];
        for (int j = 1; j <= A[i]; j++)
        {
            cin >> x[i][j] >> y[i][j];
        }
    }

    int ans = 0;
    for (int hu = 0; hu < pow(2, N); hu++) // honest or unkind
    {
        string hu2 = binary_number(hu);
        // ex. N == 15のとき、hu2 == "010001000111101"（15桁）

        bool success = true;
        for (int i = 1; i <= N; i++)
        {
            if (hu2[i - 1] == '1') // 今回、人iは正直者だが・・・
            {
                for (int j = 1; j <= A[i]; j++)
                {
                    if (hu2[x[i][j] - 1] != y[i][j]) // もし人iの証言が違ったら・・・
                    {
                        success = false; // ダメです
                    }
                }
            }
        }

        if (success == true)
        {
            int honest = 0;
            for (int i = 1; i <= N; i++)
            {
                if (hu2[i - 1] == '1') honest++;
            }
            ans = max(ans, honest);
        }
    }

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

Measured memory_bytes: 256
N = int(input())

A = list()
B = list()
for _ in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)

A = sorted(A)
B = sorted(B)

m = int((N + 1) / 2 if N % 2 == 1 else N / 2)

if N % 2 == 1:
    M = (B[m - 1] - A[m - 1]) + 1
else:
    M = ((B[m] + B[m - 1]) / 2) - ((A[m] + A[m - 1]) / 2)
    M = (2 * M) + 1
print(int(M))


Measured memory_bytes: 27144
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define MOD 1000000007
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }
ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __int128
ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}
ll inv(ll x){return power(x,MOD-2);}


void __sol(){
    
    int k,a,b; cin >> k >> a >> b;
    if( b/k > (a-1)/k ) cout << "OK";
    else cout << "NG";
    
    return;
}


int main(){
    fastio
    ll tc=1; //cin >> tc;
    while(tc--) __sol();
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
}

Measured memory_bytes: 764
import math
l = list(map(int,input().split()))

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

l[0] -= 1
la = l[0] - l[0] // l[2] - l[0] // l[3] + l[0] // lcm(l[2], l[3])
lb = l[1] - l[1] // l[2] - l[1] // l[3] + l[1] // lcm(l[2], l[3])
print(lb - la)

Measured memory_bytes: 9148
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n; string s;
  cin >> s;
  n = s.size();
  ll ans = 0;
  ll b = 0;
  for(int i = 0 ; i <n; i++) {
    if(s[i] == 'W') ans += b;
    else b++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define inf 2123333333

struct noe { int mx,mn; }t[400010];

int fa[100010][20],num[100010],h[100010],minn[100010],maxn[100010],n,m,q;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline void build(int o,int l,int r)
{
	if (l==r) { t[o].mx=t[o].mn=h[l];return; }
	int mid=(l+r)>>1;
	build(o<<1,l,mid);
	build(o<<1|1,mid+1,r);
	t[o].mx=max(t[o<<1].mx,t[o<<1|1].mx);
	t[o].mn=min(t[o<<1].mn,t[o<<1|1].mn);
}

inline int querymax(int o,int l,int r,int x,int y)
{
	if (l>=x&&r<=y) return t[o].mx;
	int mid=(l+r)>>1,res=-inf;
	if (x<=mid) res=max(res,querymax(o<<1,l,mid,x,y));
	if (y>mid) res=max(res,querymax(o<<1|1,mid+1,r,x,y));
	return res;
}

inline int querymin(int o,int l,int r,int x,int y)
{
	if (l>=x&&r<=y) return t[o].mn;
	int mid=(l+r)>>1,res=inf;
	if (x<=mid) res=min(res,querymin(o<<1,l,mid,x,y));
	if (y>mid) res=min(res,querymin(o<<1|1,mid+1,r,x,y));
	return res;
}

int main()
{
	m=rd();n=rd();
	for (int i=1;i<=n;i++) num[i]=rd();
	h[0]=0;
	for (int i=1;i<=n;i++)
	{
		if (i&1) h[i]=h[i-1]-(num[i]-num[i-1]);
		else h[i]=h[i-1]+(num[i]-num[i-1]);
	}
	minn[0]=maxn[0]=0;
	for (int i=1;i<=n;i++) minn[i]=min(minn[i-1],h[i]),maxn[i]=max(maxn[i-1],h[i]);
	build(1,0,n);
	memset(fa,-1,sizeof(fa));
	for (int i=0;i<n;i++)
	{
		int l=i+1,r=n,now=(i&1)?0:m;
		while (l<r)
		{
			int mid=(l+r)>>1;
			if (now==0)
			{
				if (querymin(1,0,n,i+1,mid)<=h[i]||querymax(1,0,n,i+1,mid)-h[i]>=m) r=mid;
				else l=mid+1;
			}
			else
			{
				if (querymax(1,0,n,i+1,mid)>=h[i]||h[i]-querymin(1,0,n,i+1,mid)>=m) r=mid;
				else l=mid+1;
			}
		}
		if (now==0)
		{
			if (querymin(1,0,n,i+1,l)>h[i]&&querymax(1,0,n,i+1,l)-h[i]<m) fa[i][0]=-1;
			else fa[i][0]=l;
		}
		else
		{
			if (querymax(1,0,n,i+1,l)<h[i]&&h[i]-querymin(1,0,n,i+1,l)<m) fa[i][0]=-1;
			else fa[i][0]=l;
		}
	}
	for (int i=n;~i;i--) for (int j=1;j<20;j++) if (fa[i][j-1]!=-1) fa[i][j]=fa[fa[i][j-1]][j-1];
	q=rd();
	while (q--)
	{
		int t=rd(),x=rd();
		if (t<=num[1]) { printf("%d\n",max(x-t,0));continue; }
		int l=0,r=n;
		while (l<r) { int mid=((l+r)>>1)+1;if (num[mid]<=t) l=mid;else r=mid-1; }
		int tot=l;
		l=0;r=tot;
		while (l<r) { int mid=(l+r)>>1;if (x+maxn[mid]>=m||x+minn[mid]<=0) r=mid;else l=mid+1; }
		if (l==0&&!x) l++;
		if (x==m) l=0;
		if (x+maxn[l]<m&&x+minn[l]>0)
		{
			int now=x+h[tot];
			if (tot&1) now=min(now+(t-num[tot]),m);
			else now=max(now-(t-num[tot]),0);
			printf("%d\n",now);
			continue;
		}
		int hh=l;
		for (int i=17;~i;i--) if (~fa[hh][i]&&fa[hh][i]<=tot) hh=fa[hh][i];
		int now=(hh&1)?0:m;
		now+=h[tot]-h[hh];
		if (tot&1) now=min(now+(t-num[tot]),m);
		else now=max(now-(t-num[tot]),0);
		printf("%d\n",now);
	}
	return 0;
}

Measured memory_bytes: 13440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false) , cin.tie(0) ;
#define w(x) cout << (#x) << " is " << x << "\n" ;

int main()
{
    fast;
    int n,i;
    for(i = 1 ; i < 6 ; i++)
    {
        cin >> n ;
        if(n == 0)
            cout << i << "\n" ;
    }

    return 0;
}


Measured memory_bytes: 3524
// In the Name of God

#include <bits/stdc++.h>

using namespace std;

#define	ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(a) int(a.size())
#define all(v) v.begin(), v.end()
#define bpc(v) __builtin_popcountll(v)
#define itr iterator
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; --i)
#define ub upper_bound
#define lb lower_bound

const int N = 2e5 + 5;
const ll mod = 8;
const ll inf = 1e18 + 1;
const double eps = 1e-15;
const int pw = 257;

int n;
pair<int, int> p[N];
ll ans = inf, X, Y, res;
set<int> s;

int main() {
	#ifdef Madi
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
	#endif

	cin >> n;
	rep(i, 1, n) {
		cin >> p[i].fi >> p[n + i].fi;
		X += p[i].fi;
		Y += p[n + i].fi;
		p[i].se = p[i + n].se = i;
	}

	sort(p + 1, p + 1 + n + n); 
	rep(i, 1, n) 
		s.insert(p[i].se);
	rep(i, 1, n)
		res += p[i].fi;

	if (sz(s) == n) {
		rep(i, n + 1, n + n) {
			if (p[n].se == p[i].se)
				ans = min(ans, res - p[n - 1].fi + p[i].fi);
			else
				ans = min(ans, res - p[n].fi + p[i].fi);
		}
	}
	else
		ans = res;

	cout << min(ans, min(X, Y));
	             
	#ifdef Madi
    cerr << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
	return 0;
}

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

typedef long long ll;

/* メモリ食い過ぎ注意 */
#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    string s[10000];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> s[i];

    int cntab = 0;
    int cnta = 0;
    int cntb = 0;
    bool f = true;
    for (int i = 0; i < n; i++)
    {
        if ((s[i])[0] == 'B')
            cntb++;
        if ((s[i])[s[i].length() - 1] == 'A')
            cnta++;
        if (((s[i])[0] == 'B' && (s[i])[s[i].length() - 1] != 'A') || ((s[i])[0] != 'B' && (s[i])[s[i].length() - 1] == 'A'))
            f = false;
        for (int j = 0; j < s[i].length() - 1; j++)
        {
            if ((s[i])[j] == 'A' && (s[i])[j + 1] == 'B')
            {
                cntab++;
                j += 1;
            }
        }
    }

    if (f)
    {
        // cout << "aaa" << endl;
        cnta--;
    }
    // cout << cnta << " " << n - 1 << " " << cntb << endl;
    int mn = max(0LL, min(cnta, min(n - 1, cntb)));
    cout << cntab + mn << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll n,k;cin>>n>>k;
    ll ans=LINF;
    ans=min(n,ans);
    ll cnt=n/k;
    ans=min(ans,n-cnt*k);
    ans=min(ans,abs(n-cnt*k-k));
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<string> bl(n);
	for (int i = 0; i < n; i++) {
		cin >> bl.at(i);
	}
	int m;
	cin >> m;
	vector<string> rd(m);
	for (int i = 0; i < m; i++) {
		cin >> rd.at(i);
	}
	int l;
	l = 0;//最大値
	for (int i = 0; i < n; i++) {//全ての青の単語に関して
		int k = 0;//挑戦者の結果
		for (int j = 0; j < n;j++) {//他の青単語と一致か確認
			if (bl.at(i) == bl.at(j)) {//青と一致してたら加算
				k++;
			}
		}
		for (int j = 0; j < m; j++) {//赤単語と一致か確認
			if (bl.at(i) == rd.at(j)) {
				k--;
			}
		}
		if (k > l) {
			l = k;
		}
	}
	cout << l << endl;
	return 0;
}

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

namespace abc71
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            int x = int.Parse(str[0]);
            int a = int.Parse(str[1]);
            int b = int.Parse(str[2]);
            if (Math.Abs(x - a) < Math.Abs(x - b))
            {
                Console.WriteLine("A");
            }else
            {
                Console.WriteLine("B");
            }
        }
    }
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, K;
string S;
vector<pii> seq;
int sums[100010];
int costs[100010];

int main(){
    
    cin >> N >> K;
    cin >> S;
    int cnt = 1;
    for(int i = 1; i < N; i++){
        if(S[i] == S[i-1]) cnt++;
        else{
            seq.push_back(pii(S[i-1]-'0', cnt));
            cnt = 1;
        }
    }
    seq.push_back(pii(S[N-1]-'0', cnt));
    for(int j = 0; j < (int)seq.size(); j++){
        sums[j+1] = sums[j] + seq[j].second;
    }
    for(int j = 0; j < (int)seq.size(); j++){
        costs[j+1] = costs[j] + ((seq[j].first == 0) ? 1 : 0);
    }

    int ans = -1;
    for(int i = 0; i < (int)seq.size(); i++){
        int ub = (int)seq.size();
        int lb = i;
        while(ub - lb > 1){
            int mid = (ub + lb) / 2;
            int cost = costs[mid + 1] - costs[i];
            if(cost <= K){
                lb = mid;
            }
            else{
                ub = mid;
            }
        }
        int cstd = sums[lb + 1] - sums[i];
        ans = max(ans, cstd);
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2164
N = int(input())
a = []
for i in range(N):
  a.append(list(map(int,input().split())))
a.sort(key=lambda x: x[1])
cnt = 0
ans = 1
for i in range(N):
  if(cnt + a[i][0] > a[i][1]):
    ans = 0
    break
  cnt += a[i][0]
  
if(ans == 1):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 53720
using System;
using System.Linq;

namespace ABC149
{
    class C
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());

            bool isOK = false;

            while (!isOK)
            {
                if (IsPrimeNumber(X)) { Console.WriteLine(X); return; }
                X++;
            }
        }

        static bool IsPrimeNumber(int number)
        {
            double i = number;
            // 平方根を求める
            double x = Math.Sqrt(i);
            // 平方根以下の値で割り切れるのか確認する
            // 最小値は2
            for (double j = 2; j <= x; j++)
            {
                if ((number % j) == 0) { return false; }
            }
            if (number == 1) { return false; }
            return true;
        }
    }
}


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

int main() {
  int N, A, B;
  cin >> N >> A;

  B = N / 500;
  
  if (B <= 0) {
    if (A >= N)
      cout << "Yes" << endl;
    else
      cout << "No" << endl; }
  else {
    if (A >= (N-500*B))
      cout << "Yes" << endl;
    else 
      cout << "No" << endl; }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.length()%2 == 1){
			System.out.println("No");
			return;
		}
		String remain = s;
		while(remain.length()>1){
			String tmp = remain.substring(0,2);
			if(!tmp.equals("hi")){
				System.out.println("No");
				return;
			}else{
				remain = remain.substring(2);
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 22740
var gets = (function(){
  function f(s){return new g(s);}
  function g(s){this._s=s.trim().split("\n");this._y=0;}
  g.prototype.a = function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y]=s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  }
  g.prototype.l = function(f){
    var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);
  }
  g.prototype.m = function(n,f){
    var r=this._s.slice(this._y,this._y+n).map(a=>a.split(" "));
    this._y += n;
    return f?r:r.map(a=>+a);
  }
  g.prototype.r = function(n,f){
    var r = this._s.slice(this._y,this._y+n);
    this._y += n;
    return f?r:r.map(a=>+a);
  }
  return f;
})();
var o=gets(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var h = o.a();
  var w = o.a();
  var n = o.a();
  var a = o.l();
  var x = 0, y = 0, z = 1;
  var ans = Array(h).fill(0).map(a=>[]);
  for(var i = 1; i <= n; i++){
    for(var j = 0; j < a[i-1]; j++){
      ans[y][x] = i;
      if(z === 1 && y === h-1){
        x++;
        z = -1;
      }else if(z === -1 && y === 0){
        x++;
        z = 1;
      }else{
        y += z;
      }
    }
  }
  return ans.map(a=>a.join(" ")).join("\n");
}

Measured memory_bytes: 8096
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a ,ll b){
    return a / gcd(a,b) * b;
}

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

int main(){
	int n;
	cin >> n;
	vector<long long> T(n);
	for(int i = 0;i < n;i++){
	    cin >> T[i];
	}
	
	ll res = 1;
	for(int i = 0; i < n;i++){
	    res = lcm(res,T[i]);
	}
	
	cout <<  res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>


using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int N,M,K,A[200300]={},B,c[200],res=0,Match[20]={0,2,5,5,4,5,6,3,7,6};

vector<long long int>pl,mi;
int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>K;
    cout<<max(0LL,N-K)<<endl;

}    


Measured memory_bytes: 256
using System;
using System.Linq;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            int count = 0;
            for(string input, word = Console.ReadLine(); (input = Console.ReadLine()) != "END_OF_TEXT" ; count += input.Split().Count(p => p.Equals(word, System.StringComparison. OrdinalIgnoreCase)));
            Console.WriteLine(count);
        }
    }
}

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

int main(){
  int n;
  cin >> n;
  int a, maxv =1, minv = 1000000000;
  for( int i = 0; i < n; i++ ) {
    cin >> a;
    maxv = max(a, maxv);
    minv = min(a, minv);
  }   
  int ans = maxv - minv;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c;
string s, t;

int main()
{
	cin >> a;
	
	cout << 3*a*a<< endl;
}


Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid u1(5, 10); u1(rnd);

int main() {
    fast;
    ll a,k; cin>>a>>k;
    vec<pair<int, pii>> m(a);
    for(int q=0; q<a; q++){
        int a1,a2,x; cin>>a1>>a2>>x;
        m[q] = {x, {a1-x,a2-x-1}};
    }
    sort(m.begin(), m.end(), [](pair<int, pii> p1, pair<int, pii> p2){return p1.F<p2.F;});
    vec<int> ans(k);
    set<pii> s;
    for(int q=0; q<k; q++){
        int n; cin>>n;
        s.insert({n,q});
    }
    for(int q=0; q<a; q++){
        int l = m[q].S.F, r = m[q].S.S, x = m[q].F;
        for(; s.size()>0;){
            auto it = s.lower_bound({l,-1});
            if(it == s.end()) break;
            pii p = *it;
            if(p.F>r) break;
            ans[p.S] = x;
            s.erase(p);
        }
    }
    for(pii p : s) ans[p.S] = -1;
    for(int i : ans) cout<<i<<endl;
    /*ll a,k, o=0; cin>>a>>k;
    vec<ll> m(a);
    for(int q=0; q<a; q++) cin>>m[q];

    cout<<o<<endl;*/
}

Measured memory_bytes: 14464
N = int(input())
h = [int(i) for i in input().split()]

res = 0
Flag = False
while True:
    if sum(h) == 0:
        break
    for i in range(N):
        if h[i]:
            Flag = True
            h[i] -= 1
            if i == N-1:
                res += 1
        else:
            if i-1 >= 0 and Flag:
                res += 1
            Flag = False
    Flag = False

print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
const ll INF = LLONG_MAX;

int main() {
	ll a, b, q;
	cin >> a >> b >> q;
	vector<ll> s(a), t(b);
	for (ll i = 0; i < a; i++) cin >> s[i];
	for (ll i = 0; i < b; i++) cin >> t[i];
	while (q--) {
		ll x;
		cin >> x;
		ll ans = INF;
		auto itr1 = lower_bound(ALL(s), x);
		auto itr2 = lower_bound(ALL(t), x);
		if (itr1 != s.end() && itr2 != t.end()) {
			ans = min(ans, max(*itr1, *itr2) - x);
		}
		auto itr3 = upper_bound(ALL(s), x);
		auto itr4 = upper_bound(ALL(t), x);
		if (itr3 != s.begin() && itr4 != t.begin()) {
			ans = min(ans, x - min(*(itr3 - 1), *(itr4 - 1)));
		}
		if (itr1 != s.end() && itr4 != t.begin()) {
			ans = min(
				ans,
				(*itr1 - *(itr4 - 1)) * 2 - max(*itr1 - x, x - *(itr4 - 1))
			);
		}
		if (itr2 != t.end() && itr3 != s.begin()) {
			ans = min(
				ans,
				(*itr2 - *(itr3 - 1)) * 2 - max(*itr2 - x, x - *(itr3 - 1))
			);
		}
		cout << ans << '\n';
	}
}

Measured memory_bytes: 4764
from sys import stdin,stdout
Pi = lambda x: stdout.write(str(x) + '\n')
S = lambda x: x*(x+1) // 2
I = lambda x: 1+(2*x)
R = lambda:stdin.readline()
Ri = lambda x:map(int,x.split())
Rs = lambda x:map(str,x.split())
Rf = lambda x:map(float,x.split())
 
def main():	
	# t = int(R())
	for x in stdin:
		s = x.strip('\n')
		if s[2]==s[3] and s[4] == s[5]:
			Pi('Yes')
		else:
			Pi('No')


if __name__=='__main__':
	main()

Measured memory_bytes: 38256
import sys
sys.setrecursionlimit(10**7)

def root(x):
    if rank[x] < 0: return x
    rank[x] = root(rank[x])
    return rank[x]
def unite(x, y):
    x, y = root(x), root(y)
    if x == y: return False
    if rank[x] > rank[y]: x, y = y, x
    rank[x] += rank[y]
    rank[y] = x
    return True
def is_same(x, y): return root(x) == root(y)
def size(x): return -rank[root(x)]

n, m = map(int, input().split())
rank = [-1 for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    unite(a-1, b-1)

cnt = 0
for r in rank:
    if r < 0:
        cnt += 1
print(cnt-1)

Measured memory_bytes: 10768
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int bm = 200001;
ll BIT[bm];
void add(int A, ll B) {
	while (A <= bm) {
		BIT[A] = max(BIT[A], B);
		A += A & -A;
	}
}
ll query(int A) {
	ll kotae = 0;
	while (A > 0) {
		kotae = max(BIT[A], kotae);
		A -= A & -A;
	}
	return kotae;
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int h[200000];
	rep(i, N) h[i] = getint();

	rep(i, N) add(h[i], query(h[i]) + getint());

	printf("%lld", query(N));

	Would you please return 0;
}

Measured memory_bytes: 2688
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 9 * 1e18;
const ll MOD = 1e9 + 7;

ll count(ll N, ll X, vl &xCount, vl &pCount) {
  if (X == 0) {
    return 0;
  }

  if (X == xCount[N]) {
    return pCount[N];
  }

  ll middle = (xCount[N] + 1) / 2;
  if (middle > X) {
    return count(N - 1, X - 1, xCount, pCount);
  } else {
    return 1 + count(N - 1, middle - 2, xCount, pCount) +
           count(N - 1, X - middle, xCount, pCount);
  }
}

void solve(long long N, long long X) {
  vl xCount(N + 1);
  vl pCount(N + 1);

  xCount[0] = 1;
  pCount[0] = 1;
  rep(n, 1, N + 1) {
    xCount[n] = 3 + 2 * xCount[n - 1];
    pCount[n] = 1 + 2 * pCount[n - 1];
  }

  print(count(N, X, xCount, pCount));
}

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


Measured memory_bytes: 256
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim()
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
            (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($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(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let _ = scan!(i64);
    let mut ts = scan!(i64;;);
    let vs = scan!(i64;;);
    for i in 0..ts.len() {
        if i + 1 < ts.len() {
            ts[i + 1] += ts[i]
        }
        ts[i] *= 2
    }

    let total: i64 = *ts.last().unwrap() + 1;
    let mut results: Vec<Vec<f64>> = Vec::new();
    results.push((0..).map(|t| 0.5 * t as f64).take(total as usize).collect());
    results.push(
        (0..total)
            .map(|t| 0.5 * total as f64 - 0.5 * t as f64 - 0.5)
            .collect(),
    );
    for (i, &end) in ts.iter().enumerate() {
        let mut start = 0;
        if i > 0 {
            start = ts[i - 1]
        }

        results.push(
            (0..)
                .map(|t| {
                    if t < start {
                        1e5
                    } else if t <= end {
                        vs[i] as f64
                    } else {
                        vs[i] as f64 + ((t as i64 - end) as f64) / 2.0
                    }
                })
                .take(total as usize)
                .collect(),
        );
        let mut v = (0..total)
            .rev()
            .map(|t| {
                if end < t {
                    1e5
                } else if start <= t {
                    vs[i] as f64
                } else {
                    vs[i] as f64 + ((start - t) as f64) / 2.0
                }
            })
            .collect::<Vec<_>>();
        v.reverse();
        results.push(v);
    }

    let mut vecs: Vec<f64> = (0..total).map(|_| 1e5f64).collect();
    for r in results.iter() {
        for (i, &v) in r.iter().enumerate() {
            vecs[i] = vecs[i].min(v)
        }
    }

    let mut ans = 0f64;
    for (v1, v0) in vecs[1..].iter().zip(vecs.iter()) {
        ans += (v1 + v0) / 4f64
    }
    println!("{}", ans)
}


Measured memory_bytes: 104408
#include <bits/stdc++.h>
#define INF 5000000
using namespace std;
typedef pair<int, int> P;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
int sum[50][10] = {}, team[50][10] = {};
bool solve[50][10];
int main()
{
    int M, T, P, R;
    while (cin >> M >> T >> P >> R)
    {
        if (M == 0)
            return 0;

        vector<int> m(R), t(R), p(R), j(R);
        for (int i = 0; i < 50; i++)
        {
            for (int k = 0; k < 10; k++)
            {
                sum[i][k] = 0, team[i][k] = 0;
                solve[i][k] = false;
            }
        }
        for (int i = 0; i < R; i++)
        {
            cin >> m[i] >> t[i] >> p[i] >> j[i];
            t[i]--, p[i]--;
        }
        for (int i = 0; i < R; i++)
        {
            if (j[i] == 0)
            {
                team[t[i]][p[i]] = m[i];
                solve[t[i]][p[i]] = true;
            }
            else
            {
                if (!solve[t[i]][p[i]])
                    sum[t[i]][p[i]] += 20;
            }
        }
        vector<int> team_time(T, 0), team_sum(T, 0);
        for (int i = 0; i < T; i++)
        {
            for (int k = 0; k < P; k++)
            {
                if (solve[i][k])
                {
                    team_sum[i]++;
                    team_time[i] += (team[i][k] + sum[i][k]);
                }
            }
        }
        vector<tuple<int, int, int>> v;
        for (int i = 0; i < T; i++)
        {
            v.emplace_back(team_sum[i], -team_time[i], i + 1);
        }
        sort(rbegin(v), rend(v));
        vector<char> st;
        for (int i = 0; i < T - 1; i++)
        {
            if (get<0>(v[i]) == get<0>(v[i + 1]) && get<1>(v[i]) == get<1>(v[i + 1]))
            {
                st.push_back('=');
            }
            else
            {
                st.push_back(',');
            }
        }
        for (int i = 0; i < T; i++)
        {
            if (i < T - 1)
                cout << get<2>(v[i]) << st[i];
            else
                cout << get<2>(v[i]) << endl;
        }
    }
}



Measured memory_bytes: 3128
// 解答不能.
// https://atcoder.jp/contests/abc159/submissions/11096062
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const LL MOD = 998244353;

LL dp[3030][3030][3];
int a[3030];

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    rep(i, n) scanf("%d", &a[i]);
    dp[0][0][0] = 1;
    rep(i, n){
        rep(j, k + 1){
            (dp[i + 1][j][0] += dp[i][j][0]) %= MOD;
            (dp[i + 1][j][1] += dp[i][j][0] + dp[i][j][1]) %= MOD;
            (dp[i + 1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]) %= MOD;
            if(j + a[i] <= k){
                (dp[i + 1][j + a[i]][1] += dp[i][j][0] + dp[i][j][1]) %= MOD;
                (dp[i + 1][j + a[i]][2] += dp[i][j][0] + dp[i][j][1]) %= MOD;
            }
        }
    }
    printf("%d\n", dp[n][k][2]);
    return 0;
}

Measured memory_bytes: 215168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int A,B,C;
  cin >>A>>B>>C;
  if(B/A>=C)cout<<C<<endl;
  else cout<<B/A<<endl;
  return 0;
    
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M ((ll)(1e9)+7)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
typedef long long ll;
ll power(ll x,ll y)
{
    if(y==0)
    return 1;
    ll res=power(x,y/2);
    res=(res*res)%M;
    if(y&1)
    res=(res*x)%M;
    return res;
}
void solve()
{
    ll h,w,a,b,va;
    cin>>h>>w>>a>>b;
    a=h-a+1;
    ll ta=a-1,tb=b+1;
    ll fact[200001];fact[0]=1;
    for(ll i=1;i<200001;i++)
    fact[i]=(fact[i-1]*i)%M;
    vector<ll> v,v1;
    for(ll i=tb;i<=w;i++)
    {
        va=fact[i+ta-2];
        va=(va*power(fact[i-1],M-2))%M;
        va=(va*power(fact[ta-1],M-2))%M;
        v.pb(va);
    }
    for(ll i=tb;i<=w;i++)
    {
        va=fact[h+w-a-i];
        va=(va*power(fact[h-a],M-2))%M;
        va=(va*power(fact[w-i],M-2))%M;
        v1.pb(va);
    }
    //cout<<v[0]<<" "<<v[1]<<" "<<v1[0]<<" "<<v1[1]<<endl;
    ll ans=0;
    for(int i=0;i<v.size();i++)
    {
        ans=(ans+(v[i]*v1[i])%M)%M;
    }
    cout<<ans<<endl;
}
int main()
{
    solve();
}


Measured memory_bytes: 4084
s = input()
stack = []
n = len(s)

ans = 0
prev = 0
each = []
for i in range(n):
    if s[i] == '\\':
        stack.append(i)
    elif s[i] == '_':
        pass
    else:
        if len(stack) != 0:
            idx = stack.pop()
            ans += (i - idx)
            if len(stack) == 0:
                each.append(ans - prev)
                prev = ans

each2 = []
stack2 = []
ans2 = 0
prev2 = 0
if len(stack) >= 1:
    for i in range(n-1,stack[0],-1):
        if s[i] == '/':
            stack2.append(i)
        elif s[i] == '_':
            pass
        else:
            if len(stack2) != 0:
                idx = stack2.pop()
                ans2 += (idx - i)
                if len(stack2) == 0:
                    each2.append(ans2 - prev2)
                    prev2 = ans2
each2.reverse()
each.extend(each2)
print(ans)
if len(each) == 0:
    print(len(each))
else:
    print(len(each),end=" ")
    print(*each)



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

using namespace std;

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
//atcoder
public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int ans = 0;
        int n = scanner.nextInt();
        TreeMap<Long, Integer> mapping = new TreeMap<>();
        for(int i = 0; i < n; i++) {
            long v = scanner.nextInt();
            if (!mapping.containsKey(v)) mapping.put(v, 0);
            mapping.put(v, mapping.get(v) +1);
        }
        while(!mapping.isEmpty()) {
            long cur = mapping.lastKey();
            mapping.put(cur, mapping.get(cur) - 1);
            if (mapping.get(cur) == 0) mapping.remove(cur);
            long next = (Long.highestOneBit(cur)) << 1;
            long val = next - cur;
            if (mapping.containsKey(val)) {
                ans++;
                mapping.put(val, mapping.get(val) -1);
                if (mapping.get(val) == 0) mapping.remove(val);
            }
        }
        out.println(ans);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

int main(){
	int H,W;
	cin >> H >> W;
	vector<string> A(H);
	for(int i=0;i<H;i++)cin >> A[i];
	int h=0,w=0;
	A[0][0]='.';
	for(;;){
		if(h==H-1 && w==W-1)break;
		if(w<W-1 && A[h][w+1]=='#'){
			w++;
			A[h][w]='.';
			continue;
		}
		if(h<H-1 && A[h+1][w]=='#'){
			h++;
			A[h][w]='.';
			continue;
		}
		cout << "Impossible" << endl;
		return 0;
	}
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++){
			if(A[i][j]=='#'){
				cout << "Impossible" << endl;
				return 0;
			}
		}
		
	cout << "Possible" << endl;
	return 0;
}

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

int main(){
  int N,sum=0;
  cin>>N;
  vector<int>v(N);
  for (int i=0;i<N;i++){
    int a;
    cin>>a;
    v.at(0)=a;
    sort(v.begin(),v.end());
    if (v.at(N-1)==a){
      sum++;
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
using namespace std;
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-6;
const int MAX=1e5+10;
const ll mod=1e9+7;
int main()
{
	int n,i,j,k,d[55],ans,res,flag[33],x;
	while(~scanf("%d",&n))
	{
		mem(flag,0);
		flag[0]++;
		for(i=0;i<n;i++)
		{
			scanf("%d",&x);
			flag[x]++;
		}
		if(n>23)
		{
			puts("0");
			goto end;
		}
		for(i=1;i<12;i++)
		{
			if(flag[i]>2)
			{
				puts("0");
				goto end;
			}
			if(flag[i]==2)
			{
				flag[i]=flag[24-i]=1;
			}
		}
		if(flag[0]>=2||flag[12]>=2)
		{
			puts("0");
			goto end;
		}
		n=0;
		for(i=0;i<24;i++)
		{
			if(flag[i]) d[n++]=i;
		}
		if(n>=15)
		{
			puts("1");
			goto end;
		}
		d[n++]=24;
		ans=0;
		for(i=0;i<(1<<(n-1));i++)
		{
			for(j=0;j<(n-1);j++)
			{
				if(i&(1<<j))
				{
					if(d[j]) d[j]=24-d[j];
				}
			}
			res=INF;
			for(j=0;j<n;j++)
			{
				for(k=0;k<n;k++)
				{
					if(j==k) continue;
					res=min(res,abs(d[j]-d[k]));
				}
			}
			if(res!=INF) ans=max(ans,res);
			for(j=0;j<(n-1);j++)
			{
				if(i&(1<<j))
				{
					if(d[j]) d[j]=24-d[j];
				}
			}
		}
		printf("%d\n",ans);
		end:;
	}
	return 0;
}
/*
13
0 1 2 3 4 5 6 7 8 9 10 11 12
*/

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		while(m-- > 0) {
			int i = sc.nextInt(), j = sc.nextInt();
			
			if(!map.containsKey(i))	map.put(i, 1);
			else	map.put(i, map.get(i)+1);
			
			if(!map.containsKey(j))	map.put(j, 1);
			else	map.put(j, map.get(j)+1);
		}
		
		boolean f = true;
		for(int i : map.keySet())
			if(map.get(i) % 2 != 0) {
				f = false;
				break;
			}
		
		if(f)	System.out.println("YES");
		else	System.out.println("NO");
	}
}


Measured memory_bytes: 90132
N,T=map(int,input().split())
t=list(map(int,input().split()))
bgn=0
end=T
res=0
for i in range(1,N):
    if end<=t[i]:
        res+=end-bgn
        bgn=t[i]
        end=t[i]+T
    else:
        end=T+t[i]
res+=end-bgn
print(res)

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

unsigned long mod = 1000000007;
unsigned long dp[1000010][4];

int main() {
  string s;
  cin >> s;
  int s_len = (int)s.length();
  dp[s_len][3] = 1;
  dp[s_len][2] = 0;
  dp[s_len][1] = 0;
  dp[s_len][0] = 0;
  string abc = "ABC";
  for (int i=s_len-1; i>=0; i--) {
    for (int j=3; j>=0; j--) {
      if (j == 3 && s[i] == '?') {
        dp[i][j] = (3 * dp[i+1][j]) % mod;
      } else if (j == 3) {
        dp[i][j] = (1 * dp[i+1][j]) % mod;
      } else if (s[i] == '?') {
        dp[i][j] = (3 * dp[i+1][j] + 1 * dp[i+1][j+1]) % mod;
      } else if (s[i] == abc[j]) {
        dp[i][j] = (1 * dp[i+1][j] + 1 * dp[i+1][j+1]) % mod;
      } else {
        dp[i][j] = (1 * dp[i+1][j]) % mod;
      }
    }
  }
  cout << dp[0][0] << endl;
  return 0;
}



Measured memory_bytes: 4608
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

int *read_array(int N)
{
    int *array;
    int i,m;
    array = new int[N];
    for(i=0;i<N;i++){
        scanf("%d",&m);
        array[i] = m;
    }

    return array;
}

void print_array(int *array, int N)
{
    int i;
    for(i=0;i<N;i++){
        if(i!=N-1){
            printf("%d ",array[i]);
        }else{
            printf("%d",array[i]);
        }
    }
    printf("\n");
    return;
}

int selectionSort(int *A, int N)
{
    int i,j,minj,v,num,flag;
    num = 0;
    flag = 0;
    for(i=0;i<N;i++){
        minj = i;
        for(j=i;j<N;j++){
            if(A[j]<A[minj]){
                minj=j;
                flag = 1;
            }
        }
        v = A[minj];
        A[minj] = A[i];
        A[i] = v;
        if(flag){
            num += 1;
            flag = 0;
        }

    }
    return num;
}

int main()
{
    int *A,N,num;
    scanf("%d",&N);
    A = read_array(N);
    num = selectionSort(A,N);
    print_array(A,N);
    printf("%d\n",num);

    return 0;
}


Measured memory_bytes: 3240
using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        for (int i = 1; i <= n; i++ )
        {
            if(i%3==0||i%10==3)
                Console.Write(" " + i);
            else
            {
                int x = i;
                while (x>0)
                {
                    x /= 10;
                    if (x < 3) 
                        break;
                    if (x % 10 == 3)
                    {
                        Console.Write(" " + i);
                        break;
                    }

                }
            }
        }
            Console.WriteLine();
    }
}

Measured memory_bytes: 9256
import java.util.*;

class Main{
  static int n,m,l,a,i,j,k;
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    n = sc.nextInt();
    m = sc.nextInt();
    l = sc.nextInt();
    long[][] matrixa = new long[n][m];
    long[][] matrixb = new long[m][l];
    long[][] matrixc = new long[n][l]; 
    for (i= 0; i<n; i++) {
      for (j= 0; j<m; j++) {
        a = sc.nextInt();
        matrixa[i][j] = a;
      }
    }  
    for (i= 0; i<m; i++) {
      for (j= 0; j<l; j++) {
        a = sc.nextInt();
        matrixb[i][j] = a;
      }
    }
    for (i= 0; i<n; i++) {
      for (j= 0; j<l; j++) {
        for (k= 0; k<m ; k++) {
             matrixc[i][j] += matrixa[i][k] * matrixb[k][j];
        }
      }
    }
    for (i= 0; i<n; i++) {
      for (j= 0; j<l; j++) {
        if (j != l-1) {
        System.out.print(matrixc[i][j] + " ");
        } else {
          System.out.println(matrixc[i][j]);
        }
      }
    }
  }   
}


Measured memory_bytes: 54040
#include<stdio.h>
int Min(int a,int b){
	if(a>b) return b;
	else return a;}
int main(){
	int N,A,B,X,Y;
	int sA,sX;
	scanf("%d%d%d%d%d",&N,&A,&B,&X,&Y);
	sA=B*(N/A),sX=Y*(N/X);
	if(N%A) sA+=B;
	if(N%X) sX+=Y;
	printf("%d\n",Min(sA,sX));
	return 0;
}



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

int main(){
  string A,B;
  cin >> A>>B;
  int c,d;
  cin>>c>>d;
  string U;
  cin>>U;
  if(U==A){
    c--;
  }
  else{
    d--;
  }
  cout<<c<<" "<<d<<endl;

  
}
 
  


Measured memory_bytes: 256