akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

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

	vii pairs(n);
	rep(i, n) cin >> pairs[i].first >> pairs[i].second;

	int ans = inf;
	bool IsTLE = true;

	rep(i, n) {
		if (pairs[i].second <= t) {
			IsTLE = false;
			ans = min(ans, pairs[i].first);
		}
	}
	if (IsTLE) cout << "TLE" << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  int r,d,x;
  cin >> r >> d >> x;
  rep(i,10) {
    x *= r;
    x -= d;
    cout << x;
    hinata;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include<bits/stdc++.h>
#define sp " "
#define endl "\n"
#define MAX 10e9
#define MAXN 100001 
#define inf_int 2e9
#define inf_ll 2e18
#define e 1e-9
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpl vector<pair<ll,ll>>
#define vpc vector<pair<char,char>>
#define adj_list vector<vl> 
#define umap unordered_map<ll, ll>
#define pll pair<ll,pair<ll, ll>>
#define clr(x) memset(x,0,sizeof(x))
#define set(x,k) memset(x,k,sizeof(x))
#define cy cout << "YES" << endl
#define  cn cout << "NO" << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;

ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (auto i=2; i<MAXN; i++) 
  		spf[i] = i; 
  	for (auto i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (auto i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (auto j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
	return;
} 

vl getFactorization(ll x) 
{ 
    vl ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 


void check()
{
	ll k,x;
	cin >> k >> x;
	if(500*k>=x) cout << "Yes" << endl;
	else cout << "No" << endl;
    return ;
}

int32_t main()
{
    fastio;
    ll t = 1;
    //cin >> t;
    while(t--)
        check();
    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    ll N,K; cin >> N >> K;
    vector<ll> a(N); REP(i,N) cin >> a[i];
    vector<ll> S(N+1); S[0]=0; REP(i,N) S[i+1] = S[i] + a[i];
    vector<ll> A;
    REP(i,N)FOR(j,i,N){
        A.push_back(S[j+1]-S[i]);
    }

    ll ans = 0;
    REP(i,40){
        ll bit = ans | 1LL<<(39-i), n = 0;
        REP(j,A.size()) if((A[j] & bit) == bit) n++;
        if(K <= n) ans |= bit;
    }
    cout << ans << en;
    return 0;
}

Measured memory_bytes: 6516
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{
    fastio;
    ll n,p,i,c=INFLL,x=-1,y=0,z=0;
    cin>>n>>p;
    vector<ll>v(p);
    set<ll>s;
    if(p==0)
    {
        cout<<n<<endl;
        return 0;
    }
    for(i=0;i<p;i++)
    {
        cin>>v[i];
        if(abs(n-v[i])<c)
        {
            c=abs(n-v[i]);
            x=v[i];
        }
        s.in(v[i]);
    }
    for(i=x+1;;i++)
    {
        if(s.count(i)==0)
        {
            y=i;
            break;
        }
    }
    for(i=x-1;;i--)
    {
        if(s.count(i)==0)
        {
            z=i;
            break;
        }
    }
    if((y-x)<abs(z-x))
    {
        cout<<y<<endl;
    }
    else if(abs(z-x)<(y-x))
        cout<<z<<endl;
    else
        cout<<min(y,z)<<endl;

}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
// cout<<fixed<<setprecision(10);
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;}

ll x;

ll f(ll n) {
    if(n == -1) {
        return 0;
    }
    return n / x + 1;
}

int main() {
    ll a,b; cin >> a >> b;
    cin >> x;
    ll an = f(b) - f(a-1);
    cout << an << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    int k;
    cin >> k;
    ll sum = 0;
    repr(a, 1, k + 1) repr(b, 1, k + 1) repr(c, 1, k + 1) sum += gcd(gcd(a, b), c);
    cout << sum << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	string n;
	ll m=0,l=0;
	cin>>n;
	for(int i=0;i<n.size();i++){
		m = m*10 + (n[i]-'0');
		l += (n[i]-'0');
	}

	//cout<<m<<endl;
	//cout<<l<<endl;

	if(m%l==0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

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

int main(){
    int A, B;
    int a,b,c;
    int max = INT_MIN;

    cin >> A >> B ;

    a = A + B;
    b = A - B;
    c = A * B;

    max = a;
    if(b > max){
        max = b;
    }
    if(c > max){
        max = c;
    }
    cout << max; 

}

Measured memory_bytes: 384
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const int INF=1000100010;
int main(){
    ll n,k;cin>>n>>k;
    ll tmp=n/k;
    ll ans=0;
    if(abs(n-tmp*k)>abs(n-(tmp+1)*k))cout<<abs(n-(tmp+1)*k)<<endl;
    else cout<<abs(n-tmp*k)<<endl;
}

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

int a[101];
int N;

bool water(){
    int s,g;
    s = -1; 
    g = -1;
    for(int i = 0; i < N; i++){
        if((s < 0) && a[i] > 0){
            s = i;  
        }
        if((s >= 0) && (a[i] == 0) && (g < 0)){
            g = i - 1;
            break;
        }
        if(s >= 0 && i == N - 1){
            g = i;
        }
    }
    //cout << "s:" << s << ", g:" << g << endl;
    bool flag = false;
    for(int i = s; i <= g && s >= 0; i++){
        flag = true;
        a[i] -= 1;
    }
    /*
    for(int i = 0; i < N; i++){
        cout << a[i] << ' ';
    }
    cout << endl;
    */
    return flag;
}

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    int ans = 0;
    while(water()){
        ans += 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{

public static void larger(int a, int b){
if (a > b) {
System.out.println("a > b");
} else if (b > a) {
System.out.println("a < b");
} else {
System.out.println("a == b");
}
}
	
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int p = scanner.nextInt();
int q = scanner.nextInt();
larger(p, q);

}
}



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

#define out(v) cout<<v<<"\n"
#define rep(i,n) for(int i=0;i<(n);++i)

const int WHITE = 0, BLACK = 1;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int A, B; cin >> A >> B;

  int board[100][100];
  rep(i, 100) rep(j, 100) {
    if (i < 50)
      board[i][j] = WHITE;
    else
      board[i][j] = BLACK;
  }
  rep(i, A-1) {
    board[99-(i / 50)*2][2*(i % 50)] = WHITE;
  }
  rep(i, B-1) {
    board[(i / 50)*2][2*(i % 50)] = BLACK;
  }
  cout << "100 100\n";
  rep(i, 100) {
    rep(j, 100) {
      cout << (board[i][j] == WHITE ? '.' : '#');
    }
    cout << "\n";
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

        int c = 0;
        while (n) {
                n /= k;
                c++;
        }

        cout << c << endl;

        return 0;
}


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

G = [[0] * N for i in range(N)]
for i in range(M):
    a, b = list(map(int, input().split()))
    a = a - 1
    b = b - 1
    G[a][b] = 1
    G[b][a] = 1

def isConnected(a, b):
    used = [0] * N
    def dfs(pos, pre):
        if used[pos]:
            return
        
        used[pos] = 1
        for to in range(N):
            if (pos == a and to == b) or (pos == b and to == a) or (G[pos][to] == 0):
                continue
            dfs(to, pos)
    dfs(0, -1)
    return used.count(1) != N

ans = 0
for a in range(N):
    for b in range(a+1, N):
        if G[a][b] == 0:
            continue
        ans = ans + isConnected(a, b)
    
print (ans)


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[] a = new Integer[N];
		for(int i = 0;i<N;i++) {
			a[i]=sc.nextInt();
		}
		Arrays.sort(a,Comparator.reverseOrder());
		int count = 1;
		for(int c = 0;c<a.length-1;c++) {
			if(a[c]>a[c+1]) {
			count++;	
			}
		}
		System.out.print(count);
	}
}

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

/*
L-1~0までを作る
数字を全部から0を出すとしよう
50こ残る
50こでL-1~1まで作る
選択肢をL個以上
0~L/2  L/2~L
とするとlog2Lこの区間に分割できそう
log10^3L=
19から20がL/2
18~19がL/4
5  1,2,
*/

#define max 2147483647



void merge(int *a,int left,int mid,int right){
        int n1 = mid - left;
        int n2 = right - mid;
        int L[n1+1],R[n2+1];
        int i;
        for(i=0;i<n1;i++){
            L[i] = a[left + i];
        }
        for(i=0;i<n2;i++){
            R[i] = a[mid + i];
        }
        L[n1]=max;
        R[n2]=max;
        int j=0,k=0;
        for(i=left;i<right;i++){
            if(L[j]<R[k]){
                a[i] = L[j];
                j++;
            }
            else{
                a[i] = R[k];
                k++;
            }
        }

}


void merge_sort(int *a,int left,int right){
    int middle;
    if(left + 1 < right){
        middle = (left + right)/2;
        merge_sort(a,left,middle);
        merge_sort(a,middle,right);
        merge(a,left,middle,right);
    }
}


int main(void){
    int n;
    scanf("%d",&n);
    int a[n];
    int i;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    merge_sort(a,0,n);
    int ans =0,val = 1;
    for(i=n-1;i>=0;i--){
        ans += val*a[i];
        val = val * (-1);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

int main(){
  char s[SIZE];
  int n;
  
  scanf("%s", s);
  n = strlen(s);
  
  ll ans = 0;  

  ll dp[SIZE][3] = {};

  dp[0][0] = 1;
  
  for(int i=0;i<n;i++){
    if(s[i] == '?') ans = (ans * 3)%mod;
    
    if(s[i] == 'A' || s[i] == '?'){
      dp[i+1][0] += dp[i][0];
      dp[i+1][1] += dp[i][1] + dp[i][0];
      dp[i+1][2] += dp[i][2];
    }
    if(s[i] == 'B' || s[i] == '?'){
      dp[i+1][0] += dp[i][0];
      dp[i+1][1] += dp[i][1];
      dp[i+1][2] += dp[i][2] + dp[i][1];
    }
    if(s[i] == 'C' || s[i] == '?'){
      dp[i+1][0] += dp[i][0];
      dp[i+1][1] += dp[i][1];
      dp[i+1][2] += dp[i][2];
      ans = (ans + dp[i][2])%mod;
    }

    for(int j=0;j<3;j++)
      dp[i+1][j] = dp[i+1][j]%mod;
  }
  
  printf("%lld\n", ans);
  
  return 0;
}



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

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
    }
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    for (int i = 0; i < N; i++)
    {
        if(S[i]=="AC")ac++;
        else if(S[i]=="WA")wa++;
        else if(S[i]=="TLE")tle++;
        else re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;   
}

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

int main() {
    int w, h; cin >> w >> h;
    vector<int> a(w), b(h);
    for(auto& x : a) cin >> x;
    for(auto& x : b) cin >> x;

    for(auto x : a) {
        sort(begin(b), end(b), greater<>{});
        if(x == 0) continue;
        if(x > (int)b.size() || *min_element(begin(b), begin(b) + x) == 0) {
            cout << 0 << endl;
            return 0;
        }
        for(int j = 0; j < x; ++j) {
            b[j] -= 1;
        }
    }

    cout << (*max_element(begin(b), end(b)) == 0) << endl;
}



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

signed main() {
  int A;
  cin >> A;
  
  //j%2が0のとき午前、j%2が1のとき午後
  vector<vector<int>> F(A, vector<int>(10));
  for( int i = 0; i < A; i++ ){
    for( int j = 0; j < 10; j++ ){
      cin >> F.at(i).at(j);
    }
  }
  
  //何個営業時間がかぶってたらどのくらい利益が得られるかの入力
  vector<vector<int>> P(A, vector<int>(11));
  for( int i = 0; i < A; i++ ){
    for( int j = 0; j <= 10; j++ ){
      cin >> P.at(i).at(j);
    }
  }
  
  vector<vector<int>> kumi(1200, vector<int>(10));
  for (int bit = 0; bit < (1<<10); ++bit) {
    for (int i = 0; i < 10; ++i) {
      if (bit & (1<<i)) {
        kumi.at(bit).at(i) = 1;
      }
    }
  }
  
  int ans = -100000000000;
  for( int i = 0; i < 1200; i++ ){
    bool fg = false;
    int rieki = 0;
    for( int j = 0; j < 10; j++ ){
      if( kumi.at(i).at(j) == 1 ) fg = true;
    }
    if( fg == false ) continue;
    for( int k = 0; k < A; k++ ){ //k個目の店について
      int cnt = 0;
      for( int j = 0; j < 10; j++ ){
        if( F.at(k).at(j) == 1 && kumi.at(i).at(j) == 1 ) cnt++;
      }
      rieki += P.at(k).at(cnt);
    }
    ans = max(ans, rieki);
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		boolean ans[] = new boolean[N];
		Arrays.fill(ans, true);
		int H[] = new int[N];
		for(int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
		}
		int A[][] = new int[M][2];
		for(int i = 0; i < M; i++) {
			A[i][0] = sc.nextInt() - 1;
			A[i][1] = sc.nextInt() - 1;
			if(H[A[i][0]] < H[A[i][1]]) {
				ans[A[i][0]] = false;
			} else if(H[A[i][1]] < H[A[i][0]]){
				ans[A[i][1]] = false;
			} else {
				ans[A[i][0]] = false;
				ans[A[i][1]] = false;
			}
		}
		
		int cnt = 0;
		for(int i = 0; i < N; i++) {
			if(ans[i]) cnt++;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 65072
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int m1=fsc.nextInt(), d1=fsc.nextInt(), m2=fsc.nextInt(), d2=fsc.nextInt();
        fsc.close();
        System.out.println(m1<m2?1:0);
        
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte(){
        if(ptr<buflen) return true;
        else{
            ptr = 0;
            try{
                buflen = in.read(buffer);
            }
            catch(IOException e){
                e.printStackTrace();
            }
            if(buflen<=0) return false;
        }
    return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) throw new NumberFormatException();
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }
            else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
            else throw new NumberFormatException();
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
    public void close(){
        try{in.close();}
        catch(IOException e){e.printStackTrace();}
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <list>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(long long (i)=0;(i)<(long long)(n);(i)++)
#define RREP(i,n) for(long long (i)=(long long)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

int main(){
    
    int can[101][101];
    REP(i,101)REP(j,101)can[i][j]=0;
    int W,H,N; cin>>W>>H>>N;
    
    REP(i,N){
        int x,y,a;
        cin>>x>>y>>a;
        if(a==1){
            for(int j=0;j<H;j++){
                for(int k=0;k<x;k++)can[j][k]=1;
            }
        }
        if(a==2){
            for(int j=0;j<H;j++){
                for(int k=x;k<=W;k++)can[j][k]=1;
            }
        }
        if(a==3){
            for(int k=0;k<W;k++){
                for(int j=0;j<y;j++)can[j][k]=1;
            }
        }
        if(a==4){
            for(int k=0;k<W;k++){
                for(int j=y;j<=H;j++)can[j][k]=1;
            }
        }
    }
    
    int ans=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(can[i][j]==0)ans++;
        }
    }
    
  /*  REP(i,5){
        REP(j,5)cout<<can[i][j]<<" ";
        cout<<endl;
    }*/
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = INF;
  string y = "";
  rep(i,n) y = y + s[0];
  if (y == s) {
    cout << 0 << endl;
    return;
  }
  rep(i,n) {
    char c = s[i];
    int cnt = 0;
    string t = s;
    for(;;) {
      cnt++;
      string temp = "";
      string x = "";
      rep(j,t.size()-1) {
        if (t[j] == c || t[j+1] == c) temp = temp + c;
        else temp = temp + t[j];
        x = x + c;
      }
      if (x == temp) break;
      t = temp;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
using namespace std;
 
 class dice{
   public:
   void changenum(int num[6]);
   int dicenum[6];
 };

 void dice::changenum(int num[6]){
   for(int i = 0; i < 6; i++){
     dicenum[i] = num[i];
   }
 }

 void move1(char dir, int num[6]);
 int move2(int, int, int*);

int main(){
  int answer[100];
  answer[12] = answer[31] = answer[24] = answer[43] = 0;
  answer[3] = answer[20] = answer[35] = answer[52] = 1;
  answer[1] = answer[15] = answer[40] = answer[54] = 2;
  answer[4] = answer[10] = answer[51] = answer[45] = 3;
  answer[2] = answer[25] = answer[30] = answer[53] = 4;
  answer[13] = answer[21] = answer[34] = answer[42] = 5;
  dice dice1;
  int num[6];
  for(int i = 0; i < 6; i++){
    cin >> num[i];
  }
  dice1.changenum(num);
  int s;
  cin >> s;
  for(int i = 0; i < s; i++){
      int up,front;
      cin >> up >> front;
      cout << dice1.dicenum[answer[move2(up,front,dice1.dicenum)]] << endl;
  }
  

}
void move1(char dir,int num[6]){
  int localnum[6] = {num[0],num[1],num[2],num[3],num[4],num[5]};
  switch(dir){
    case 'N':
     num [0] = localnum[1];
     num [1] = localnum[5];
     num [2] = localnum[2];
     num [3] = localnum[3];
     num [4] = localnum[0];
     num [5] = localnum[4];
    break;
    case 'S':
     num [0] = localnum[4];
     num [1] = localnum[0];
     num [2] = localnum[2];
     num [3] = localnum[3];
     num [4] = localnum[5];
     num [5] = localnum[1];
    break;
    case 'E':
     num [0] = localnum[3];
     num [1] = localnum[1];
     num [2] = localnum[0];
     num [3] = localnum[5];
     num [4] = localnum[4];
     num [5] = localnum[2];
    break;
    case 'W':
     num [0] = localnum[2];
     num [1] = localnum[1];
     num [2] = localnum[5];
     num [3] = localnum[0];
     num [4] = localnum[4];
     num [5] = localnum[3];
    break;
  }
  //for(int i = 0; i < 6; i++){
    //cout << num[i] << endl;
  //}
  //cout << endl;
}

int move2(int up, int front,int num[6]){
    int i = 0,j = 0,ans = 0;
    for(i; i < 6; i++){
        if(num[i] == up) break;
    }
    for(j; j < 6; j++){
         if(num[j] == front) break;
    }
    ans = i*10 + j;
    return ans;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
vector<long> fact_inv, inv, Com;
void init_nCk(int n,int k){
  fact_inv.resize(k+5);
  inv.resize(k+5);
  fact_inv[0]=fact_inv[1]=1;
  inv[1]=1;
  for(int i=2;i<k+5;i++){
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    fact_inv[i]=fact_inv[i-1]*inv[i]%MOD;
  }
  Com.resize(k+5);
  Com[0]=1;
  for(int i=1;i<k+5;i++){
    Com[i]=Com[i-1]*((n-i+1)*inv[i]%MOD)%MOD;
  }
}
int a,K,i;
long ans=0,x=1;
int nCk(int k){
  if(a>=2*k){return Com[k];}
  else{return Com[a-k];}
}
int main(){
  string S;
  cin>>K>>S;
  a=K+S.size();
  init_nCk(a,min(a/2,K));
  for(i=0;i<=K;i++){
    ans+=x*nCk(i);
    ans%=MOD;
    if(i==K){cout<<ans<<endl;return 0;}
    x*=25;
    x%=MOD;
  }
}

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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}
    
int main()
{    
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        li n;

        cin>>n;

        cout<<n*n;
    return 0;
}

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

int gcd(int i, int j){
    if(i%j>0) return gcd(j, i%j);
    else return j;
}
int main() {
	int N, a[100010]; cin >> N;
	for(int i=0; i<N; ++i) cin >> a[i];
	sort(a, a+N);
	int ans=gcd(a[0], a[1]);
	for(int i=2; i<N && ans>1; ++i) ans=gcd(ans, a[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
#define biggest(A,B) A=max(A,B)
#define smallest(A,B) A=min(A,B)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
char c[10][10]; 
int main(){
	fastio;
	int res=0;
	int h,w,k;
	cin>>h>>w>>k;
	int s=0;
	rb(i,1,h)
		rb(j,1,w) cin>>c[i][j],s+=c[i][j]=='#';
	int n=h+w;
	rep(i,1<<n){
		int cnt=0;
		rep(j,h)
			if(i&(1<<j)){
				rb(k,1,w)
					if(c[j+1][k]=='#') cnt++;
			}
		rep(k,w){
			if(i&(1<<(h+k))){
				rb(j,1,h){
					if(!(i&(1<<(j-1)))){
						
					if(c[j][k+1]=='#') cnt++;
					}
				}
			}
		}
		res+=(s-cnt)==k;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
#include <fstream>
#include <stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

vector<ll> dx = { 0, 1, 0, -1, 1, -1, 1, -1, 0};
vector<ll> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0};

void chmin(ll& x, ll y) {
	x = min(x, y);
}

void chmax(ll& x, ll y) {
	x = max(x, y);
}

ll pow_long(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y % 2 == 1) res *= x;
		x *= x;
		y /= 2;
	}
	return res;
}

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 1000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

ll N;
ll num[200010];
ll A[200010];
ll ans;

void solve() {
	cin >> N;
	for (ll i = 1; i <= N; i++) {
		cin >> A[i];
		num[A[i]]++;
	}
	for (ll i = 1; i <= N; i++) {
		ans += num[i] * (num[i] - 1) / 2;
	}
	//cout << ans << endl;
	for (ll i = 1; i <= N; i++) {
		cout << ans - (num[A[i]] - 1) << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll T = 1;
	//cin >> T;
	rep(i, T) solve();
}


Measured memory_bytes: 6400
import itertools 

n, m = map(int, input().split())
G = [[] for _ in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  G[a].append(b)
  G[b].append(a)
  
P = itertools.permutations(range(1, n), n-1)

ans = 0
for p in P:

  for i in range(n-1):

    if i==0:
      pnow = 0
      pnext = p[0]
    else:
      
      pnow = p[i-1]
      pnext = p[i]
    if pnext not in G[pnow]:
      break
  else:
    ans += 1
    continue
  
  
print(ans)

Measured memory_bytes: 9180
#include <iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include <stdio.h>
using namespace std;
//const long long N = 100005;
//int cm[N];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	long long a[5],min=100,mi=-1;
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
		int mod = a[i] % 10;
		if (mod < min && mod != 0) {
			min = mod;
			mi = a[i];
		}
	}
	bool q = false;
	int sum = 0;
	for (int i = 0; i < 5; i++) {
		if (a[i] == mi&&!q) {
			sum += a[i];
			q = true;
		}
		else if (a[i] % 10 != 0)
			sum += ((a[i] / 10 + 1) * 10);
		else sum += a[i];

	}
	cout << sum;
	
	
}

Measured memory_bytes: 256
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package dp;

/**
 *
 * @author aakas
 */
import java.util.*;
public class Main {
    static int n;
    static int[] a;
    static int[] b;
    static int[] c;
    static boolean[][] v;
    static int[][] dp;
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = new int[n];
        b = new int[n];
        c = new int[n];
        v = new boolean[n][3];
        dp = new int[n][3];
        for(int i=0;i<n;i++)
        {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        System.out.println(Math.max(Math.max(s(0,0),s(0,1)),s(0,2)));
    }
    public static int s(int i,int type)
    {
        if(i==n)
            return 0;
        if(v[i][type])
            return dp[i][type];
        v[i][type] = true;
        if(type==0)
            return dp[i][type] = Math.max(s(i+1,1)+a[i],s(i+1,2)+a[i]);
        if(type==1)
            return dp[i][type] = Math.max(s(i+1,0)+b[i],s(i+1,2)+b[i]);
        else
            return dp[i][type] = Math.max(s(i+1,0)+c[i],s(i+1,1)+c[i]);
    }
}


Measured memory_bytes: 117540
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

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

  for(int i=1; i<=3; i++){
    if( i != a && i != b )
      cout << i;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	ll dx=x2-x1;
	ll dy=y2-y1;
	ll x3=x2-dy;
	ll y3=y2+dx;
	cout << x3 << " "<<y3;
	ll x4=x3-dx;
	ll y4=y3-dy;
	cout << " "<<x4<<" "<<y4;
	return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k & 1)cout << b - a << endl;
	else cout << a - b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
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 const INF = 1001001001;
ll const MOD = 1000000007;


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

string s;
cin >> s;
if(s[0]=='9' || s[1]=='9') puts("Yes");
else puts("No");

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define N 200005

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2 + m*(m-1)/2;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

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

int main(){
    int H,W;
    cin>>H>>W;
    string S[1100];
    for(int i=0;i<H;i++){
        cin>>S[i];
    }
    dp[0][0]=1;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            for(int k=0;k<4;k++){
                int ni=dx[k]+i,nj=dy[k]+j;
                if(ni>=0 && ni<H && nj>=0 && nj<W && S[ni][nj]=='.'){
                    dp[ni][nj]+=dp[i][j];
                    dp[ni][nj]%=MOD;
                }
            }
        }
    }
    cout<<dp[H-1][W-1]<<endl;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;


void print_line(vector<string> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef int Weight;

struct Edge {
    int src, dst;
    Weight weight;

    Edge(int src, int dst, Weight weight) :
            src(src), dst(dst), weight(weight) {}
};

bool operator<(const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
           e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool visit(const Graph &g, int v, vector<int> &order, vector<int> &color) {
    color[v] = 1;
    for (auto e: g[v]) {
        if (color[e.dst] == 2) continue;
        if (color[e.dst] == 1) return false;
        if (!visit(g, e.dst, order, color)) return false;
    }
    order.push_back(v);
    color[v] = 2;
    return true;
}

bool topologicalSort(const Graph &g, vector<int> &order) {
    int n = g.size();
    vector<int> color(n);
    rep(u, n) if (!color[u] && !visit(g, u, order, color))
            return false;
    reverse(order.begin(), order.end());
    return true;
}


int main() {
    int v, e;
    cin >> v >> e;

    Graph g(v);

    rep(i, e) {
        int s, t;
        cin >> s >> t;
        Edge edge(s, t, 1);

        g[s].push_back(edge);
    }
    vector<int> order(v);
    bool b = !topologicalSort(g, order);
    cout << b << endl;

}



Measured memory_bytes: 3172
#include <iostream>
using namespace std;
 
int main(void)
{
    int h,a,b,total = 0;
 
    cin >> h >> a >> b;
 
    for (int i = 0; i <= b - a; i++) {
        if (h % (a + i) == 0)
            total++;
    }
 
    cout << total << endl;
}


Measured memory_bytes: 3124
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    string s;
    ll k;
    cin >> s;
    cin >> k;
    ll lastI = 0;
    REP(i, s.length()){
        if(s[i] == '1'){lastI++;}
        else{break;}
    }
    if(lastI >= k){
        print(1);
    }else{
        print(s[lastI]);
    }
}


Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
int min(int x, int y) { return x < y ? x : y; }
int main() {
	int n, x, y, dis, k[2000] = {0};
	scanf("%d%d%d", &n, &x, &y);
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			dis = min(j - i, min(abs(x - i) + 1 + abs(y - j),
								 abs(y - i) + 1 + abs(x - j)));
			k[dis - 1]++;
		}
	}
	for (int i = 0; i < n - 1; i++) {
		printf("%d\n", k[i]);
	}
	return 0;
}


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

int main(void){
    int n;
    cin >> n;
    string ans = "Three";
    char c;
    for(int i=0; i<n; i++){
        cin >> c;
        if(c == 'Y'){
            ans = "Four";
        }
    }

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

Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <vector>
#include <string>
#include <iostream>

int Hash(const std::string& Text)
{
    int Hash = 0;
    for(std::size_t i = 0; i < Text.size(); ++i){
        if(i){
            Hash *= 5;
        }
        switch(Text[i]){
        case 'A':
            Hash += 1; break;
        case 'C':
            Hash += 2; break;
        case 'G':
            Hash += 3; break;
        case 'T':
            Hash += 4; break;
        default:
            assert(false);
        }
    }
    return Hash;
}
int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::vector<bool> dic(std::pow(5,12), false);
    int n;
    std::cin >> n;
    for(int i = 0; i < n; ++i){
        std::string command, str;
        std::cin >> command >> str;
        if(command[0] == 'i'){
            dic[Hash(str)] = true;
        }else
        if(command[0] == 'f'){
            std::cout << (dic[Hash(str)] ? "yes" : "no") << std::endl;
        }
    }
    return 0;
 }

Measured memory_bytes: 31008
N=int(input())
A=list(map(int,input().split()))
A.sort()
ans=1
mod=10**9+7
if N%2==0:
    for k in range(N//2):
        if A[2*k]==2*k+1 and A[2*k+1]==2*k+1:
            ans=ans*2%mod
            continue
        else:
            ans=0
            break
if N%2==1:
    if A[0]==0:
        ans=2
        for k in range(N//2-1):
            if A[2*k+2]==2*k+2 and A[2*k+1]==2*k+2:
                ans=ans*2%mod
                continue
            else:
                ans=0
                break
    else:
        ans=0
if N==1:
    if A[0]==0:
        ans=1
    else:
        ans=0
print(ans)

Measured memory_bytes: 14008
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main() {
	string S;
	cin >> S;
	if (S[0] == '9' || S[1] == '9') cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
use std::io::stdin;
fn get_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

macro_rules! input {
    ($single:ty) => ( get_string().parse::<$single>().unwrap() );
    ($plural:ty,) => ({
        let line = get_string();
        line.split_whitespace().map(|v| v.parse::<$plural>().unwrap()).collect::<Vec<$plural>>()
    });
    ($($plural:ty),+) => ({
        let line = get_string();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$plural>().unwrap()),+)
    });
    ($single:ty; $times:expr) => ( (0..$times).map(|_| input!($single)).collect::<Vec<$single>>() );
    ($($plural:ty),+; $times:expr) => ( (0..$times).map(|_| input!($($plural),+)).collect::<Vec<($($plural),+)>>() );
}

#[allow(dead_code)]
fn get_value<T: std::str::FromStr>() -> T {
    get_string().parse().ok().unwrap()
}
#[allow(dead_code)]
fn get_values_for<T: std::str::FromStr>(times: u64) -> Vec<T> {
    (0..times).map(|_| get_value()).collect()
}
#[allow(dead_code)]
fn get_vector<T: std::str::FromStr>() -> Vec<T> {
    get_string()
        .split_whitespace()
        .map(|v| v.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn get_vectors_for<T: std::str::FromStr>(times: u64) -> Vec<Vec<T>> {
    (0..times).map(|_| get_vector()).collect()
}

fn main() {
    let (n, m) = input!(u32, usize);
    let cakes = input!(i64, i64, i64; n);
    let mut scores = Vec::new();
    scores.push(maximize(&cakes, m, (1, 1, 1)));
    scores.push(maximize(&cakes, m, (1, 1, -1)));
    scores.push(maximize(&cakes, m, (1, -1, 1)));
    scores.push(maximize(&cakes, m, (1, -1, -1)));
    scores.push(maximize(&cakes, m, (-1, 1, 1)));
    scores.push(maximize(&cakes, m, (-1, 1, -1)));
    scores.push(maximize(&cakes, m, (-1, -1, 1)));
    scores.push(maximize(&cakes, m, (-1, -1, -1)));

    println!("{:?}", scores.iter().max().unwrap());
}

fn maximize(cakes: &Vec<(i64, i64, i64)>, m: usize, flags: (i64, i64, i64)) -> i64 {
    let mut scores: Vec<_> = cakes
        .iter()
        .map(|v| (v.0 * flags.0 + v.1 * flags.1 + v.2 * flags.2, v))
        .collect();
    scores.sort();
    let score = scores[0..m]
        .iter()
        .map(|v| v.1)
        .fold((0, 0, 0), |i, v| (i.0 + v.0, i.1 + v.1, i.2 + v.2));
    score.0.abs() + score.1.abs() + score.2.abs()
}


Measured memory_bytes: 4352