akhauriyash/Code-Regression huggingface dataset:
H, W = map(int, input().split())
ans = float("inf")


for i in range(2):
    if i == 0:
        ver, hori = H, W
    else:
        ver, hori = W, H
    for ha in range(1, ver):
        sa = ha * hori
        h = ver - ha
        
        # Case1 横二本の区切り線
        if h % 2 == 0:
            hb, hc = h // 2, h // 2
        else:
            hb, hc = h // 2, h // 2 + 1
        sb1, sc1 = hb * hori, hc * hori
        diff1 = max(sa, sb1, sc1) - min(sa, sb1, sc1)
        
        # Case2 横一本、縦一本区切り線
        if hori % 2 == 0:
            wb, wc = hori // 2, hori // 2
        else:
            wb, wc = hori // 2, hori // 2 + 1
        sb2, sc2 = h * wb, h * wc
        diff2 = max(sa, sb2, sc2) - min(sa, sb2, sc2)
        
        tmp_min =  min(diff1, diff2)
        ans = min(ans, tmp_min)


print(ans)


Measured memory_bytes: 3064
n=int(input())
A=[0]+list(map(int,input().split()))+[0]
S=sum(abs(A[j]-A[j+1]) for j in range(n+1))
for i in range(n):
  if (A[i+1]-A[i])*(A[i+2]-A[i+1])>=0:
    print(S)
  else:
    print(S-abs(A[i+1]-A[i])-abs(A[i+2]-A[i+1])+abs(A[i+2]-A[i]))

Measured memory_bytes: 14040
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    string S;
    cin>>N>>S;
    int ans=1;
    for(int i=0;i<N;i++){
        if(i==0)continue;
        if(S.at(i-1)!=S.at(i)){
            ans++;
        }
    } 
     cout<<ans<<endl; 
}

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


int main()
{
	ll N,K;
	cin>>N>>K;
	if(K%2==1)
	{
		cout<<(ll)pow(N/K,3.0)<<endl;
	}
	else
	{
		cout<<(ll)pow(N/K,3.0)+(ll)pow(N/(K/2)-N/K,3.0)<<endl;
	}
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  int n;
  cin >> n;
  int x = 1000;
  int sum = 0;
  while (true){
    sum += x;
    if (sum >= n){
      cout << sum - n << "\n";
      return 0;
    }
  }
  assert(false);
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#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)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

bool enough(vll& h,ll x,ll a,ll b){
    ll use=0;
    rep(i,h.size()){
        ll t=h[i]-(ll)x*b;
        if(t>0){
            // if(x==1)cout<<ceil((double)t/(a-b))<<endl;
            use+=ceil((double)t/(a-b));
        }
    }
    // cout<<"use:"<<use<<endl;
    if(use>x)return false;
    else return true;
}


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

    ll n,a,b;
    cin>>n>>a>>b;
    vll h(n);
    rep(i,n)cin>>h[i];
    pair<ll,ll> range;
    range.first=1;
    range.second=INF;

    while(range.first<range.second){
        ll x=(range.first+range.second)/2;
        bool ch = enough(h,x,a,b);
        // cout<<"x:"<<x<<" ch:"<<ch<<endl;
        if(ch){
            range.second=x;
        }
        else{
            range.first=x+1;
        }
        // cout<<range.first<<" "<<range.second<<endl;
    }
    cout<<range.first<<endl;

//////////////////////////////////////////////////////
return 0;}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    ll a , b , c , k;
    scanf("%lld %lld %lld %lld" , &a , &b , &c , &k);

    ll ans = 0;

    if(a > k) {
            ans = k;
            k = 0;
    }
    else {
            ans += a;
            k -= a;
    }

    k -= b;

    if(k > 0){

    if(c > k) {
            ans -= k;
            k = 0;
    }
    else {
            ans -= c;
    }
    }

    printf("%lld\n" , ans);
}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  ll n,k; cin >> n >> k;
  vi a(n);
  rep(i,n){
    cin >> a[i];
    --a[i];
  }
  map<int,int> mp;
  int now = 0;
  vi place;
  while(1){
    if(mp[now] == 2) break;
    mp[now]++;
    place.emplace_back(now);
    now = a[now];
  }
  vi once,twice;
  int one = 0, two = 0;
  for(auto x : mp){
    if(x.second == 1) one++;
    else two++;
  }
  rep(i,one) once.emplace_back(place[i]);
  rep(i,two) twice.emplace_back(place[i+one]);
  if(k < one){
    cout << once[k]+1;
  }else{
    k -= one;
    cout << twice[k%two]+1;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 15776
n, a, b, c, d = map(int, input().split())
s = input()

a -= 1
b -= 1
c -= 1
d -= 1

if '##' in s[a:max(c,d)+1]:
    print('No')
    exit()

if c < d:
    print('Yes')
else:
    if '...' in s[b-1:d+2]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 63256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = int;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

vector<bool> seen;

vector<ll> ans(200010);
vector<set<int>> child(200010);
void dfs(const Graph &G, int v)
{
    seen[v] = true;
    for (auto &&next_v : G[v])
    {
        if (seen[next_v])
            continue;
        ans[next_v] += ans[v];
        dfs(G, next_v);
    }
}
int main()
{

    long long N;
    scanf("%lld", &N);
    long long Q;
    scanf("%lld", &Q);
    Graph G(N);
    std::vector<long long> a(N - 1);
    std::vector<long long> b(N - 1);
    for (int i = 0; i < N - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
      G[b].push_back(a);
    }
    for (int i = 0; i < Q; i++)
    {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    seen.assign(N,false);
    dfs(G, 0);

    for (int i = 0; i < N; i++)
    {
        cout << ans[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 36736
import java.util.Scanner;

class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int length = sc.nextInt();

		while(sc.hasNext()){

			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();

			int a2 = a * a;
			int b2 = b * b;
			int c2 = c * c;

		if(a2 + b2 == c2) {

			System.out.println("YES");

		}
		else if(b2 + c2 == a2){
			System.out.println("YES");
		}

		else if(a2 + c2 == b2) {
			System.out.println("YES");

		}

		else {
		System.out.println("NO");
		}
		}


	}

}

Measured memory_bytes: 34008
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
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; }

int main(){

	int X; cin >> X;

	int ans = 1;
	for(int i = 1; i <= X; i++){
		int tmp = i;
		for(int j = 2; j <= 100; j++){
			tmp *= i;
			if(tmp <= X){
				ans = max(ans, tmp);
			}
		}
		
	}

	cout << ans << endl;

}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
const int maxn=1000010;

int n;
long long st,ans,x[maxn],y[maxn];

int main()
{
	scanf("%d%lld",&n,&st);
	for (int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&x[i],&y[i]);
	}
	int l=1;
	int r=n;
	while (l<=r)
	{
		if (x[l]>=st) 
		{
			ans=ans+x[r]-st;
			break;
		}
		if (x[r]<=st)
		{
			ans=ans+st-x[l];
			break;
		}
		ans=ans+x[r]-x[l];
		if (y[l]>=y[r])
		{
			while (y[l]>=y[r] && l<r)
			{
				y[l]=y[l]+y[r];
				r--;
			}
		}
		else
		{
			while (y[l]<y[r] && l<r)
			{
				y[r]=y[r]+y[l];
				l++;
			}
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 5120
#include <iostream>

using namespace std;

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

    while(true) {
        int Q1, B, C1, C2, Q2;
        cin >> Q1 >> B >> C1 >> C2 >> Q2;
        if(!Q1) break;

        bool found = false;
        for(int q2 = Q2; q2 >= 1; --q2) {
            const int cost1 = C1*q2;
            const int rem = B - cost1;
            if(rem < 0) continue;
            const int amount = rem / C2;
            //cout << q2 << ' ' << rem << ' ' << amount << endl;
            if(q2 + amount >= Q1) {
                cout << q2 << ' ' << amount << endl;
                found = true;
                break;
            }
        }
        if(!found) {
            cout << "NA" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1192
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
count=0
ans=0
for i in range(n):
  a=list(map(int,input().split()))
  for j in range(m):
    ans+=a[j]*b[j]
  if (ans+c)>0:
    count+=1
  ans=0
print(count)

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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0 ; i < n ; i += 1){
        if(i % 2 == 0){
            if(s[i] == 'L'){
                cout << "No";
                return 0;
            }
        }else{
            if(s[i] == 'R'){
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=55;
int n,k;
ll s,t,f[18][2],ycl[N],c[N][N],a[N],ans;
void dfs(int p,ll zt,int xs){
	if(!zt)return;
	if(p==18){
		ans+=ycl[__builtin_popcountll(zt)]*xs; 
		//cout<<ans<<" "<<xs<<" "<<zt<<endl;
		return;
	}
	//if(p<3)cout<<zt<<" "<<f[p][0]<<" "<<f[p][1]<<endl;
	if(s>>p&1){
		dfs(p+1,zt&f[p][1],xs);
	}else if(!(t>>p&1)){
		dfs(p+1,zt&f[p][0],xs);
	}else{
		dfs(p+1,zt&f[p][0],-xs);
		dfs(p+1,zt&f[p][1],-xs);
		dfs(p+1,zt,xs);
	}
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	n=read(),k=read(),s=read(),t=read();
	For(i,0,n)For(j,c[i][0]=1,i)c[i][j]=(c[i-1][j-1]+c[i-1][j]);
	For(i,0,n)For(j,1,k)ycl[i]+=c[i][j];
	For(i,0,n-1)a[i]=read();
	For(i,0,17){
		For(j,0,n-1)if(a[j]>>i&1)f[i][1]|=(ll)1<<j;
		f[i][0]=f[i][1]^(((ll)1<<n)-1);
	}
	For(i,0,17)if((s>>i&1)&&(t>>i&1)==0){
		puts("0"); exit(0);
	}
	//puts("fj");
	dfs(0,((ll)1<<n)-1,1);
	cout<<ans<<endl;
}


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

int main(){
    
    int a,b,c;
    cin >> a >> b >> c;
    
    vector<int> v = {a,b,c};
    sort(v.begin(),v.end());
    
    cout << v.at(2)*10 + v.at(1) + v.at(0) << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,K;
    int A[114514],B[114514];
    cin >> N >> K;
    REP(i,N){
        cin >> A[i] >> B[i];
    }
    int L=K;
    int Ans=0;
    int e=0;
    while(1){
        int num=0;
        REP(i,N){
            if((L|A[i])==L){
                num+=B[i];
            }
        }
        if(L<=K){
            Ans=max(Ans,num);
        }
        
        //cout << L MM num<< endl;
        L|=(1<<e);
        L&= ~(1<<(e+1));
        e++;
        
        if(L>=2*K)break;
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))
SUM = [0 for _ in range(32)]
for i in range(N):
    for j in range(32):
        SUM[j] += ((A[i] >> j) & 1)
for i in range(32):
    SUM[i] %= 2
res = [0 for _ in range(N)]
for i in range(N):
    for j in range(32):
        res[i] += ((((A[i] >> j) & 1) ^ SUM[j]) << j)
for i in range(N):
    print(res[i], end = ' '*(i!=(N-1)))
print()

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

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            return Array().Select(int.Parse).ToArray();
        }
        public long[] LongArray()
        {
            return Array().Select(long.Parse).ToArray();
        }
    }

    class Program
    {

        public void Solve()
        {
            var sc = new Scanner();
            char x = sc.Next()[0], y = sc.Next()[0];
            if (x == y)
            {
                Console.WriteLine("=");
            }
            else if (x > y)
            {
                Console.WriteLine(">");
            }
            else
            {
                Console.WriteLine("<");
            }
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

using ll = long long;

int main()
{
    string S;
    cin >> S;

    int Q;
    cin >> Q;
    
    bool flag = false;

    for (int i = 0; i < Q; i++) {
        int q0, q1;
        char q2;

        cin >> q0;
        if (q0 == 1) {
            flag = !flag;
        } else if (q0 == 2) {
            cin >> q1 >> q2;
            if (q1 == 1) {
                if (flag) S.push_back(q2);
                else S.insert(0, string(1, q2));
            } else if (q1 == 2) {
                if (flag) S.insert(0, string(1, q2));
                else S.push_back(q2);
            }
        }
        
    }

    if (flag) reverse(S.begin(), S.end());

    cout << S << endl;
}


Measured memory_bytes: 900
#include <iostream>

using namespace std;

int main()
{
    string x;
    cin>>x;
    for(int i=0;i<x.length();i++)
    {
        x[i]='x';
    }
    for(int i=0;i<x.length();i++)
    {
        cout<<x[i];
    }
    return 0;
}

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

const int MAX_N = (int)(1e5 + 5);

int n;
int a[MAX_N];

map<int, int> cnt;
int cand = 0;
int odd = 0, even = 0;

int ans;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%d\n", &(a[i]));
  }

  for (int i = 0; i < n; ++i) {
    cnt[a[i]] += 1;
  }

  for (auto itr = cnt.begin(); itr != cnt.end(); ++itr) {
    cand += 1;
    if (itr->second % 2 == 0) even += 1;
    else odd += 1;
  }

  if (even % 2 == 0) ans = cand;
  else ans = cand - 1;

  printf("%d\n", ans);

	return 0;
}

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

class Program
{
    static void Main()
    {
        var i = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        Console.WriteLine(string.Join("\n", Enumerable.Range(i[0], i[2]).Union(Enumerable.Range(i[1] - i[2] + 1, i[2])).Where(x => i[0] <= x && x <= i[1]).OrderBy(x => x).Select(x => x.ToString())));
    }
}

Measured memory_bytes: 13408
def check(learn_total):
    for i in range(m):
        if learn_total[i] < x:
            return False
    return True
 
 
def calc_price(bit):
    price_total = 0  # 値段の合計
    learn_total = [0] * m  # 理解度
 
    for i in range(n):
        if (bit >> i) & 1:  # i桁目が0か1か見て、i番目を買うか買わないか判定します
            price_total += c[i]  # 買うので、i番目の値段を加算します
            learn = a[i]  # 「i番目の参考書を読んで増える、各アルゴリズムの理解度」のリストです
            for j, le in enumerate(learn):  # 理解度を足します。 enumerateを使うと、range(n)よりスマートです
                learn_total[j] += le
 
    # 条件を満たすか、check関数で確認します
    if check(learn_total):
        return price_total
    else:
        return INF
 
 
if __name__ == '__main__':
    INF = float("inf")
 
    n, m, x = list(map(int, input().split()))
 
    # 空のリストを作って、appendで追加していきます
    c = []  # 参考書の値段です
    a = []  # 各参考書に入る理解度です
 
    for i in range(n):
        c_temp, *a_temp = list(map(int, input().split()))  # こうすると、2つ目以降をリストで受け取れます
        c.append(c_temp)
        a.append(a_temp)
 
    ans = INF
 
    for bit in range(1 << n):
        price = calc_price(bit)  # 条件を満たすなら価格、満たさないならINFが返ってきます
        ans = min(ans, price)  # 答えを更新します
 
    if ans == INF:
        print(-1)
    else:
        print(ans)
        

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

int main() {
    int64_t n;
    cin >> n;
    vector<int64_t> a(n);
    for (auto& e : a) cin >> e;

    int64_t can1 = 0, can2 = 0;
    for (int64_t i = 0, acc1 = 0, acc2 = 0; i < n; i++) {
        acc1 += a[i], acc2 += a[i];
        if (i % 2 == 0) {
            if (acc1 <= 0) {
                can1 += -acc1 + 1;
                acc1 = 1;
            }
            if (acc2 >= 0) {
                can2 += acc2 + 1;
                acc2 = -1;
            }
        } else {
            if (acc1 >= 0) {
                can1 += acc1 + 1;
                acc1 = -1;
            }
            if (acc2 <= 0) {
                can2 += -acc2 + 1;
                acc2 = 1;
            }
        }
    }

    cout << min(can1, can2) << endl;
}


Measured memory_bytes: 1024
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>

using namespace std;
typedef long long ll;

const ll INF = std::numeric_limits<ll>::max();

int main()
{
	int Q, H, S, D;
	cin >> Q >> H >> S >> D;
	ll N;
	cin >> N;
	if (S > Q * 4)
		S = Q * 4;
	if (D > Q * 8)
		D = Q * 8;
	if (S > H * 2)
		S = H * 2;
	if (D > H * 4)
		D = H * 4;
	ll n = N / 2;
	ll m = N % 2;
	ll ans = min(D*n + S*m, S*N);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll x, y;
    string s;
    cin >> s >> x >> y;
    s.push_back('T');
    ll n = s.size();
    vector<vector<bool>> dpx(n, vector<bool>(20000, false)), dpy(n, vector<bool>(20000, false));
    bool fst = true;
    ll cnt = 0, direct = 1, refx = 0, refy = 0;
    dpx[0][10000] = true;
    dpy[0][10000] = true;
    rep(i, 0, n){
        if(s[i] == 'F') {
            cnt++;
        }else{
            rep(j, 0, 20000){
                if(direct){
                    ll itr = refx;
                    if(dpx[itr][j]){
                        if(!fst && j - cnt >= 0) dpx[itr+1][j-cnt] = true;
                        if(j + cnt < 20000) dpx[itr+1][j+cnt] = true;
                    }
                } else {
                    ll itr = refy;
                    if(dpy[itr][j]){
                        if(j - cnt >= 0) dpy[itr+1][j-cnt] = true;
                        if(j + cnt < 20000) dpy[itr+1][j+cnt] = true;
                    }
                }
            }
            cnt = 0;
            fst = false;
            if(direct) refx++;
            else refy++;
            direct = (direct + 1) % 2;
        }
    }
    rep(i, 0, 20000) if(dpx[refx][i]) cerr << i + 10000 << endl;
    if(dpx[refx][x+10000] && dpy[refy][y+10000]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 43096
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

long long x;
long long from[50], to[50];
string ans = "";

int main() { 

  from[0] = 0; to[0] = 1;
  long long cur = 1;
  for (int i = 1; i < 40; i++) {
    cur = cur * -2;
    from[i] = min(from[i - 1], from[i - 1] + cur);
    to[i] = max(to[i - 1], to[i - 1] + cur);
    // cerr << from[i] << " " << to[i] << endl;
  }

  cin >> x;

  for (int i = 39; i >= 0; i--) {
    long long l = 1, r = 1;
    if (i > 0) {
      l = from[i - 1] + cur, r = to[i - 1] + cur;
    }
    // cerr << l << " " << r << endl;

    if (x >= l && x <= r) {
      ans.append(1, '1');
      x -= cur;
    } else if (sz(ans)) {
      ans.append(1, '0');
    }

    cur /= -2;
  }

  if (ans == "") {
    ans = "0";
  }
  // reverse(all(ans));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vll A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);    
  }
  sort(ALL(A));
  deque<ll> deq;
  for(int i = 0; i < N; i++){
    ll num;
    if(i % 2 == 0) num = A.at(i/2);
    else num = A.at(N-1 - i/2);

    if(deq.size() == 0){
      deq.push_front(num);
      continue;
    }

    if(i == N-1){
      if(abs(num - deq.front()) > abs(num - deq.back())) deq.push_front(num);
      else deq.push_back(num);
    }
    else{
      if(i % 4 == 0 || i % 4 == 3) deq.push_front(num);
      else deq.push_back(num);
    }
    
  }
  ll before = deq.front(); deq.pop_front();
  ll ans = 0;
  while(!deq.empty()){
    ll num = deq.front(); deq.pop_front();
    ans += abs(num - before);
    before = num;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1920
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 200005;
const int mod = (int) 1e9 + 7;

int fact[N];
int inver[N];

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

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

inline int mul(int a, int b) {
  return (int) ((long long) a * b % mod);
}

inline int fp(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int x) {
  return fp(x, mod - 2);
}

int comb(int n, int k) {
  if (n <= 0 || k > n) return 0;
  int ans = mul(fact[n], inver[k]);
  ans = mul(ans, inver[n - k]);
  return ans;
}

int n, a, b;

int main() {
  fact[0] = 1;
  inver[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = mul(fact[i - 1], i);
    inver[i] = inv(i);
  }
  cin >> n >> a >> b;
  int ans = fp(2, n);
  sub(ans, 1);
  int here = 1, ce = n;
  for (int i = 0; i < a; i++) {
    here = mul(here, ce--);
    here = mul(here, inver[i + 1]);
  }
  sub(ans, here);
  here = 1; ce = n;
  for (int i = 0; i < b; i++) {
    here = mul(here, ce--);
    here = mul(here, inver[i + 1]);
  }
  sub(ans, here);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    for (Array(_, m) <- in if m != 0) {
        val as = in.next.toList.zipWithIndex.sortBy(_._1)
        val x = as.map{case (a, i) => as.reverse.find{case (b, j) => a + b <= m && i != j} match {
            case Some(x) => Some(a + x._1)
            case None => None
        }}.flatten
        if (x.size != 0) println(x.max) else println("NONE")
    }
}

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

int i,j,k,block[500000][5],hhh,max[5],left,from,time;
int n,d,l,x;

int main(){
	while(scanf("%d",&n)*n){
		hhh=0;left=0;
		for(i=0;i<5;i++)max[i]=0;

		for(;n>0;n--){

			scanf("%d %d %d",&d,&l,&x); x--;
			left+=l;

			if(d==1){
				k=0;j=0;
				for(i=0;i<l;i++){if(max[x+i]>k){k=max[x+i];j=x+i;}}
				for(i=0;i<l;i++){max[x+i]=k+1;block[k][x+i]=1;}
				from=k;time=1;
			}
			else{
				for(i=0;i<l;i++)block[max[x]+i][x]=1;
				from=max[x];
				max[x]+=l;
				time=l;
				j=x;
			}

			if(hhh<max[j])hhh=max[j];

			for(i=0;i<time;i++){
				if(block[from][0]==1 && block[from][1]==1 && block[from][2]==1 && block[from][3]==1 && block[from][4]==1){
					for(j=0;j<5;j++){block[from][j]=0;}
					for(k=from+1;k<hhh+1;k++){
						for(j=0;j<5;j++){
							block[k-1][j]=block[k][j];
						}
					}
					left-=5;hhh--;
				}
				else from++;
			}

			for(j=0;j<5;j++){
				for(k=max[j];k>=0;k--){
					if(block[k][j]==1)break;
				}
				max[j]=k+1;
			}
		}

		for(i=0;i<hhh;i++){
			for(j=0;j<5;j++){
				block[i][j]=0;
			}
		}

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

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

using ll = long long;

void solve(long long N, std::vector<long long> A){
    ll ans = 0;
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    ans += A[0];
    for(int i = 0;i < N - 2;i++){
        //cout<<A[i / 2 + 1]<<" ";
        ans += A[i / 2 + 1];
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4868
#import<bits/stdc++.h>
#define l(x)std::lower_bound(B,B+*a,x-A)
int a[2<<18],B[1<<18],s,A,i=1,j,L;main(){for(;std::cin>>a[A++];);for(;i<1<<29;i*=2){for(;j++<*a;)B[j-1]=a[j+*a]%(i*2);for(std::sort(B,B+*a);--j;s^=(a[j]&i?*a-L:L)%2*i)A=a[j]%i,L=l(i*2)-l(i);}std::cout<<s;}

Measured memory_bytes: 2560
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

struct UnionFind {
	vector<long> par;//親を返す

	UnionFind(long N) : par(N) {
		for (int i = 0; i < N; i++) par[i] = i;//全て根である状態
	}

	long root(long i) {//根を返す
		if (par[i] == i) return i;
		return par[i] = root(par[i]); //根に直接繋ぎなおす
	}

	void unite(long x, long y) {//二つの木の統合(rxをryに繋ぐ)
		long rx = root(x);
		long ry = root(y);

		if (rx == ry) return;
		par[rx] = ry;
	}

	bool same(long x, long y) { return root(x) == root(y); }//根が等しいか
};

int main() {

	long N, M; cin >> N >> M;
	long res = 0;

	vector<pair<long, long>> edge;

	UnionFind tree(N);

	for (int i = 0; i < M; i++) {
		long a, b; cin >> a >> b;
        a--;b--;
		edge.push_back(make_pair(a, b));
	}

	for (int sk = 0; sk < M; sk++) {
		for (int i = 0; i < N; i++) {
			tree.par[i] = i; //初期化
		}
		for (int i = 0; i < M; i++) {
			if (sk == i) continue;
			tree.unite(edge[i].first, edge[i].second);
		}

		if (!tree.same(edge[sk].first, edge[sk].second)) res++; //スキップした辺のみ調べればよい。
	}

	cout << res << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int x,y,ans[100][100];
char sky[101][101];
int main()
{
	cin>>y>>x;
	for(int i=0;i<y;i++) {
		int p=0;
		bool b=0;
		scanf("%s",sky[i]);
		for(int j=0;j<x;j++){
			if(sky[i][j]=='c'){
				b=1;
				p=0;
				printf("%d",p++);
			} 
			else if(!b) printf("-1");
			else printf("%d",p++);
			
			if(j==x-1) printf("\n");
			else printf(" ");
		}
	}
}

Measured memory_bytes: 1188
#include<stdio.h>

int main(void)
{
    int a, b, c, d;

    scanf("%d%d", &a, &b);

    c = a + b;
    d = b - a;

    if (b % a == 0){
        printf("%d", c);
    }

    else
        printf("%d", d);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
	int n;
    cin >> n;
    vector<int> b;
    for(int i = 1; i <= 2000000; i *= 2){
        if(i > n){
            cout << b[b.size()-1] << endl;
            return 0;
        }
        b.pb(i);
    }
}


Measured memory_bytes: 3144
#include <stdio.h>
#define L 200

int main(void)
{
  int n,m,ax,by,i,j,flag=0,xma=-100,ymi=100;
  int x[L]={0},y[L]={0};

  scanf("%d",&n);
  scanf("%d",&m);
  scanf("%d",&ax);
  scanf("%d",&by);

  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
    if(x[i]>xma){
      xma=x[i];
    }
  }
  for(j=0;j<m;j++){
    scanf("%d",&y[j]);
    if(y[j]<=ymi){
      ymi=y[j];
    }
  }

  if(ax<by && xma<ymi){
    for(i=by;i>ax;i--){
      for(j=ymi;j>xma;j--){
        if(i==j){
          flag=1;
        }
      }
    }
  }

  if(flag==0){
    printf("War\n");
  }else{
    printf("No War\n");
  }

  return(0);
}


Measured memory_bytes: 128
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <fstream>
#include <cmath>

using namespace std;

int main(void)
{
	string s;

	cin >> s;

	for (int i = 0; i < s.length(); i++)
	{
		if (i % 2 == 0)
		{
			cout << s[i];
		}
	}
	cout << endl;

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int d1,d2;
  int flag=0;
  for(int i=0; i<n; i++){
    cin >> d1 >> d2;
    if(d1==d2){
      flag++;
      if(flag>=3){
        cout << "Yes";
        return 0;
      }
    }
    else flag=0;
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3672
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>
  
using namespace std;
  
void Solution()
{
    int a, b, c;
    double h, s, l;
     
    cin>>a>>b>>c;
     
    double raid = c * 3.141592653 / 180.0 ; 
     
    h = b * sin(raid);
    s = h * a * 0.5;
    l = sqrt(a * a + b * b - 2 * a * b * cos(raid)) + a + b;
     
    cout<<fixed<<setprecision(4)<<s<<endl;
    cout<<fixed<<setprecision(4)<<l<<endl;
    cout<<fixed<<setprecision(4)<<h<<endl;
 
}
int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
  int A, B, C, D ,E ,F;
  string S,Sa,Sb,Sc;
  cin >> S;
  bool ans = false;
  if(S[0] == S[1] && S[1] == S[2])ans = true;
  if(S[1] == S[2] && S[2] == S[3])ans = true;
  if(ans)cout << "Yes" << endl;
else cout << "No" << endl;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;
int numofbits(int bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

// BEGIN //////////////////////////////////////////////////////////////
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    vector<int> ans;
    while (n) {
      for (int t = 1024; ; t >>= 1) {
        if (n & t) {
          ans.push_back(t);
          n ^= t;
          break;
        }
      }
    }
    for (int i = ans.size() - 1; i; i--) {
      cout << ans[i] << SPACE;
    }
    cout << ans[0] << endl;
  }
	return 0;
}
// END   //////////////////////////////////////////////////////////////

Measured memory_bytes: 1232
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a%b) : a;
}

signed main(void)
{
	ll n, x;
	cin >> n >> x;
	cout << 3*(n-gcd(n, x)) << endl;

	return 0;
}


Measured memory_bytes: 256
import math
import copy

neko = 0
nuko = 0
inu = 0
n = int(input())
h = [int(x) for x in input().split()]
nya = h[0]
h = h[1:]
for i in h:
    if nya >= i:
        neko += 1
    else:
        neko = 0
    if neko > inu:
        inu = neko
    nya = i
print(inu)

Measured memory_bytes: 14912
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

/*-----------Main-----------*/

func main() {
	n, m := readI(), readI()
	h := readIs(n)
	observatory := make([][]int, n)
	for i := 0; i < m; i++ {
		a, b := readI(), readI()
		observatory[a-1] = append(observatory[a-1], h[b-1])
		observatory[b-1] = append(observatory[b-1], h[a-1])
	}
	ans := 0
	for i := 0; i < len(observatory); i++ {
		tmp := true
		for j := 0; j < len(observatory[i]); j++ {
			if h[i] <= observatory[i][j] {
				tmp = false
			}
		}
		if tmp {
			ans++
		}
	}
	fmt.Println(ans)
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-2.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}


Measured memory_bytes: 12084
#include <bits/stdc++.h>
#define int long long
//#define double long double
#define endre getchar();getchar();return 0
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int n, cnt[30];
string s;
signed main() {
	cin >> n >> s;
	rep(i, n) {
		cnt[s[i] - 'a']++;
	}
	int ans = 1;
	rep(i, 26) {
		ans *= cnt[i] + 1;
		ans %= moder;
	}
	cout << (ans - 1) % moder << endl;
	endre;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll INF=(1ll<<60);
constexpr ll mod=1000000007;
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    ll n;cin>>n;
    vector<ll> vec1(n),vec2(n);

    ll ans=0;
    rep(i,n){
        cin>>vec1[i];
    }
    rep(i,n){
        cin>>vec2[i];
    }

    rep(i,n){
        if(vec1[i]-vec2[i]>0){
            ans+=vec1[i]-vec2[i];
        }
    }

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

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

vector<int> c(26);
vector<vector<int>> s(365 ,vector<int>(26));
vector<vector<int>> last(365 ,vector<int>(26));

int culc(int d){
    int ret=1;
    ll maxv=0;
    rep(j,26){
        if(s[d][j]+c[j]*(d+1-last[d][j])>maxv){
            maxv=s[d][j]+c[j]*(d+1-last[d][j]);
            ret=j+1;
        }
    }
    return ret;
}

int main(){
    int D;
    cin>>D;
    rep(i,26){ 
        cin>>c[i];
    }
    rep(d,D) rep(j,26) cin>>s[d][j];
    int t;
    int v=0;
    vector<int> kaisai_bi(26);
    int ans=18398+s[1][16];
    rep(j,26){
        if(j==16)continue;
        else if(j==0)ans-=c[j]*(2-1);
        else ans-=c[j]*(2-0);
    }
    rep(d,D) {
//        cin>>t;
        t=culc(d);
        cout<<t<<endl;
        t--;
        v+=s[d][t];
        kaisai_bi[t]=d+1;
        rep(j,26) last[d][j]=kaisai_bi[j];
        rep(j,26){ 
            v-=c[j]*(d+1-last[d][j]);
            }
    }
//    cout<<v<<endl;

    int m;
//    cin>>m;
m=0;
    rep(i,m){
        int dd,q;
        cin>>dd>>q;
        q--;
        int j=0;
        while(last[dd-1][j]!=dd || j>=26) j++;
        if(j==26){ 
            cout<<"error"<<endl;
            return 0;
        }
        v-=s[dd-1][j];
        for(int d=dd-1;d<D;d++){ 
            if(last[d][j]==dd){
                v+=c[j]*(d+1-last[d][j]);
                last[d][j]=(d==0? 0 : last[d-1][j]);
                v-=c[j]*(d+1-last[d][j]);
            }
            else{ 
                break;
            }
        }
        
        v+=s[dd-1][q];
        int before=last[dd-1][q];
        for(int d=dd-1;d<D;d++){ 
            if(last[d][q]==before){ 
                v+=c[q]*(d+1-last[d][q]);
                last[d][q]=dd;
                v-=c[q]*(d+1-last[d][q]);
            }
            else{ 
                break;
            }
        }
        cout<<v<<endl;
    }
    return 0;
}


Measured memory_bytes: 3728
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif
   int h1,h2,m1,m2,k;
   cin >> h1 >> m1 >> h2 >> m2 >> k;
   int t1 = (h1*60)+m1;
   int t2 = (h2*60)+m2;
   int ans = (t2-k)-t1;
   cout << max(0LL,ans);
}






Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
#define LEN 100000
typedef struct pp{
  char name[100];
  int time;
} X;
X Y[LEN];
int head,tail,n;
void enqueue(X);
X dequeue(void);
int min(int,int);
int main(){
  int y,i,a;
  int clock=0;
  X x;
    scanf("%d%d",&n,&y);
    for(i=1;i<=n;i++){
      scanf("%s",Y[i].name);
      scanf("%d",&Y[i].time);
    }
    head=1;
    tail=n+1;
    while(head!=tail){
      x=dequeue();
      a=min(y,x.time);
      x.time-=a;
      clock+=a;
      if(x.time>0)
	enqueue(x);
      else{
	printf("%s %d\n",x.name,clock);
      }
    }
    return 0;
}

      int min(int x,int y){
	return x<y? x : y;
      }
    void enqueue(X x){
      Y[tail]=x;
      tail=(tail+1)%LEN;
    }
    X dequeue(){
      X x=Y[head];
      head=(head+1)%LEN;
      return x;
    }



Measured memory_bytes: 11856