akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
 
int main(void){
    int i,n,t1,t2,j,m,e;
    while(0==0)
    {
        scanf("%d",&n);
        if(n==0)break;
 
        for(i=0;i<n;i++){
            scanf("%d %d %d",&m,&e,&j);
            t1=m+e;  t2=m+e+j;
            if((m==100 || e==100 || j==100) || (t1>=180) || (t2>=240))
                printf("A\n");
            else if((t2>=210) || (t2>=150 && ( m>=80 || e>=80)))
                printf("B\n");
            else printf("C\n");
        }
    }
    return 0;
}

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2];


void solve()
{
     cin >> n;
     bool f = 1;
     lop(i, 0, n)
     {
          cin >> arr[i];
          if (arr[i] == 0 ) f = 0;
     }

     if (f == 0)
     {
          cout << 0 << endl;
          return;
     }


     long double sum = arr[0];
     lop(i, 1, n)
     {
          // cout << sum << endl;
          sum = sum * arr[i];
          if ( sum > (long double)1e18 )
          {
               cout << -1 << endl;
               return ;
          }
     }

     cout << fixed << setprecision(0) << sum << endl;

}

int32_t main()
{
     ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

     int test = 1;
     // cin >> test;
     while (test--)solve();


}





Measured memory_bytes: 4540
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int main()
{
  ll n, k;
  cin >> n >> k;
  
  vector<ll> vec(n);
  for (ll i = 0; i < n; i++) {
    cin >> vec[i];
  }
  
  ll len = 0;
  for (ll i = 1; i <= k; i*=2) {
    len++;
  }
  
  ll x = 0;
  for (ll i = len - 1; i >= 0; i--) {
    ll one = 0, zero = 0;
    for (ll j = 0; j < n; j++) {
      if (vec[j] & (1LL << i)) {
        one++;
      } else {
        zero++;
      }
    }
    if (zero > one && (x | (1LL << i)) <= k) {
      x |= (1LL << i);
    }
  }
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    ans += vec[i] ^ x;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vp = vector<pii>;
using vs = vector<string>;
using qi = queue<int>;
using qp = queue<pii>;
using pqi = priority_queue<int>;
using pqim = priority_queue<pii, vector<pii>, greater<pii> >;
using ppp = pair<int, pair<int, int>>;
#define all(vec) vec.begin(), vec.end()
#define rall(vec) vec.rbegin(), vec.rend()
#define pb push_back
const ll mod = 998244353;
const ll inf = 1e18;
ll a;
string s;
void input() {
	cin >> a >> s;
}
void solve() {
	ll b = 0;
	for (int i = 0; i < 4; ++i) {
		if (i == 1) continue;
		b = b * 10 + s[i] - '0';
	}
	cout << a * b / 100;

	return;
}

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

	//int tc; cin >> tc;
	//while (tc--) {
	input();
	solve();
	//}
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

const int mod = 1000000007;

int main() {
    int n,k;
    int m=0;
    int cnt=0;
    cin >> n >> k;

    vector<int> a(n);
    for (int i=0; i<n; i++) cin>>a[i];

    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            if (a[i] < a[j]) cnt++;
            if (i>=j) continue;
            if (a[i] > a[j]) m++;
        }
    }
    // cout << cnt << endl;
    // cout << m << endl;

    // (k-1) * (k-1 + 1) / 2;
    long long ans = ((long long)k*(k-1)/2) % mod;
    ans *= cnt;
    ans %= mod;
    ans += (long long)m*k;
    ans %= mod;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

int pl[101010];
ll val[101010];
vector<pair<int, ll>>e[101010];
ll cur = inf;
void dfs(int now,int pre) {
	fore(x, e[now]) {
		ll cost = x.second;
		int nxt = x.first;
		if (pl[nxt] != -1) {
			if (pre == nxt)continue;
			if (pl[nxt] == pl[now]) {
				ll tmp;
				tmp = (pl[nxt] == 0) ? cost - (val[nxt] + val[now]) : val[nxt] + val[now]-cost;
				if (tmp % 2 != 0) {
					puts(0);
					exit(0);
				}
				if (cur == inf)cur = tmp / 2;
				else if (tmp / 2 != cur) {
					puts(0);
					exit(0);
				}
			}
			else {
				ll tmp = val[nxt] + val[now];
				if (tmp != cost) {
					puts(0);
					exit(0);
				}
			}
		}
		else {
			val[nxt] = cost - val[now];
			pl[nxt] = !pl[now];
			dfs(nxt,now);
		}
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	memset(pl, -1, sizeof(pl));
	rep(i, 0, m) {
		int u, v, c;
		cin >> u >> v >> c;
		u--, v--;
		e[u].pb({ v,c });
		e[v].pb({ u,c });
	}
	
	pl[0] = 0;
	dfs(0,-1);

	ll pmi = inf;
	ll mmi = inf;
	rep(i, 0, n) {
		if (pl[i] == 0)pmi = min(pmi,val[i]);
		else mmi = min(mmi, val[i]);
	}

	if (cur != inf) {
		if (pmi + cur > 0 && mmi - cur > 0)puts(1);
		else puts(0);
	}
	else {
		puts(max(pmi + mmi - 1, 0LL));
	}

	return 0;
}


Measured memory_bytes: 15232
n,m = map(int, input().split())
while(n != 0 or m != 0):
    dplists = []
    for i in range(n):
        dplist= list(map(int, input().split()))
        dplists.append(dplist)
    dplists = sorted(dplists, key = lambda x: x[1], reverse = True)
    for i in range(n):
        if ( m >= dplists[i][0]):
            m = m - dplists[i][0]
            dplists[i][0] = 0
        else:
            dplists[i][0] = dplists[i][0] - m
            m = 0
            l = i
            break
    sum = 0
    for k in range(l,n):
        sum += dplists[k][0]*dplists[k][1]
    print(sum)
    n,m = map(int,input().split())


Measured memory_bytes: 7216
#Checkpoints
N,M = list(map(int, input().split()))
s,c =[],[]
for i in range(N):
    s.append( list(map(int, input().split())) )
for i in range(M):
    c.append( list(map(int, input().split())) )
    
for si in s:
    l = [ abs(si[0]-c[i][0])+abs(si[1]-c[i][1]) for i in range(M) ]
    print(l.index(min(l))+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}


vector<int> argmin_subseq(const vector<int> &seq,const int K){
  vector<int> A=seq;
  const int mi=numeric_limits<int>::min();
  int N=A.size(),mx=mi,amx;
  assert(0<K && K<=N);
  vector<int> idx,nx;
  for(auto &I:A){I*=-1;}
  for(int i=0;i+K<=N;i++){mx=max(mx,A[i]);}
  for(auto &I:A){I-=mx-1;}
  for(int i=0;i+K<=N;i++){
    if(A[i]==1){idx.push_back(i);}
  }
  for(int len=1;len<K;){
    mx=mi;
    amx=-1;
    for(auto I:idx){
      if(mx<=A[I+len]){
        mx=A[I+len];
        amx=I;
      }
    }
    if(mx<=0){
      for(auto I:idx){
        if(A[I+len]==mx){A[I]++; nx.push_back(I);}
      }
      len++;
    }
    else{
      int ls=idx.back();
      if(ls+len+K>N){
        for(int j=0;j<mx && len+j<K;j++){
          if(seq[amx+len+j]>seq[ls+len+j]){return {ls};}
          else if(seq[amx+len+j]==seq[ls+len+j]){A[ls]++;}
          else{break;}
        }
      }
      reverse(idx.begin(),idx.end());
      for(auto I:idx){
        A[I]+=max(0,min(A[I+len],K-len));
        mx=max(mx,A[I]);
      }
      reverse(idx.begin(),idx.end());
      for(auto I:idx){
        if(A[I]==mx){nx.push_back(I);}
      }
      len=mx;
    }
    idx.clear();
    swap(nx,idx);
  }
  return idx;
}

vector<int> argmin2(string s,int N){
  vector<int> ret;
  string mi=s.substr(0,N);
  for(int i=1;i<=N;i++){mi=min(mi,s.substr(i,N));}
  for(int i=0;i<=N;i++){
    if(mi==s.substr(i,N)){ret.push_back(i);}
  }
  return ret;
}

int main(){
  ll N,K;
  cin>>N>>K;
  string s;
  cin>>s;
  string t=s;
  reverse(t.begin(),t.end());
  s+=t;
  vector<int> A(s.size());
  for(int i=0;i<(int)s.size();i++){A[i]=(int)s[i];}
  vector<int> ret=argmin_subseq(A,N);
  vector<int> ret2=argmin2(s,N);
  //assert(ret==ret2);
  int idx=ret2[0];
  int cnt=0,c=0;
  for(int i=0;i<N;i++){
    if(A[idx]==A[idx+i]){cnt++;}
    else{break;}
  }
  c=cnt;
  while(K>1 && cnt<N){cnt*=2; K--;}
  string ans;
  for(int i=0;i<cnt && i<N;i++){ans+=s[idx];}
  for(int i=cnt;i<N;i++){ans+=s[idx+c+(i-cnt)];}
  cout<<ans<<endl;

  
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
 
int main(){
    char ch;
    while(1){
        scanf("%c",&ch);
        if(islower(ch)){
            ch=toupper(ch);
        }
        else if(isupper(ch)){
            ch=tolower(ch);
        }
        printf("%c",ch);
        if(ch=='\n') break;
    }
    return 0;
}

Measured memory_bytes: 2564
a, b, ab, x, y = map(int, input().split())
average = (a + b) / 2

if average <= ab:
    ans = a * x + b * y
else:
    temp1 = ab * min(x, y) * 2 + a * (x - min(x, y)) + b * (y - min(x, y))
    temp2 = ab * max(x, y) * 2
    ans = min(temp1, temp2)
    
print(ans)

Measured memory_bytes: 3064
import math

D,G = map(int,input().split())
pc = [list(map(int,input().split()))for i in range(D)]

digit = "0"+str(D)+"b"
ans = float('INF')
for i in range(2**D):
  pattern = list(str(format(i,digit)))
  point = 0
  count = 0
  last0 = -1
  for j in range(D):
    if pattern[j] =="1":
      point += pc[j][1]+pc[j][0]*100*(j+1)
      count += pc[j][0]
    else:
      last0 = j
  r = G - point
  if r > 0 and last0 > -1:
    tmp = math.ceil(r/(100*(last0+1)))
    if tmp < pc[last0][0]:
      count += tmp
      ans = min(ans,count)
  elif r <= 0:
    ans = min(ans,count)
  
print(ans)

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

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


long long lcm(long long a, long long b)
{
    return (a*b)/gcd(a, b);
}
int main()
{
    long long a,b;
    cin>>a>>b;
    cout<<lcm(a, b);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

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

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


#define WALL '#'
#define PATH '.'

class coord{
    public:
    coord(){}
    coord(int _x,int _y):x(_x),y(_y){}
    int x,y;
};

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

    int h, w;
    cin >> h >> w;

    int ch, cw;
    cin >> ch >> cw;
    int dh, dw;
    cin >> dh >> dw;

    vector<vector<int>> m(h, vector<int>(w));
    rep(i,h){
        string si; cin >> si;
        rep(j,w){
            m[i][j] = si[j];
        }
    }
    vector<vector<int>> d(h, vector<int>(w));
    vector<vector<int>> mahou(h, vector<int>(w));
    rep(i,h){
        rep(j,w){
            d[i][j] = -1;
        }
    }
    rep(i,h){
        rep(j,w){
            mahou[i][j] = inf;
        }
    }
    auto s = coord(ch-1, cw-1);

    d[s.x][s.y]=0;
    mahou[s.x][s.y]=0;

    queue<coord> q2;
    queue<coord> q;
    q.push(s);
    while(q.size()){
        while(q.size()){
            coord u = q.front(); q.pop();
            int count = 0;
            rep(ix,3)rep(jx,3){
                if(abs(ix-1)+abs(jx-1)==2) continue;                    
                int i = ix-1 + u.x;
                int j = jx-1 + u.y;                 
                if(i>=0&&i<h&&j>=0&&j<w&&(d[i][j]==-1 || mahou[i][j] > mahou[u.x][u.y])&&m[i][j]==PATH){
                    d[i][j] = 1;
                    mahou[i][j] = mahou[u.x][u.y];
                    q.push(coord(i,j));
                    count++;
                }
            }
            if (count > 2) continue;
            q2.push(u);
        }
        while(q2.size()){
            coord u = q2.front(); q2.pop();
            rep(ix,5)rep(jx,5){
                int i = ix-2 + u.x;
                int j = jx-2 + u.y;                 
                if(i>=0&&i<h&&j>=0&&j<w&&(d[i][j]==-1 || mahou[i][j] > mahou[u.x][u.y]+1)&&m[i][j]==PATH){
                    d[i][j] = 1;
                    mahou[i][j] = mahou[u.x][u.y]+1;
                    q.push(coord(i,j));
                }
            }
        }
    }


    // wcout << "d\n";
    // rep(i, h) {
    //     rep(j, w) {
    //         wcout << d[i][j] << " ";
    //     }
    //     wcout << "\n";
    // }
    // wcout << "mahou\n";
    // rep(i, h) {
    //     rep(j, w) {
    //         wcout << mahou[i][j] << " ";
    //     }
    //     wcout << "\n";
    // }
    auto res = mahou[dh-1][dw-1];
    if (res == inf) {
        wcout << -1 << "\n";

    } else {
        wcout << res << "\n";
    }
}

Measured memory_bytes: 15576
#include <iostream>

using namespace std;

int main(void)
{
    int A1, A2, A3;

    cin >> A1 >> A2 >> A3;

    if(A1+A2+A3>=22){
        cout << "bust" << endl;
    }

    else{
        cout << "win" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (){
	
	char s[100], t[100], u[100];
	int a,b;
	int x = 0;
	scanf ("%s %s", s, t);
	scanf ("%d %d", &a, &b);
	getchar();
	scanf ("%s", u);
	
	for(int i = 0 ; s[i] != '\0' || t[i] != '\0' ; i++ ){
		if(s[i] != u[i]){
		x = 1;
		break;
		}
	}
	if (x == 0){
		printf ("%d %d\n", a-1, b);
	}
	else {
		printf ("%d %d\n", a , b-1);
	}
	return 0;
}

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

int main(){
    int x;
    for(int i=1;i<=5;i++){
        cin >> x;
        if(x!=i){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

template <typename T>
struct edge {
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x) {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

template <typename T>
using Edges = vector<edge<T>>;
template <typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T>
using Matrix = vector<vector<T>>;

struct UnionFind {
    vector<int> data;

    UnionFind(int sz) { data.assign(sz, -1); }

    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
    }

    bool same(int x, int y) { return find(x) == find(y); }

    int find(int k) {
        if (data[k] < 0) return k;
        return (data[k] = find(data[k]));
    }

    int size(int k) { return (-data[find(k)]); }
};

template <typename T, typename F>
T boruvka(int N, F f) {
    vector<int> rev(N), belong(N);
    UnionFind uf(N);
    T ret = T();
    while (uf.size(0) != N) {
        int ptr = 0;
        for (int i = 0; i < N; i++) {
            if (uf.find(i) == i) {
                belong[i] = ptr++;
                rev[belong[i]] = i;
            }
        }
        for (int i = 0; i < N; i++) {
            belong[i] = belong[uf.find(i)];
        }
        auto v = f(ptr, belong);
        bool update = false;
        for (int i = 0; i < ptr; i++) {
            if (~v[i].second && !uf.same(rev[i], rev[v[i].second])) {
                uf.unite(rev[i], rev[v[i].second]);
                ret += v[i].first;
                update = true;
            }
        }
        if (!update) return -1;
    }
    return ret;
}

int main() {
    int V, E;
    cin >> V >> E;
    Edges<int> g;
    for (int i = 0; i < E; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        g.emplace_back(s, t, w);
    }
    const int INF = 1 << 30;
    auto f = [&](int sz, vector<int> belong) {
        vector<pair<int, int>> ret(sz, {INF, -1});
        for (auto &e : g) {
            if (belong[e.src] == belong[e.to]) continue;
            ret[belong[e.src]] =
                min(ret[belong[e.src]], make_pair(e.cost, belong[e.to]));
            ret[belong[e.to]] =
                min(ret[belong[e.to]], make_pair(e.cost, belong[e.src]));
        }
        return ret;
    };
    cout << boruvka<int, decltype(f)>(V, f) << endl;
}


Measured memory_bytes: 4528
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	static Scanner in;
	static PrintWriter out;
	static void solve() {
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int ans1 = a + b;
		int ans2 = b + c;
		int ans3 = c + a;
		int answer = Math.min(Math.min(ans1, ans2), ans3);
		out.println(answer);		
	}
	public static void main(String[] args) {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
		out.close();
		in.close();
	}

}


Measured memory_bytes: 23636
from sys import exit, stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
s1 = set()
sn = set()
for _ in range(M):
    a,b = [int(_) for _ in stdin.readline().rstrip().split()]
    if a==1:
        s1.add(b)
    elif b==N:
        sn.add(a)
for x in s1:
    if x in sn:
        print("POSSIBLE")
        exit(0)
print("IMPOSSIBLE")

Measured memory_bytes: 19012
package main

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

var tree map[int]map[int]int64
var color []int

func main() {
  var n int = NextInt()
  tree = make(map[int]map[int]int64)
  color = make([]int,n)
  for i:=0;i<n;i++ {
    tree[i] = map[int]int64{}
    color[i] = -1
  }
  for i:=0;i<n-1;i++ {
    var u,v,w int = NextInts()
    tree[u-1][v-1] = int64(w)
    tree[v-1][u-1] = int64(w)
  }
  dfs(0,-1,0)
  for i:=0;i<n;i++ { fmt.Println(color[i]) }
}

func dfs(v,p int,d int64) {
  color[v] = int(d%2)
  for u,w := range tree[v] {
    if u == p { continue }
    dfs(u,v,d+w)
  }
}

var reader = bufio.NewReaderSize(os.Stdin,1000000)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var x int
  x,_ = strconv.Atoi(NextLine())
  return x
}
func NextInts() (int,int,int) {
  var x,y,z int
  var s []string = strings.Split(NextLine()," ")
  x,_ = strconv.Atoi(s[0])
  y,_ = strconv.Atoi(s[1])
  z,_ = strconv.Atoi(s[2])
  return x,y,z
}

Measured memory_bytes: 42240
#include <stdio.h>

/* 選択ソート (0オリジン) */
int selectionSort(int A[], int N) {
  int i, j, t, sw = 0, mini;
  for(i=0; i<N-1; i++) {
    mini = i;
    for(j=i; j<N; j++) {
      if(A[j] < A[mini]) mini = j;
    }

  	t = A[i];
  	A[i] = A[mini];
  	A[mini] = t;

  	if(i != mini) sw++;
  }
  return sw;
}

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

  sw = selectionSort(A,N);

  for(i=0;i<N;i++) {
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n", sw);

  return 0;
}



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

int main()
{
    int M;
    cin >> M;

    ll sumc = 0;
    ll sumd = 0;
    for (int i = 0; i < M; i++)
    {
        ll d, c;
        cin >> d >> c;
        sumc += c;

        sumd += d * c;
    }
    ll ans = sumc - 1 + (sumd - 1) / 9;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstring>
#include <string.h>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;

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

	string s;
  	cin >> s;
  	if (s[1] == s[2] && (s[0] == s[1] || s[2] == s[3])) cout << "Yes";
  	else cout << "No";

	return 0;
}

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

vector <int> xaxis;
vector <int> yaxis;
bool dpx[8001][32001];
bool dpy[8001][32001];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	int gx,gy;
	int x=0,y=0;

	cin >> s;
	cin >> gx >> gy;

	int flag = 0;
	int cnt = 0;
	bool num = 0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='F')
		{
			cnt++;
		}
		else
		{
			if(flag==0)
			{
				if(num!=0)
				{
					if(cnt!=0)
					{
						xaxis.push_back(cnt);
						cnt = 0;
					}
				}
				else
				{
					if(cnt!=0)
					{
						x += cnt;
						cnt = 0;
					}
				}
				flag = 1;
				num++;
			}
			else
			{
				if(cnt!=0)
				{
					yaxis.push_back(cnt);
					cnt = 0;
				}
				flag = 0;
				num++;
			}
		}
	}

	if(cnt!=0)
	{
		if(flag==0)
		{
			if(num==0)
			{
				x+=cnt;
			}
			else
			{
				xaxis.push_back(cnt);
			}
		}
		else
		{
			yaxis.push_back(cnt);
		}
	}

	memset(dpx,false,sizeof(dpx));
	memset(dpy,false,sizeof(dpy));
	//cout << xaxis[0] << '\n';

	dpx[0][x+16000] = true;
	dpy[0][y+16000] = true;

	for(int i=0;i<xaxis.size();i++)
	{
		for(int j=0;j<=32000;j++)
		{
			if(dpx[i][j]==false)
			{
				continue;
			}

			if(j-xaxis[i]>=0)
			{
				dpx[i+1][j-xaxis[i]] = true;
			}
			if(j+xaxis[i]<=32000)
			{
				dpx[i+1][j+xaxis[i]] = true;
			}
		}
	}

	for(int i=0;i<yaxis.size();i++)
	{
		for(int j=0;j<=32000;j++)
		{
			if(dpy[i][j]==false)
			{
				continue;
			}

			if(j-yaxis[i]>=0)
			{
				dpy[i+1][j-yaxis[i]] = true;
			}
			if(j+yaxis[i]<=32000)
			{
				dpy[i+1][j+yaxis[i]] = true;
			}
		}
	}	


	if(dpx[xaxis.size()][gx+16000] && dpy[yaxis.size()][gy+16000])
	{
		cout << "Yes" << '\n';
	}
	else
	{
		cout << "No" << '\n';
	}

	return 0;	
}	

Measured memory_bytes: 500480
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int,int>PII;
int divisors[10000001];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        for(int j=i;j<=n;j+=i)
            divisors[j]++;
    //cout<<divisors[100]<<"\n";
    long long int sum=0;
    for(int i=1;i<=n;i++){
        long long int t1=divisors[i],t2=i,t3=t2*t1;
        sum+=t3;
    }
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 42840
import java.util.*;

public class Main {

    private static Map<Integer, Double> map = new HashMap<>();

    static {
        map.put(1, 2.0);
        map.put(2, 4.0);
        map.put(3, 8.0);
        map.put(4, 16.0);
        map.put(5, 32.0);
        map.put(6, 64.0);
        map.put(7, 128.0);
        map.put(8, 256.0);
        map.put(9, 512.0);
        map.put(10, 1024.0);
        map.put(11, 2048.0);
        map.put(12, 4096.0);
        map.put(13, 8192.0);
        map.put(14, 16384.0);
        map.put(15, 32768.0);
        map.put(16, 65536.0);
        map.put(17, 131072.0);
    }

    public static void main(String[] args) {
//        long startTime = System.currentTimeMillis();
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        scanner.close();

        double ans = 0.0;

        for (int a = 1; a <= N; a++) {
            int n = 0;
            int t = a;
            while (t < K) {
                n++;
                t *= 2;
            }
            if (n != 0) {
                ans += 1.0 / N * Math.pow(0.50, (double) n);
            } else {
                ans += 1.0 / N;
            }
        }

//        for (int a = 1; a <= N; a++) {
//            double c1 = (double) (a + K) / a;
//            System.out.println("c1:"+c1);
//            int mapIdx = 0;
//            for (int i = 1; i <= 16; i++) {
//                if (map.get(i) < c1) {
//                    continue;
//                } else {
//                    mapIdx = i;
//                    break;
//                }
//            }
//            System.out.println("mapIdx:"+mapIdx);
//            if (mapIdx != 0) {
//                ans += 1.0 / N * Math.pow(0.5, (double) mapIdx);
//            } else {
//                ans += 1.0 / N;
//            }
//        }

        System.out.println(ans);

//        System.out.println(System.currentTimeMillis() - startTime);
    }


}


Measured memory_bytes: 23124
def readinput():
    n,m,c=list(map(int,input().split()))
    b=list(map(int,input().split()))
    a=[]
    for _ in range(n):
        l=list(map(int,input().split()))
        a.append(l)
    return n,m,a,b,c

def main(n,m,a,b,c):
    seikai=0
    for i in range(n):
        sum=0
        for j in range(m):
            sum+=a[i][j]*b[j]
        sum+=c
        if sum > 0:
            seikai+=1
    return seikai

if __name__=='__main__':
    n,m,a,b,c=readinput()
    ans=main(n,m,a,b,c)
    print(ans)



Measured memory_bytes: 9156
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t x){
	if(was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}

struct vector3{
	double x;
	double y;
	double z;
	vector3(double a, double b, double c):x(a), y(b), z(c){}
	vector3(){}
	vector3 operator+(vector3 o){return vector3(x+o.x, y+o.y, z+o.z);}
	vector3 operator-(vector3 o){return vector3(x-o.x, y-o.y, z-o.z);}
	vector3 operator*(double o){return vector3(x*o, y*o, z*o);}
	vector3 operator/(double o){return vector3(x/o, y/o, z/o);}

	double magnitude(){return sqrt(x*x+y*y+z*z);}
};

double dot(vector3 a, vector3 b){return a.x * b.x + a.y * b.y + a.z * b.z;}

double getangle(vector3 a, vector3 b){
	a = a / a.magnitude();
	b = b / b.magnitude();
	return acos(dot(a, b));
}

int main(){
	int n, m;
	while(cin>>n&&n){
		vector<vector3> stars(n);
		foreach(i, stars){
			double x, y, z;
			cin >> x >> y >> z;
			i = vector3(x, y, z);
		}
		cin >> m;
		vector<vector3> scopes(m);
		vector<double> angle(m);
		rep(i, m){
			double a, b, c, d;
			cin >> a >> b >> c >> d;
			scopes[i] = vector3(a, b, c);
			angle[i] = d;
		}
		int ans = 0;
		foreach(i, stars){
			rep(j, m){
				double nangle = getangle(i, scopes[j]);
				if(nangle-angle[j]<1e-8){
					++ans;
					break;
				}
			}
		}

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





Measured memory_bytes: 3372
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  ll x, k;
  cin >> x >> k;
  if(x%k == 0){
    say(0)
    return 0;
  }else{
    x = x%k;
    if(abs(x - k) <= abs(x)){
      say(abs(x - k));
    }else{
      say(abs(x));
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
	string s,t;
	cin>>s;
	t=s;
	reverse(t.begin(),t.end());
	map<char,char> m;
	m['p']='q';
	m['q']='p';
	m['b']='d';
	m['d']='b';
	int siz=t.size();
	lol(i,siz){
		t[i]=m[t[i]];
	}
	cout<<(s==t?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 512
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
        PEOPLE'S LIVES DON'T END WHEN THEY DIE.
        IT ENDS WHEN THEY LOSE FAITH
                                     -ITACHI UCHIHA
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
  ll n,m,i,p,d,flg=0;cin>>n>>m;
  ll A[n];
  fo(i,0,n)A[i]=-1;
  
  if(m==0&&n==1){cout<<"0\n";return;}
  fo(i,0,m)
  {
    cin>>p>>d;
    if(A[p-1]==-1||A[p-1]==d)
    A[p-1]=d;
    else
    {flg=1;break;}
  }
  
  if(!flg)
  {
    if(n>1&&A[0]==0)flg=1;
    else
    {
       fo(i,0,n)
       {
          if(A[i]==-1)
          {
              if(i==0&&n>1)A[i]=1;
              else A[i]=0;
          }
       }
   }
   if(!flg)
   {fo(i,0,n)cout<<A[i];
   cout<<"\n";
   
   }
   else
  cout<<"-1\n";
  }
  else
  cout<<"-1\n";
}
int main()
{
   fastio
   solve();
  return 0;
}


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

void cal(string&prevS,string&nextS){
	int toUpper='A'-'a';
	for(int i=1;i<prevS.size();++i){
		if(prevS.at(i-1)==prevS.at(i)){
			prevS.at(i)+=toUpper;
		}
	}
	nextS.front()=prevS.back();
	return;
}

int count(string&S){
	int count=0;
	for(int i=1;i<S.size();++i){
		if(S.at(i)<'a')++count;
	}
	return count;
}

int main(){
	string S;
	int K;
	cin>>S>>K;
	string evenS='-'+S,oddS='-'+S;
	cal(S,evenS),cal(evenS,oddS),cal(oddS,evenS);
	int64_t first=count(S),even=count(evenS),odd=count(oddS);
	cout<<first+K/2*even+(K-1)/2*odd<<"\n"s;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt(), q = in.nextInt();
        RMinQ rMinQ = new RMinQ(n, Integer.MAX_VALUE);
        for (int i = 0; i < q; i++) {
            int cmd = in.nextInt(),
                    x = in.nextInt(),
                    y = in.nextInt();
            if (cmd == 0) {
                rMinQ.update(x, y);
            }else {
                System.out.println(rMinQ.find(x,y));
            }
        }
    }
}

// by heap DST
class RMinQ{
    int[] heap;
    int n;

    static int log2(int n) {
        int ret = 0, pow = 1;
        while (pow <= n-1) {
            pow = pow * 2;
            ret += 1;
        }
        return ret;
    }

    RMinQ(int n, int val) {
        // construct complelte binary heap
        this.n = n;
        int heapLen = (int) Math.pow(2, log2(n) + 1);
        heap = new int[heapLen];
        Arrays.fill(heap, val);
    }

    void update(int i, int val) {
        if (i >= n || i < 0) {
            return;
        }

        if (n <= 1) {
            heap[1] = val;
            return;
        }

        update(1, val, i, 0, n);
    }
    private int update(int iheap, int val, int i, int left, int right) {
        if (i < left || i >= right) {
            return heap[iheap];
        }
        if (right - left <= 1) {
            heap[iheap] = val;
            return val;
        }


        heap[iheap] = Math.min(
                update(iheap * 2, val, i, left, (left + right) / 2),
                update(iheap * 2 + 1, val, i, (left + right) / 2, right)
        );
        return heap[iheap];
    }

    int find(int s, int t) {
        int iheap = 1;
        return find(s, t+1, 0, n, iheap);
    }
    private int find(int s, int t, int left, int right, int iheap) {
        if (s >= t) {
            return Integer.MAX_VALUE;
        }
        if (left == s && right == t) {
            return heap[iheap];
        }

        int mid = (left + right) / 2;

        return Math.min(
                find(Math.max(s, left), Math.min(t, mid), left, mid, iheap * 2),
                find(Math.max(s, mid), Math.min(t, right), mid, right, iheap * 2 + 1)
        );
    }

}



Measured memory_bytes: 103972
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<stdio.h>
#define rep(i,n)for(int i=0;i<n;i++)
//printf("%.yf\n",x); xを小数点以下y桁で
using namespace std;
int main() {
    int x,y;
    cin >> x >> y;
    cout << x*y << " " << 2 * (x + y) << endl;
    return 0;
}



Measured memory_bytes: 3096
import sys
input = sys.stdin.readline
def main():
    A, B, C = map(int, input().split())
    K = int(input())
    for i in range(1,K+1):
        if A < B:
            i -= 1
            break
        B *= 2
    K -= i
    for i in range(1,K+1):
        if B < C:
            break
        C *= 2
    if A < B and B < C:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9200
#include<cctype>
#include<string>
#include<iostream>

using namespace std;

int main(){
	string ciph;

	while(getline(cin,ciph)){
		int len=ciph.length();
		bool match=false;
		for(int i=0;i<26;i++){
			for(int j=0;j<len;j++){
				if(islower(ciph[j])){
					ciph[j]++;
					if(ciph[j]>'z')	ciph[j]-=26;
				}
			}

			for(int j=0;j<len-2;j++){
				if(ciph.substr(j,3)=="the"
				&& !islower(ciph[j+3])
				&& (j==0 || !islower(ciph[j-1]))){
					match=true;
				}
			}
			if(match)	break;

			for(int j=0;j<len-3;j++){
				if(ciph.substr(j,4)=="this"
				&& !islower(ciph[j+4])
				&& (j==0 || !islower(ciph[j-1]))){
					match=true;
				}
			}
			if(match)	break;

			for(int j=0;j<len-3;j++){
				if(ciph.substr(j,4)=="that"
				&& !islower(ciph[j+4])
				&& (j==0 || !islower(ciph[j-1]))){
					match=true;
				}
			}
			if(match)	break;
		}
		cout<<ciph<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int x, y, a, b, c;
    std::cin >> x >> y >> a >> b >> c;
    std::vector<i64> p(a), q(b), r(c);
    for (auto &e : p) std::cin >> e;
    for (auto &e : q) std::cin >> e;
    for (auto &e : r) std::cin >> e;

    std::nth_element(p.begin(), p.begin() + x, p.end(), std::greater<>());
    std::nth_element(q.begin(), q.begin() + y, q.end(), std::greater<>());

    r.insert(r.end(), p.begin(), p.begin() + x);
    r.insert(r.end(), q.begin(), q.begin() + y);

    std::nth_element(r.begin(), r.begin() + x + y, r.end(), std::greater<>());

    const i64 ret = std::accumulate(r.begin(), r.begin() + x + y, 0ll);
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 6128
#include <iostream>
using namespace std;
int main(void){
   
    int i,j,num,n,m,d,length;
    char k;
    int kaijou[100][100];
    num = 0;
    cin>>n>>m>>d;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            cin>>k;
            if(k=='#')
            kaijou[i][j]=0;
            else
            kaijou[i][j]=1;
        }
    }
    for(i=0;i<n;i++)
    {
        length = 1;
        for(j=0;j<m;j++)
        {
            
            if(kaijou[i][j]==1)
            {
                length++;
                if(j==m-1)
                {
                    if(length>d)
                    num = num + length - d;
                }
                
            }
            else if(length>d)
            {
                   num = num + length - d;
                   length = 1;
            }
            else 
            length = 1;
            
         
        }
    }
    for(i=0;i<m;i++)
    {
        length = 1;
        for(j=0;j<n;j++)
        {
            
            if(kaijou[j][i]==1)
            {
                length++;
                if(j==n-1)
                {
                    if(length>d)
                    num = num + length - d;
                }
                
            }
            else if(length>d)
            {
                   num = num + length - d;
                   length = 1;
            }
            else 
            length = 1;
            
         
        }
    }
    cout<<num<<endl;
    return 0;
    
}



Measured memory_bytes: 3160
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int[] A={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        
        int k=sc.nextInt();
        
        System.out.println(A[k-1]);
    }
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<long long> A(N);
	for (long long i = 0; i < N; i++) {
		cin >> A[i];
	}
	vector<long long> cnt(N + 1, 0);
	for (long long i = 0; i < N; i++) {
		cnt[A[i]]++;
	}
	long long sum = 0;
	for (long long i = 0; i < N + 1; i++) {
		if (cnt[i] >= 2) {
			sum += cnt[i] * (cnt[i] - 1) / 2;
		}                 
	}
	//cerr << sum << endl;
	for (long long k = 0; k < N; k++) {
		cout << sum - (cnt[A[k]] - 1) << endl;
	}
	return 0;
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    // Fast_IO();
    ll n, m; cin >> n >> m;
    ll a[n]; f(i,0,n-1) cin >> a[i];
    vector < vector<ll> > adj;
    adj.resize(n);
    f(_,1,m) {
        ll u, v; cin >> u >> v;
        u--; v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    ll ans = 0;
    f(i,0,n-1) {
        ll flag = 1;
        f(j,0,sz(adj[i])-1) {
            ll v = adj[i][j];
            if(a[v] >= a[i]) flag = 0;
        }
        if(flag) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 9856
from sys import stdin
import math
from collections import deque

EPS = 1e-10

class Vector:
    def __init__(self, x=None, y=None):
        self.x = x
        self.y = y

    def __add__(self, other):
        return Vector(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vector(self.x - other.x, self.y - other.y)

    # can't  apply "number * Vector" but "Vector * number"
    def __mul__(self, k):
        return Vector(self.x * k, self.y * k)

    def __truediv__(self, k):
        return Vector(self.x / k, self.y / k)

    def __gt__(self, other):
        return self.x > other.x and self.y > other.yb

    def __lt__(self, other):
        return self.x < other.x and self.y < other.yb

    def __eq__(self, other):
        return self.x == other.x and self.y == other.y

    def dot(self, other):
        return self.x * other.x + self.y * other.y

    # usually cross operation return Vector but it returns scalor
    def cross(self, other):
        return self.x * other.y - self.y * other.x

    def norm(self):
        return self.x * self.x + self.y * self.y

    def abs(self):
        return math.sqrt(self.norm())

    def rotate(self, theta):
        return Vector(self.x * math.cos(theta)
                               - self.y * math.sin(theta),
                               self.x * math.sin(theta)
                               + self.y * math.cos(theta))

class Point(Vector):
    def __init__(self, *args, **kargs):
        return super().__init__(*args, **kargs)

class Segment:
    def __init__(self, p1=Point(0, 0), p2=Point(1, 1)):
        self.p1 = p1
        self.p2 = p2

class Line(Segment):
    def __init__(self, *args, **kargs):
        return super().__init__(*args, **kargs)

def ccw(p0, p1, p2):
    a = p1 - p0
    b = p2 - p0
    if a.cross(b) > EPS:
        return 1
    elif a.cross(b) < -EPS:
        return -1
    elif a.dot(b) < -EPS:
        return 2
    elif a.norm() < b.norm():
        return -2
    else:
        return 0

def convex_hull(P):
    n = len(P)
    A = sorted(P, key=lambda p: (p.x, p.y))
    U = deque([])
    L = deque([])
    for i in range(n):
        if i < 2:
            U.append(A[i])
        else:
            while ccw(U[-2], U[-1], A[i]) == 1:
                U.pop()
                if len(U) == 1:
                    break
            U.append(A[i])

    for i in range(n-1, -1, -1):
        if i > n-3:
            L.append(A[i])
        else:
            while ccw(L[-2], L[-1], A[i]) == 1:
                L.pop()
                if len(L) == 1:
                    break
            L.append(A[i])

    U.pop()
    U.popleft()
    return U + L

def read_polygon(n):
    P = []
    for _ in range(n):
        line = stdin.readline().strip().split()
        p = Vector(int(line[0]), int(line[1]))
        P.append(p)
    return P

def __main():
    n = int(input())
    P = read_polygon(n)
    P_rev = convex_hull(P)
    while min(P_rev, key=lambda p: (p.y, p.x)) != P_rev[-1]:
        P_rev.appendleft(P_rev.pop())
    print(len(P_rev))
    for i in reversed(P_rev):
        print("{0} {1}".format(i.x, i.y))

if __name__ == '__main__':
    __main()


Measured memory_bytes: 38352
// clang-format off
#include <bits/stdc++.h>

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

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T>& p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T>& vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
constexpr ll MOD = 1000000007;



int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    int cnt = 1;
    bool rising = false;
    bool start = false;
    cin >> A[0];
    for(int i = 1; i < N; i++){
        cin >> A[i];
        if(start){
            if(rising and A[i] < A[i-1]){
                cnt++;
                start = false;
            } else if ((not rising) and A[i] > A[i-1]){
                cnt++;
                start = false;
            }
        } else {
            if(A[i-1] < A[i]){
                start = true;
                rising = true;
            } else if(A[i-1]>A[i]){
                start = true;
                rising = false;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
S = int(input())
a = int(S / 100)
b = S - a*100
if a <=12 and b <= 12 and a > 0 and b > 0:
    print("AMBIGUOUS")
elif a <= 12 and a > 0:
    print("MMYY")
elif b<= 12 and b > 0:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int m, k;
    cin >> m >> k;
    int cand = pow(2, m) - 1;
    if(k > cand)
    {
        cout << -1 << endl;
        return 0;
    }
    if(k == 0)
    {
        for(int i = 0; i <= cand; i++)
        {
            cout << i << " " << i << " ";
        }
        return 0;
    }
    if(m == 1 && k == 1)
    {
      cout << -1 << endl;
      return 0;
    }

    cout << "0 " << k << " 0 ";
    for(int i = 1; i <= k-1; i++)
    {
        cout << i << " ";
    }
    for(int i = k+1; i <= cand; i++)
    {
        cout << i << " ";
    }
    cout << k << " ";
    for(int i = cand; i >= k+1; i--)
    {
        cout << i << " ";
    }
    for(int i = k-1; i >= 1; i--)
    {
        cout << i << " ";
    }
}



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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main(){
	int n;
	string s;
	cin>>n>>s;

	for (int i = 0; i < s.size(); i++){
		if(s[i]+n>'Z'){
			s[i]='A'+s[i]+n-'Z'-1;
		}else{
			s[i]+=n;
		}
	}

	cout<<s<<endl;

	return 0;
}

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

int main() {
  int N;
  cin>>N;
  int dt=0,dx=0,dy=0;
  bool f=true;
  for (int i=0; i<N; i++) {
    int t,x,y;
    cin>>t>>x>>y;
    dt=abs(t-dt),dx=abs(x-dx),dy=abs(y-dy);
    if (dt<dx+dy || (abs(dx+dy-dt))%2!=0) {
      f=false;
    }
  }
  cout<<(f?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256