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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long M, long long D) {
  int ans = 0;
  for(int i = 1 ; i <= M ; i++){
    for(int j = 1 ; j <= D ; j++){
      int d1 = j % 10;
      int d2 = j / 10 % 10;
      if( d1 >= 2 && d2 >= 2 && d1 * d2 == i ){
        ans++;
      }

    }
  }
  cout << ans << endl;
}

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


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n,ans=0;
    cin>>n;
    Vi a(n),b(n),c(n-1);
    REP(i,0,n) cin>>a[i];
    REP(i,0,n){cin>>b[i]; ans+=b[i];}
    REP(i,0,n-1) cin>>c[i];
    REP(i,0,n-1){
        if(a[i]+1==a[i+1]) ans+=c[a[i]-1];
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n, m, d;

	cin >> n >> m >> d;

	if (d == 0) {
		cout << fixed;
		cout << setprecision(12) << 1.0 / n * (m - 1) << endl;
	}
	else {
		cout << fixed;
		cout << setprecision(12) << 2.0 * (n - d) / n / n * (m - 1) << endl;
	}
}

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

int main(){
int W,H,x,y,r;
cin >>W >>H >>x >>y >>r;
if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
cout <<"Yes" <<endl;
}
else cout <<"No" <<endl;
return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
 
int main() {

    int n;
    cin>>n;
    vector<string> s(n);
    rep(i,n)    cin>>s.at(i);

    rep(i,n)    sort(all(s[i]));
    sort(all(s));

    ll ans=0;
    ll res=0;
    rep(i,n-1) {
        if(s[i]==s[i+1]) {
            res++;
            ans+=res;
        }
        else    res=0;
    }

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

Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ll res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<ll,ll> x,pair<ll,ll> y)
{
    if(x.first<y.second)
        return true;
    else if(x.first==y.second)
        return x.second<y.second;
    else
        return false;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }

void solve()
{   
    ll n,W;
    cin>>n>>W;
    vector<ll> w(n);
    vector<ll> v(n);
    for(ll i=0;i<n;i++)
        cin>>w[i],cin>>v[i];
    ll dp[100001];
    for(int i=0;i<=100000;i++)
        dp[i]=INT_MAX;
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=100000;j>=v[i];j--){
            if(dp[j-v[i]]!=INT_MAX)
                dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
        }
    }
    for(int i=100000;i>=0;i--)
        if(dp[i]<=W ){
            cout<<i;
            return;
        }

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


Measured memory_bytes: 1024
// STLを用いた解き方 p.135

#include <cstdio>
#include <algorithm>
using namespace std;

int A[1000000], n;

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

    int q, k, sum = 0;
    scanf("%d", &q);
    for (int i=0; i<q; i++) {
        scanf("%d", &k);
        // 標準ライブラリのlower_boundを使用
        if (*lower_bound(A, A+n, k) == k) sum++;
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define vi vector<int>
#define INF (int)1e9
using namespace std;

int main() {
	int n;
	cin>>n;
	
	vi v(26,INF);
	REP(i,n){
		string s;
		cin>>s;
		
		vi cnt(26,0);
		REP(i,s.size()){
			cnt[s[i]-'a']++;
		}
		
		REP(i,26){
			v[i]=min(v[i],cnt[i]);
		}
	}
	
	string ans="";
	REP(i,26){
		REP(j,v[i]){
			ans+=('a'+i);
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    rep(i,H) cin >> s[i];

    vector<vector<int>> dp(H, vector<int>(W, INF));
    dp[0][0] = (s[0][0] == '.' ? 0 : 1);
    
    for (int i = 1; i < W; i++) dp[0][i] = dp[0][i - 1] + (s[0][i - 1] == '.' && s[0][i] == '#' ? 1 : 0);
    for (int i = 1; i < H; i++) dp[i][0] = dp[i - 1][0] + (s[i - 1][0] == '.' && s[i][0] == '#' ? 1 : 0);
    for (int i = 1; i < H; i++) for (int j = 1; j < W; j++) {
        dp[i][j] = dp[i][j - 1] + (s[i][j - 1] == '.' && s[i][j] == '#' ? 1 : 0);
        dp[i][j] = min(dp[i][j], dp[i - 1][j] + (s[i - 1][j] == '.' && s[i][j] == '#' ? 1 : 0));
    }

    cout << dp[H - 1][W - 1] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;
  if(x==1||x==3||x==5||x==7||x==8||x==10||x==12){
    if(y==1||y==3||y==5||y==7||y==8||y==10||y==12){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  if(x==4||x==6||x==9||x==11){
    if(y==4||y==6||y==9||y==11){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  if(x==2){
    if(y==2){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }   
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include<string>
#include<utility>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;


bool cmpf(pair<lli, lli> left, pair<lli, lli> right) {
	return left.first < right.first;
}


int main() {
	lli n;
	cin >> n;
	vector<double> vec(n);
	double ans=0;
	rep0(i, n)cin >> vec[i],ans += 1.0 / vec[i];
	cout << 1.0/ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    set<char> e(begin(s), end(s));
    for (char i = 'a'; i <= 'z'; i++) {
        if (e.find(i) == end(e)) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 512
var n,m,x,y,ai,bi,i:integer;
a:array[1..100]of integer;
begin 
	read(n,m,x,y);
	ai:=-maxint;
	bi:=maxint;
	for i:=1 to n do begin read(a[i]);if a[i]>ai then ai:=a[i];end;
	for i:=1 to m do begin read(a[i]);if a[i]<bi then bi:=a[i];end;
	if ai>=bi then begin write('War');exit;end;
	for i:=ai+1 to bi do
	if (i>x) and (i<=y) then begin write('No War');exit;end;
	write('War');
end.

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[100005];
const int MOD = int(1e9) + 7;

void check(bool b) {
    if (!b) {
        cout << 0 << endl;
        exit(0);
    }
}

int main() {
    scanf("%d", &n);
    forn(i, n) {
        int x;
        scanf("%d", &x);
        ++a[x];
    }
    if (n % 2 == 1) {
        check(a[0] == 1);
        int ans = 1;
        for (int i = 2; i < n; i += 2) {
            check(a[i] == 2);
            ans = 2 * ans % MOD;
        }
        cout << ans << endl;
        return 0;
    }
    int ans = 1;
    for (int i = 1; i < n; i += 2) {
        check(a[i] == 2);
        ans = 2 * ans % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 764
// AOJ 1069: Squid Multiplication
// 2017.8.18 bal4u@uu
// 2017.11.19

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAX 32000
long long odd[MAX+1], even[MAX+1];
int ol, el;

long long gcd(long long a, long long b)
{
	long long r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

int cmp(long long *a, long long *b)
{
	if (*a < *b) return -1;
	if (*a == *b) return 0;
	return 1;
}

char buf[640000], *p;
long long getint()
{
	long long n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, k, i;
	long long g, e1, e2, o1;

	while (fgets(p=buf, 10, stdin) && *p != '0') {
		n = (int)getint();
		k = (n*(n + 1)) >> 1;
		fgets(p=buf, 640000, stdin);
		ol = el = 0; while (k--) {
			g = getint(), p++;
			if (g & 1) odd[ol++] = g;
			else      even[el++] = g;
		}
		qsort(odd,  ol, sizeof(unsigned long long), cmp);
		qsort(even, el, sizeof(unsigned long long), cmp);
		e1 = even[0], e2 = even[1], o1 = odd[0];
		g = gcd(e1, o1), e1 /= g, o1 /= g;
		g = gcd(e2, o1), e2 /= g; // o1 /= g;
		g = (int)sqrt((double)e1 * e2);
		printf("%d\n%d", (int)g, (int)(even[0]/g));
		for (i = 1; i < n; i++) printf(" %d", (int)(even[i]/g));
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 2796
N = int(input())
A = [int(x) for x in input().split()]

for i in range(N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1 
        A[j+1] = v
    for _ in range(N):
        if _ == N-1:
            print(A[_],sep='',end='')
        else:
            print(A[_], sep='',end=' ')
    print()


Measured memory_bytes: 5980
#include <stdio.h>                                                                                                                                                                                                                                                                                                                                                                                                                 [14/115]
#include <stdlib.h>

#define LINE_SIZE 512

static int *
split(char *line, int size) {
  char c;
  char elm[5];
  int *arr;
  int *tmp_arr;
  char *tmp_elm;

  arr = (int *) malloc(sizeof(int) * size);
  if (arr == NULL) return NULL;

  tmp_arr = arr;
  tmp_elm = elm;
  while (1) {
    c = *line++;
    if (c == '\0') break;
    if (c == ' ' || c == '\n') {
      *tmp_elm = '\0';
      *tmp_arr++ = atoi(elm);
      tmp_elm = elm;
      continue;
    }
    *tmp_elm++ = c;
  }

  return arr;
}

static void
print_arr(int *arr, int size) {
  int i;

  for (i = 0; i < size; ++i) {
    if (i > 0) fprintf(stdout, " ");
    fprintf(stdout, "%d", arr[i]);
  }
  fprintf(stdout, "\n");
}

// Insertion sort
static void
sort(int *a, int n) {
  int i, j, v;

  print_arr(a, n);
  for (i = 1; i < n; ++i) {
    v = a[i];
    j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      --j;
    }
    a[j + 1] = v;
    print_arr(a, n);
  }
}

int
main(int argc, char **argv) {
  char *buf;
  int n;
  int *arr;

  buf = (char *) malloc(LINE_SIZE);
  if (buf == NULL) exit(1);

  buf = fgets(buf, LINE_SIZE, stdin);
  if (buf == NULL) exit(1);
  n = atoi(buf);

  buf = fgets(buf, LINE_SIZE, stdin);
  if (buf == NULL) exit(1);
  arr = split(buf, n);
  if (arr == NULL) exit(1);

  sort(arr, n);

  free(buf);
  buf = NULL;
  free(arr);
  arr = NULL;
  exit(0);
}


Measured memory_bytes: 2052
#include<stdio.h>
#include<math.h>
int main()
{
	int a,b,c,d,e,min,f,n=0;
	while(scanf("%d%d%d",&a,&b,&c)!=EOF)
	{
		d=abs(a-b);
		e=abs(a-c);
		f=abs(b-c);
		if(d>=e&&d>=f)
		{
			min=e+f;
		}
		if(e>=d&&e>=f)
		{
			min=d+f;
		}
		if(f>=e&&f>=d)
		{
			min=e+d;
		}
		printf("%d\n",min);
	}
	return 0;
}



Measured memory_bytes: 128
var
    n,y,sum_max,x_max,y_max,offset,i,tmp,a,b,c: Longint;
begin
    read(n,y);
    y:=y div 1000;
    sum_max:=10*n;
    if (sum_max<y) or (n>y) then
    begin
        writeln('-1 -1 -1');
        readln;
        exit;
    end;
    offset:=y-n;
    x_max:=offset div 9;
    y_max:=offset div 4;
    tmp:=offset+9;
    for i := 0 to x_max do
    begin
        dec(tmp,9);
        if (tmp mod 4=0)  then
        begin
            a:=i;
            b:=tmp div 4;
            c:=n-a-b;
            if (c<0) then
            begin
                continue;
            end;
            writeln(a,' ',b,' ',c);
            readln;
            exit;
        end;
    end;
    writeln('-1 -1 -1');
    readln;
end.

Measured memory_bytes: 128
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  int D;
  cin >> D;
  vi c(26);
  cin >> c;
  vvi s(D, vi(26));
  cin >> s;
  vi t(D);
  cin >> t;

  vi last(26, 0);

  ll score = 0;
  rep(i, D) {
    score += s[i][t[i] - 1];
    last[t[i] - 1] = i + 1;
    rep(j, 26) {
      score -= c[j] * (i + 1 - last[j]);
    }
    out(score);
  }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector <int> d(N);
  for(int i=0;i<N;i++){
  cin>>d.at(i);
  }
  int sum=0;
  for(int i=0;i<N;i++)
    sum+=d.at(i);
  int sum1=0;
  for(int i=0;i<N;i++)
    sum1+=d.at(i)*d.at(i);
  cout<<(sum*sum-sum1)/2<<endl;
  return 0;
}

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

const int M = 1000000007;
long long a[2001][2001];
int n, k;

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

	a[0][0] = 1;

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

		for (int j = 1; j <= i; j++)
			a[i][j] = (a[i - 1][j - 1] + a[i - 1][j]) % M;
	}

	for (int i = 1; i <= k; i++) {
		long long t = (a[k - 1][i - 1] * a[n - k + 1][i]) % M;

		cout << t << endl;
	}

	return 0;
}

Measured memory_bytes: 30080
package main

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

func abs(it int) int {
	if it < 0 {
		it *= -1
	}
	return it
}

func max(a, b int) int {
	if a < b {
		a = b
	}
	return a
}

// ref.
// https://qiita.com/tnoda_/items/b503a72eac82862d30c6
var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	dpNoFlip := make([]int, n+1)
	dpDoFlip := make([]int, n+1)
	dpNoFlip[0] = 0
	dpDoFlip[0] = -1 * (2 << 61)

	for i := range dpNoFlip {
		if i == n {
			break
		}
		aI := nextInt()
		dpNoFlip[i+1] = max(dpNoFlip[i]+aI, dpDoFlip[i]-aI)
		dpDoFlip[i+1] = max(dpNoFlip[i]-aI, dpDoFlip[i]+aI)
	}

	fmt.Println(dpNoFlip[n])
}


Measured memory_bytes: 3840
N, M = map(int, input().split())
height = list(map(int, input().split()))
judge = N*[1]
for i in range(M):
	A, B = map(int, input().split())
	if(height[A-1]>=height[B-1]):
		judge[B-1] = 0
	if(height[A-1]<=height[B-1]):
		judge[A-1] = 0

ans = 0
for i in range(N):
	if judge[i]==1:
		ans += 1
print(ans)

Measured memory_bytes: 20104
//#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<set>
#include<vector>
#include<cmath>
#include<list>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#include<iomanip> 
#include<cstdlib> 
#include<string>

#define ll long long

using namespace std;

int main() {
	double b;
	ll a;

	cin >> a >> b;
		
	ll d = round(b * 100);

	ll c = a * d / 100;
	cout << c << endl;

	return 0;
}

Measured memory_bytes: 3744
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

public class Main {
  private static PrintWriter pw;

  public static void main(String[] args) {
    pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    HashMap<Integer, ArrayList<Integer>> map = new HashMap<Integer, ArrayList<Integer>>();

    ArrayList<Integer> aList = new ArrayList<Integer>();

    Scanner sc = new Scanner(System.in);
    // 整数の入力
    int n = sc.nextInt();
    int count = 1;

    HashMap<Integer, Integer> table = new HashMap<Integer, Integer>();

    for (int i = 0; i < n; i++) {
      int tmp = sc.nextInt();
      aList.add(tmp);
      table.put(tmp - 1, 0);
    }

    table.put(aList.get(0), 1);

    for (int i = 1; i < n; i++) {
      table.put((aList.get(i)), table.get(aList.get(i) - 1) + 1);

      if (count < table.get(aList.get(i))) {
        count = table.get(aList.get(i));
      }
    }

    pw.println(n - count);
    exitImmediately();
  }

  private static void exitImmediately() {
    pw.close();
    System.exit(0);
  }
}

Measured memory_bytes: 106476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);++(i))

int N, L, Q;
const int MAX_LOG = 20;
vector<int> X;
// nxt[k][i] := iから2^k日以内にいける最右のホテル
vector<vector<int>> nxt;

bool check(int day, int A, int B) {
    // cerr << day << ' ' << A << ' ' << B << endl;
    for (int i = MAX_LOG - 1; i >= 0; --i) {
        if (day & (1 << i)) {
            A = nxt[i][A];
            if (A == -1 or A >= B) {
                return true;
            }
        }
    }
    return false;
}

int solve(int A, int B) {
    int ok = N, ng = 0;
    while (ok - ng > 1) {
        int md = (ok + ng) >> 1;
        if (check(md, A, B)) {
            ok = md;
        } else {
            ng = md;
        }
    }
    return ok;
}

signed main() {

    cin >> N;

    X.resize(N);
    REP(i, N) cin >> X[i];

    cin >> L >> Q;

    nxt.assign(MAX_LOG, vector<int>(N, -1));
    REP(i, N - 1) {
        auto itr = upper_bound(X.begin(), X.end(), X[i] + L);
        nxt[0][i] = int(prev(itr) - X.begin());
    }
    FOR(i, 1, MAX_LOG) {
        REP(j, N) {
            if (nxt[i - 1][j] == -1) {
                nxt[i][j] = -1;
            } else {
                nxt[i][j] = nxt[i - 1][nxt[i - 1][j]];
            }
        }
    }

    while (Q--) {
        int A, B;
        cin >> A >> B;
        if (A > B) swap(A, B);
        --A, --B;
        cout << solve(A, B) << endl;
    }

}

Measured memory_bytes: 9080
if !ENV['RUBY_THREAD_VM_STACK_SIZE']
    require 'rubygems';RUBY=Gem.ruby
    exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},RUBY,$0)
end

N, U, V = gets.split.map(&:to_i)
ABs = readlines.map{|l| l.split.map(&:to_i)}

@g = ABs.each_with_object(Hash.new{|h, k| h[k] = []}){|(a, b), h| h[a] << b; h[b] << a}
@d = Array.new(N + 1){Array.new(2)}

def dfs(u, v, d, i)
  @d[v][i] = d
  @g[v].each{|k| dfs(v, k, d + 1, i) unless k == u}
end

dfs(U, U, 0, 0)
dfs(V, V, 0, 1)
puts @d.drop(1).select{|u, v| u < v}.map(&:last).max - 1

Measured memory_bytes: 203604
#include <stdio.h>
#include <math.h>
#include <limits.h>
int main(void){
  int n, i, j;
  scanf("%d", &n);
  long long a[n];
  for(i=0; i<n; i++)
    scanf("%lld", &a[i]);

  long long s[n+1];

  for(i=0; i<n+1; i++){
    s[i]=0;
  }
  
  for(i=0; i<n; i++) 
    s[i+1] = s[i]+a[i];
  
  long long ans = LLONG_MAX;

  for(i=1; i<n; i++){
    long long t1 = s[n]-s[i]; //[i,n)
    long long t2 = s[i]-s[0]; //[0,i)
    long long t = t1 - t2;
    if(t<0) t*=-1;
    if(ans > t){
      ans = t;
    }
  }
  printf("%lld", ans);
  return 0;
}


Measured memory_bytes: 3328
n,m,x = gets.chomp.split(' ').map(&:to_i)
choice = []
combination = []
n.times do
    choice << gets.chomp.split(' ').map(&:to_i)
end
prices = []
[0,1].repeated_permutation(n) do |bits|
    understandings = Array.new(m){0}
    price = 0
    bits.each_with_index do |bit,i|
        if bit == 1
            price += choice[i][0]
            m.times do |j|
                understandings[j] += choice[i][j+1]
            end
        end
    end
    flag = true
    understandings.each do |understanding|
        if understanding < x
            flag = false
            break
        end
    end
    if flag
        prices << price
    end
end
if prices.size >= 1
    puts prices.min
else
    puts -1
end


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

int main(){
    int t; cin >> t;
    while(t--){
        int N; cin >> N;
        vi K(N), L(N), R(N);
        vi gl, gr;
        for(int i=0; i<N; i++){
            cin >> K[i] >> L[i] >> R[i];
            if(L[i] >= R[i]) gl.push_back(i);
            else gr.push_back(i);
        }
        //Left
        ll sum=0;
        for(auto &x : gl){
            sum+=R[x];
        }
        priority_queue<int, vector<int>, greater<int>> pq;
        vector<vi> S(N);
        for(auto &x : gl){
            S[K[x]-1].push_back(x);
        }
        for(int i=0; i<N; i++){
            for(auto &x : S[i]){
                pq.push(L[x]-R[x]);
            }
            while((int)pq.size() > i+1){
                pq.pop();
            }
        }
        while(!pq.empty()){
            sum+=pq.top();
            pq.pop();
        }

        //Right
        for(auto &x : gr){
            sum+=L[x];
        }
        S.assign(N, vi(0));
        for(auto &x : gr){
            S[K[x]-1].push_back(x);
        }
        for(int i=N-1; i>=0; i--){
            for(auto &x : S[i]){
                pq.push(R[x]-L[x]);
            }
            while((int)pq.size() > N-i-1){
                pq.pop();
            }
        }
        while(!pq.empty()){
            sum+=pq.top();
            pq.pop();
        }
        cout << sum << endl;
    }
    return 0;
}

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

int main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  vector <int> l(N);
  vector <int> length_list;
  vector <int> Link_MP_list;
  vector <int> index_list;

  length_list.emplace_back(-1);
  Link_MP_list.emplace_back(-1);

  rep(i, N)
    cin >> l[i];
  int min_MP = INT16_MAX;
  
  rep(i, pow(2, N) - 1)
  {
    stringstream ss;
    ss << bitset<8>(i + 1);
    string s = ss.str(); // "00001001"
    int length = 0;
    int zero_count = 0;
    rep(index, N)
    {
      if(s[7 - index] == '0') zero_count++;
      else length += l[index];
    }    
    length_list.emplace_back(length);
    Link_MP_list.emplace_back((N - zero_count - 1) * 10);
  }

  reps(1, A_i, length_list.size())
    reps(1, B_i, length_list.size())
    {
      if( (A_i & B_i) != 0) continue;
      reps(1, C_i, length_list.size())
      {
        if( (B_i & C_i) != 0) continue;
        if( (C_i & A_i) != 0) continue;
        int MP = abs(length_list[A_i] - A) + abs(length_list[B_i] - B) + abs(length_list[C_i] - C);
        MP += Link_MP_list[A_i] + Link_MP_list[B_i] + Link_MP_list[C_i];
        min_MP = min(MP, min_MP);
      }
    }
  cout << min_MP << endl;


  return 0;

}

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

typedef long long ll;

main()
{
    int a, b, k;
    cin >> a >> b >> k;
    int arr[101] = {0};
    vector<int> v;
    int i = 1;
    while(i <= a/i){
        if(a % i == 0){
            if(i == a/i){
                arr[i]++;
            }
            else{
                arr[i]++;
                arr[a/i]++;
            }
        }
        i++;
    }
    i = 1;
    while(i <= b/i){
        if(b % i == 0){
            if(i == b/i){
                arr[i]++;
            }
            else{
                arr[i]++;
                arr[b/i]++;
            }
        }
        i++;
    }
    for(int i = 0; i < 101; i++){
        if(arr[i] == 2){
            v.push_back(i);
        }
    }
    sort(v.rbegin(), v.rend());
    cout << v[k-1];



}





///promy_pompom
//hello world


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
//プロトタイプ宣言
int gcd(int , int);
void often(void);
int get_digent(int);


int main(){
  often();
  ll a,b;
  cin >> a >> b;
  if((a+b)%2==0) cout << (a+b)/2 << endl;
  else cout << "IMPOSSIBLE" << endl;
}








































//以下、ライブラリ

int gcd(auto a, auto b) {
  return b ? gcd(b, a%b) : a;
}  //ユークリッドの互除法

void often(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int get_digent(int x){
  string s;
  s = to_string(x);
  int digent = s.size();
  return digent;
} 

Measured memory_bytes: 256
<?php
$n = fgets(STDIN);
for ($i = 0; $i < $n; $i++) {
	$line = explode(" ", trim(fgets(STDIN)));
	rsort($line);
	if ($line[0]**2 == $line[1]**2 + $line[2]**2) {
		echo "YES\n";
	}else {
		echo "NO\n";
	}
}

Measured memory_bytes: 15140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  string S;
  cin >> S;
  if(S.at(0) == S.at(1) && S.at(1) == S.at(2)){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 3580
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*
a[i]: i番目を踏むときの最善

漸化式は
a[i] = min(j; i - k .. i)(a[j] + abs(h[i] - h[j]))

*/

void main(){
	long n = read.to!long;
	long k = read.to!long;
	long[] hs = readln.chomp.split.map!(to!long).array;
	
	long[] as = [0];
	foreach(i; 1 .. n){
		as ~= long.max;
		foreach(j; max(0, i - k) .. i){
			long a = as[j] + abs(hs[i] - hs[j]);
			if(a < as[i]) as[i] = a;
		}
	}
	
	as[n - 1].writeln;
}


Measured memory_bytes: 4512
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

long baseN(long mynum, long mybase) { //9進数まで。
	if (mynum == 0) return 0;
	long N = mynum;
	long B = mybase;
	string S = "";

	while (N != 0) {
		string mymod = to_string(N % B);
		N -= N % B;
		N /= B;
		S = mymod + S;
	}

	return stol(S);
}


int main() {

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

	for (long i = 1;; i++) {
		string base4 = to_string(baseN(i, 4));
		long mylen = base4.length();
		if (count(&base4[0], &base4[mylen], '0') != 0) continue;
		if (count(&base4[0], &base4[mylen], '1') == 0) continue;
		if (count(&base4[0], &base4[mylen], '2') == 0) continue;
		if (count(&base4[0], &base4[mylen], '3') == 0) continue;

		for (int i = 0; i <= mylen - 1; i++) {
			if (base4[i] == '3')base4[i] = '7';
            if (base4[i] == '2')base4[i] = '5';
            if (base4[i] == '1')base4[i] = '3';
		}

		long num753 = stol(base4);
		 
		if (num753 <= N) res++; else break;
	}

	cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
struct list {
	int val;
	list* next;
	list* prev;
};
list*  head;
void init() {
	head = new list;
	head->next = head;
	head->prev = head;
}
int main() {
	using namespace std;
	int len,key;
	cin >> len;
	char str[12];
	init();
	for (int i = 0; i < len;i++) {
		scanf("%s", str);
		if (str[0] == 'i') {
			list* add = new list;
			scanf("%d", &key);
			add->val = key;
			add->next = head->next;		
			head->next->prev = add;
			head->next = add;
			add->prev = head;
		}
		else if (strlen(str)>6 && str[6] == 'F') {
			if (head->next != head) {
				head->next->next->prev = head;
				list* minus = head->next;
				head->next = head->next->next;
				delete minus;
			}
		}
		else if (strlen(str)>6 && str[6] == 'L') {
			if (head->prev != head) {
				list* minus = head->prev;
				minus->prev->next =minus->next;
				minus->next->prev = minus->prev;
				delete minus;
			}
		}
		else {
			scanf("%d", &key);
			list* search = head->next;
			while (search != head && search->val != key) {
				search = search->next;
			}
			if (search == head)
				continue;
			search->prev->next = search->next;
			search->next->prev = search->prev;
			delete search;
		}
	}
	list* show = head->next;
	int isf = 0;
	while (1) {
		if (show == head)break;
		if (isf++ > 0) printf(" ");
		printf("%d", show->val);
		show = show->next;
		delete show->prev;
	}
	printf("\n");
	delete head;
	return 0;
}


Measured memory_bytes: 34376
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int mxN = 805;

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int h, w, k;
int vis[mxN][mxN];
int dist[mxN][mxN];

bool valid(int i, int j){
	return (i >= 0 && j >= 0 && i < h && j < w);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin >> h >> w >> k;
	vector<string> s(h);
	rep(i, h) cin >> s[i];
	pi st;
	rep(i, h) rep(j, w) if(s[i][j] == 'S') st = mp(i, j), s[i][j] = '.';
	vector<pi> proc = {st};
	vis[st.fi][st.se] = 1;
	queue<pi> q;
	q.push(st);
	int cnt = 0;
	while(cnt < k && !q.empty()){
		queue<pi> q1;
		while(!q.empty()){
			pi cur = q.front();
			q.pop();
			rep(i, 4){
				int x = dx[i] + cur.fi, y = dy[i] + cur.se;
				if(valid(x, y) && !vis[x][y] && s[x][y] != '#'){
					vis[x][y] = 1;
					proc.pb(mp(x, y));
					q1.push(mp(x, y));
				}
			}
		}	
		cnt++;
		q = q1;
	}
	rep(i, mxN) rep(j, mxN) dist[i][j] = 1e9;
	set<pair<int, pi>> q2;
	rep(i, proc.size()){
		dist[proc[i].fi][proc[i].se] = 0;
		q2.insert(mp(0, mp(proc[i].fi, proc[i].se)));
	}
	int ans = 1e9;
	while(!q2.empty()){
		pair<int, pi> cur = *q2.begin();
		q2.erase(q2.begin());
		rep(i, 4){
			int x = dx[i] + cur.se.fi, y = dy[i] + cur.se.se;
			if(valid(x, y) && dist[x][y] > (1 + dist[cur.se.fi][cur.se.se])){
				q2.erase(mp(dist[x][y], mp(x, y)));
				dist[x][y] = dist[cur.se.fi][cur.se.se] + 1;
				q2.insert(mp(dist[x][y], mp(x, y)));
			}
		}
	}
	rep(i, h) ans = min(ans, (dist[i][w - 1] + k - 1) / k);
	rep(i, h) ans = min(ans, (dist[i][0] + k - 1) / k);
	rep(j, w) ans = min(ans, (dist[h - 1][j] + k - 1) / k);
	rep(j, w) ans = min(ans, (dist[0][j] + k - 1) / k);
	cout << ans + 1 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 53012
#include<bits/stdc++.h>
using namespace std;
int MAXN=99999;
int MAXM=60;

int main(){
  int N, M;
  int f[MAXN];
  int a[MAXM], b[MAXM];
  cin >> N >> M;

  for (int i=0 ; i < M; i++){
    cin >> a[i] >> b[i];
  }

  for (int j=0; j < N; j++){
    f[j]=0;
  }

  for (int i=0; i < M; i++){
    for (int j=0; j < N; j++){
      if (a[i] == j+1 || b[i] == j+1){
        f[j]+=1;
      }
    }
  }
  for (int j =0; j < N; j++){
    cout << f[j] << endl;
  }

  return 0;
}

Measured memory_bytes: 256
# ABC078D - ABS (ARC085D)
def main():
    N, Z, W, *A = map(int, open(0).read().split())
    if N == 1:
        ans = abs(A[0] - W)
    else:
        ans = max(abs(A[-1] - W), abs(A[-2] - A[-1]))
    print(ans)


if __name__ == "__main__":
    main()

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

typedef int Capacity;
struct Edge {
    int src, dst;
    Capacity cap;
    Edge(int src_, int dst_, Capacity cap_) :
        src(src_), dst(dst_), cap(cap_) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef int Capacity;
struct Dinic {
    int n, s, t;
    vector<int> level, iter, que;
    vector<vector<Capacity>> cap, flow;
    vector<vector<int>> g;
    Capacity inf;
    Dinic(int n)
        : n(n), cap(n, vector<Capacity>(n)), flow(n, vector<Capacity>(n)),
          g(n, vector<int>()), inf(numeric_limits<Capacity>::max()/8){}
    Dinic(const Graph &graph){
        *this = Dinic(graph.size());
        for(int i = 0; i < n; i++) for(auto &e : graph[i]) addEdge(e.src, e.dst, e.cap);
    }
    void addEdge(int u, int v, Capacity c){
        cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;
        g[u].push_back(v); g[v].push_back(u);
    }
    inline Capacity residue(int u, int v){ return cap[u][v] - flow[u][v]; }
    Capacity solve(int s, int t){
        this->t = t, this->s = s;
        que.resize(n+1);
        Capacity res = 0;
        while(levelize()){
            iter.assign(n, 0);
            res += augment(s, inf);
        }
        return res;
    }
    bool levelize(){
        int l = 0, r = 0;
        level.assign(n, -1); level[s] = 0;
        que[r++] = s;
        while(l != r){
            int v = que[l++];
            for(const int &d : g[v]){
                if((level[d] != -1 && level[d] <= level[v] + 1) || residue(v,d) == 0) continue;
                level[d] = level[v] + 1; que[r++] = d;
            }
        }
        return level[t] != -1;
    }
    Capacity augment(int v, Capacity lim){
        Capacity res = 0;
        if(v == t) return lim;
        for(int &i = iter[v]; i < (int)g[v].size(); i++){
            const int &d = g[v][i];
            if(residue(v,d) == 0 || level[v] + 1 != level[d]) continue;
            const Capacity aug = augment(d, min(lim, residue(v,d)));
            if(aug > 0){
                flow[v][d] += aug; flow[d][v] -= aug;
                res += aug; lim -= aug;
                if(lim == 0) break;
            }
        }
        return res;
    }
};

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

int main(){
    int N,M;
    cin >> N >> M;
    Graph g(N);
    rep(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        g[a].emplace_back(a,b,c);
    }
    Dinic dinic(g);
    cout << dinic.solve(0,N-1) << endl;
}

Measured memory_bytes: 1348
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(z) for(int i=1;i<=z;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
#define mod  1000000007
#define cl(n,m) (n-1)/m  + 1 ;
#define T() int TT; cin>>TT; while(TT--)
#define P pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const int  N = 1e5 + 5;

int dis[10][10] ;
signed main(){
	int x ;
	int ans = 0 ;
	int h , w ;
	cin >>h >> w ;
	for (int i = 0; i<=9 ;i++){
		for( int j = 0;j<=9 ; j++){
			cin >> dis[i][j] ;
		}
	}

	for( int k = 0 ;k<=9 ;k++){
		for( int i = 0 ;i<=9 ;i++){
			for( int j =0 ;j<=9 ;j++){
				dis[i][j] = min( dis[i][j]  , dis[i][k] + dis[k][j]) ;
			}
		}
	}

	for( int i =1 ;i<=h ;i++){
		for( int j =1 ;j<=w ;j++){
			cin>>x ;
			if( x !=-1){
				ans += dis[x][1] ;
			}
		}
	}
	cout << ans ;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX_NUM 200000
#define BIRTHDAY 1009

typedef struct hash{
	int num;
	struct hash *next;
}hash;

void append(hash**, int);
void search(hash**, int);
void possible();

int a_list[MAX_NUM] = {0};
int a_index = 0;
hash *hash_list[BIRTHDAY] = {NULL};

int main(void){
	int N, M;
	int a, b;
	int i;
	hash *p;

	scanf("%d %d", &N, &M);
	for(i = 0; i < M; i++){
		scanf("%d %d", &a, &b);
		if(a == 1){
			append(hash_list, b);
		}
		if(b == N){
			a_list[a_index++] = a;
		}
	}

	for(i=0; i<a_index; i++){
		search(hash_list, a_list[i]);
	}

	printf("IMPOSSIBLE");
	return 0;
}

void append(hash **list, int num){
	hash *p, *tmp;
	hash *item;
	tmp = NULL;
	for(p = list[num%BIRTHDAY]; p != NULL && p->num < num; p = p->next)
		tmp = p;

	item = (hash*)malloc(sizeof(hash));
	item->num = num;
	item->next = p;
	if(tmp == NULL)
		list[num%BIRTHDAY] = item;
	else
		tmp->next = item;
}

void search(hash **list, int num){
	hash *p;
	for(p = list[num%BIRTHDAY]; p != NULL && p->num <= num; p = p->next){
		if(p->num == num)
			possible();
	}
}

void possible(){
	printf("POSSIBLE");
	exit(0);
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	ll n;
	cin>>n;
	vector<bool> ans;
	while(n > 0){
		if((n-1)%2 == 0){
			ans.push_back(true);
			n = (n-1)/2;
		}else{
			ans.push_back(false);
			n = n-1;
		}
	}
	reverse(all(ans));
	vector<int> s;
	int max = 0;
	int min = -1;
	rep(i,ans.size()){
		if(ans[i]){
			s.push_back(max);
			max++;
		}else{
			s.push_back(min);
			min--;
		}
	}
	rep(i,ans.size()){
		s[i] -= min;
	}
	cout<<s.size()*2<<endl;
	reps(i,s.size()){
		cout<<i<<" ";
	}
	rep(i,s.size()){
		cout<<s[i];
		if(i != s.size()-1){
			cout<<" ";
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
s=input()
t=list(map(int,input().split()))
t.sort(reverse=True)
a=0
b=0
d=0
e=0
if len(t)%2==0:
  for i in range(0,len(t),2):
    d+=t[i]
    e+=t[i+1]
  print(d-e)
else:
  for j in range(0,len(t),2):
    d+=t[j]
  for l in range(1,len(t),2):
    e+=t[l]
  print(d-e)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, i;
    cin >> N;
    if(N > 81) cout << "No\n";
    else if(N < 10) cout << "Yes\n";
    else{
        i = 2;
        while(i<10){
            if(N%i == 0 && N/i < 10){
                cout << "Yes\n";
                break;
            }
            i++;
        }
        if(i == 10) cout << "No\n";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) REPD(i, 0, n)
#define DIV0 1000000007
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int X,Y;
    cin >> X >> Y;
    if(Y > 4*X){fin("No"); return 0;}
    if(Y < 2*X){fin("No"); return 0;}
    REP(i,X){
        REP(j,X-i){
            if(i*4+j*2 == Y){
                fin("Yes");
                return 0;
            }
        }
    }
    fin("No");
    return 0;
}

Measured memory_bytes: 3128
# -*- coding: utf-8 -*-
n = int(input())
ab = list()
for _ in range(n - 1):
    ab.append(list(map(int, input().split())))

c = list(map(int, input().split()))

tree = [[] for i in range(n)]
for a, b in ab:
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)

c.sort(reverse=True)

ans = [-1 for _ in range(n)]
ans[0] = c.pop(0)

q = list()
q.append(0)

while(len(q) != 0):
    v = q.pop(0)
    for u in tree[v]:
        if ans[u] != -1:
            continue
        ans[u] = c.pop(0)
        q.append(u)

print(sum(ans[1:]))
print(" ".join([str(a) for a in ans]))

Measured memory_bytes: 7896
x1, y1, x2, y2 = map(int, input().split())
x_len = x1 - x2
y_len = y1 - y2

x3 = x2 + y_len
y3 = y2 - x_len
x4 = x3 + x_len
y4 = y3 + y_len

print(x3, y3, x4, y4)

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int a,b,x; cin >> a >> b >> x;
    if(a<=x && a+b>=x)cout <<"YES" << endl;
    else cout << "NO" << endl;
}


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

int main(void)
{
    long N, K, Q;
    long A;
    long point[100000];
    long i;
    
    scanf("%ld %ld %ld", &N, &K, &Q);
    
    for (i = 0; i < N; i ++) {
        point[i] = K - Q;
    }
    
    for (i = 0; i < Q; i++) {
        scanf("%ld", &A);
        --A;
        point[A]++;
    }
    
    for (i = 0; i < N; i ++) {
        if (point[i] <= 0) {
            printf("No\n");
        } else {
            printf("Yes\n");
        }
    }

    return 0;
}

Measured memory_bytes: 1280
N,Y = gets.chomp.split(" ").map(&:to_i);

for x in 0..N
  for y in 0..(N-x)
    z = N - x - y
    a = (x + y + z)
    b = (10000 * x + 5000 * y + 1000 * z)
    if (a == N and b == Y)
      puts "#{x} #{y} #{z}"
      exit
    end
  end
end

puts "-1 -1 -1"

Measured memory_bytes: 3836
#include<stdio.h>
#include<ctype.h>
long long IN(void)
{
  long long x=0,f=1;char c=getchar();
  while(!isdigit(c)&&c!='-')c=getchar();
  if(c=='-')f=-f,c=getchar();
  while(isdigit(c))x=x*10+c-48,c=getchar();
  return f*x;
}
void OUT(int x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
int main(void)
{
  int N,i,j,x,A[200000]={0},here[200000]={0},town[200000]={0};
  long long K;
  N=IN(),K=IN();
  for(i=0;i<N;i++)A[i]=IN(),here[i]=-1;
  for(i=0,j=0;;i=A[i]-1,j++)if(here[i]<0)here[i]=j,town[j]=i;else{x=here[i];break;}
  if(K>=j)K=(K-x)%(x-j)+x;
  return OUT(town[K]+1),0;
}

Measured memory_bytes: 3868
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N, K;
vector<pair<int, int>>vec;

int main(void)
{
	cin >> N >> K;
	for (int i = 0; i < N; ++i)
	{
		int x, y;
		cin >> x >> y;
		vec.push_back({ x,y });
	}
	LL answer = LLONG_MAX;
	for (int A = 0; A < N; ++A)
	{
		for (int B = 0; B < N; ++B)
		{
			if (vec[A].second >= vec[B].second)continue;
			vector<pair<int, int>>inner;
			for (int c = 0; c < N; ++c)
			{
				if (vec[A].second <= vec[c].second && vec[c].second <= vec[B].second)
				{
					inner.push_back(vec[c]);
				}
			}
			sort(inner.begin(), inner.end());
			LL height = (LL)vec[B].second - vec[A].second;
			for (int i = 0; i <= (int)inner.size() - K; ++i)
			{
				LL width = inner[i + K - 1].first - inner[i].first;
				LL area = height * width;
				answer = min(answer, area);
			}
		}
	}
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 256