akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define REP(i, a) for (ll i(0), _##i(a); i < _##i; ++i)
#define FOR(i, a, b) for (ll i(a), _##i(b); i <= _##i; ++i)

#ifdef LOCAL
#define _NTH_ARG(_1, _2, _3, _4, _5, _6, N, ...) N
#define _FE_1(_CALL, x) _CALL(x)
#define _FE_2(_CALL, x, ...) _CALL(x) _FE_1(_CALL, __VA_ARGS__)
#define _FE_3(_CALL, x, ...) _CALL(x) _FE_2(_CALL, __VA_ARGS__)
#define _FE_4(_CALL, x, ...) _CALL(x) _FE_3(_CALL, __VA_ARGS__)
#define _FE_5(_CALL, x, ...) _CALL(x) _FE_4(_CALL, __VA_ARGS__)
#define _FE_6(_CALL, x, ...) _CALL(x) _FE_5(_CALL, __VA_ARGS__)
#define FOR_EACH_MACRO(MACRO, ...)                                             \
  _NTH_ARG(__VA_ARGS__, _FE_6, _FE_5, _FE_4, _FE_3, _FE_2, _FE_1)              \
  (MACRO, __VA_ARGS__)
#define watch(x) cerr << "\033[1;32m" #x " = \033[1;34m" << (x) << "\033[0m; ";
#define debug(...)                                                             \
  cerr << "\033[2;31mLine " << __LINE__ << ": \033[0;m";                       \
  FOR_EACH_MACRO(watch, __VA_ARGS__)                                           \
  cerr << endl
#else
#define debug(...)
#endif

using namespace std;

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  return os << '{' << p.first << ", " << p.second << '}';
}

template <class T, class = decltype(begin(declval<T>())),
          class = enable_if_t<!is_same<T, string>::value>>
ostream &operator<<(ostream &os, const T &c) {
  os << '[';
  for (auto it = begin(c); it != end(c); ++it)
    os << (it == begin(c) ? "" : ", ") << *it;
  return os << ']';
}
using ll = long long;

void solve() {
  ll n, w;
  cin >> n >> w;
  vector<pair<ll,ll>> a(n);
  for(auto &p : a){
    cin >> p.F >> p.S;
  }
  const ll MAX_SUM = 1e5;
  const ll INF = 1ll << 60;
  const ll UNDEFINED = 1ll << 61;
  vector<vector<ll>> dp(n + 1, vector<ll>(MAX_SUM + 1, UNDEFINED));

  function<ll(ll, ll)> bt = [&](ll i, ll sum){
    if (sum <= 0) return 0ll;
    if (i == n) return INF;
    ll &res = dp[i][sum];
    if (res != UNDEFINED) return res;
    res = min(bt(i + 1, sum), a[i].F + bt(i + 1, sum - a[i].S));
    return res;
  };
  ll ans = 0;
  
  for(ll i = MAX_SUM; i >= 0; --i) {
    if (bt(0, i) <= w){
      ans = i;
      break;
    }
  }
  cout << ans << "\n";
}

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

  int T = 1;
  // cin >> T;
  while (T--) {
    solve();
  }
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    string S, T;
    cin >> S >> T;
    T.pop_back();
    if (S == T) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


Measured memory_bytes: 3628
#include <stdio.h>

int H[100000];
int n, a, b;

int check(long long int t){
  int i;
  long long int tt = 0;
  for(i=0;i<n;i++){
    if(H[i] > (long long) t * b){
      tt += (H[i] - (long long) t * b + a - b - 1) / (a-b);
      if(tt > t) return 0;
    }
  }
  return 1;
}

int main(){
  int i;
  long long sum = 0;
  long long l, r;
  scanf("%d%d%d", &n, &a, &b);
  for(i=0;i<n;i++){
    scanf("%d", H+i);
    sum += H[i];
  }
  l = 0; r = 1+sum/b;
  while(l<r){
    long long m = (l+r)/2;
    if(check(m)) r = m;
    else l = m+1;
  }
  printf("%lld\n", l);

  return 0;
}


Measured memory_bytes: 512
import java.util.HashSet;
import java.util.Scanner;

public class Main{

	int N;
	String[][] strs;
	HashSet<String> visited, groupName, memberName;

	void run(){
		Scanner in = new Scanner(System.in);
		for(;;){
			N = in.nextInt();
			if(N==0) return ;
			strs = new String[N][];
			for(int i=0;i<N; i++){
				String line = in.next();
				strs[i] = line.replace(".","").split("[:,]");
			}
			visited = new  HashSet<String>();
			groupName = new HashSet<String>();
			memberName = new HashSet<String>();
			System.out.println(solve());
		}
	}

	void dfs(String str){
		visited.add(str);
		if(groupName.contains(str)){
			for(int i=0; i<N; i++){
				if(strs[i][0].equals(str)){
					for(int j=1; j<strs[i].length; j++)if(!visited.contains(strs[i][j])){
						dfs(strs[i][j]);
					}
					return ;
				}
			}
		}
		else{
			memberName.add(str);
		}
	}

	int solve(){
		for(int i=0; i<N; i++){
			groupName.add(strs[i][0]);
		}
		dfs(strs[0][0]);
		return memberName.size();
	}

	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 39548
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int n, k, q;
int a[2020];
vector<int>v;
int main() {
	cin >> n >> k >> q;
	REP(i, n) {
		cin >> a[i];
		v.emplace_back(a[i]);
	}
	sort(ALL(v));
	int ans = INF<int>();
	REP(i, n) {
		int x = v[i];
		vector<int> vec;
		vector<int> num;
		REP(j, n) {
			if (a[j] < x) {
				sort(ALL(vec));
				if (vec.size() >= k) {
					REP(l, vec.size() - k + 1) {
						num.emplace_back(vec[l]);
					}
				}
				vec.clear();
			}
			else {
				vec.emplace_back(a[j]);
			}
		}
		sort(ALL(vec));
		if (vec.size() >= k) {
			REP(l, vec.size() - k + 1) {
				num.emplace_back(vec[l]);
			}
		}
		vec.clear();
		sort(ALL(num));
		if (num.size() < q)continue;
		int y = num[q - 1];
		ans = min(ans, y - x);
	}
	cout << ans << endl;
}

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

vector<vector<int>> to;
vector<int> cnt;

void dfs(int s, int t) {
	for (int p: to[t]) {
		if (p == s) continue;
		cnt[p] += cnt[t];
		dfs(t, p);
	}
}

void solve() {
	int n, q;
	cin >> n >> q;
	to.resize(n);
	cnt.resize(n);
	rep(i,n-1) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	rep(i,q) {
		int p, x;
		cin >> p >> x;
		p--;
		cnt[p] += x;
	}
	dfs(-1, 0);
	rep(i,n) cout << cnt[i] << " ";
	cout << endl;
}

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

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

using namespace std;
typedef long long ll;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int N;
    ll K;
    cin >> N >> K;
    ll A[100001];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    bitset<60> master;
    bitset<60> B;
    bitset<60> temp_bit;
    master = K;
    ll out = 0;
    int memo[60];
    for (int i = 0; i < 60; i++)
    {
        memo[i] = -1;
    }
    for (int idx = 59; idx >= 0; idx--)
    {
        if (master[idx] == 0)
        {
            continue;
        }
        B = master;
        B[idx] = 0;
        for (int bit_cnt = 0; bit_cnt < idx; bit_cnt++)
        {
            int cnt = 0;
            if (memo[bit_cnt] != -1)
            {
                cnt = memo[bit_cnt];
            }
            else
            {
                for (int i = 0; i < N; i++)
                {
                    temp_bit = A[i];
                    if (temp_bit[bit_cnt] == 1)
                    {
                        cnt++;
                    }
                }
                memo[bit_cnt] = cnt;
            }
            if (cnt > (N - cnt))
            {
                B[bit_cnt] = 0;
            }
            else
            {
                B[bit_cnt] = 1;
            }
        }
        ll X = ll(B.to_ullong());
        ll temp = 0;
        for (int i = 0; i < N; i++)
        {
            temp += ll(A[i] ^ X);
        }
        chmax(out, temp);
    }
    ll X = K;
    ll temp = 0;
    for (int i = 0; i < N; i++)
    {
        temp += ll(A[i] ^ X);
    }
    chmax(out, temp);
    if (K == 0)
    {
        ll X = 0;
        ll temp = 0;
        for (int i = 0; i < N; i++)
        {
            temp += ll(A[i] ^ X);
        }
        out = temp;
    }
    cout << out;
    //system("pause");
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

const int dir[][2] = {
	1, 0,
	0, 1,
	-1, 0,
	0, -1
};

int comp( VI &x1, VI &x2, int W )
{
	const int N = x1.size();

	VI xs;

	REP( i, 0, N )
	{
		REP( j, -1, 2 )
		{
			int tmp1 = x1[i] + j, tmp2 = x2[i] + j;

			if ( 0 <= tmp1 && tmp1 <= W )
			{
				xs.PB( tmp1 );
			}

			if ( 0 <= tmp2 && tmp2 <= W )
			{
				xs.PB( tmp2 );
			}
		}
	}

	sort( ALL( xs ) );
	xs.erase( unique( ALL( xs ) ), xs.end() );

	REP( i, 0, N )
	{
		x1[i] = lower_bound( ALL( xs ), x1[i] ) - xs.begin();
		x2[i] = lower_bound( ALL( xs ), x2[i] ) - xs.begin();
	}

	return xs.size() - 1;
}

void paint( VVI &board, int x1, int y1, int x2, int y2 )
{
	REP( i, y1, y2 )
	{
		REP( j, x1, x2 )
		{
			board[i][j] = 1;
		}
	}

	return;
}

void bfs( VVI &board, int y, int x )
{
	const int H = board.size(), W = board[0].size();

	queue< PII > que;
	que.push( MP( y, x ) );

	while ( !que.empty() )
	{
		auto cur = que.front();
		que.pop();

		if ( board[ cur.fst ][ cur.snd ] )
		{
			continue;
		}

		board[ cur.fst ][ cur.snd ] = 1;

		REP( d, 0, 4 )
		{
			auto next = cur;

			next.fst += dir[d][0];
			next.snd += dir[d][1];

			if ( !( 0 <= next.fst && next.fst < H && 0 <= next.snd && next.snd < W ) )
			{
				continue;
			}

			que.push( next );
		}
	}

	return;
}

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

	while ( true )
	{
		int w, h;
		cin >> w >> h;

		if ( !( w | h ) )
		{
			break;
		}

		int n;
		cin >> n;

		VI x1( n ), y1( n ), x2( n ), y2( n );

		REP( i, 0, n )
		{
			cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
		}

		const int W = comp( x1, x2, w ), H = comp( y1, y2, h );

		VVI board( H, VI( W, 0 ) );

		REP( i, 0, n )
		{
			paint( board, x1[i], y1[i], x2[i], y2[i] );
		}

		int res = 0;

		REP( i, 0, H )
		{
			REP( j, 0, W )
			{
				if ( board[i][j] )
				{
					continue;
				}

				res++;

				bfs( board, i, j );
			}
		}

		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 8216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

int main() {
  int N; cin >> N;
  vector<tuple<ll, ll, ll> > v(N);
  rep(i, N) {
    ll a, b, sum;
    cin >> a >> b;
    sum = a + b;
    v[i] = make_tuple(sum, a, b);
  }

  sort(all(v));
  reverse(all(v));

  ll ans = 0LL;
  rep(i, N) {
    if ((i%2) == 0) {
      ans += get<1>(v[i]);
    } else {
      ans -= get<2>(v[i]);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
    int k,n;
    cin >> k>>n;
    int a[n];
    rep(i,n){
        cin >> a[i];
    }
    int temp=0;
    rep(i,n-1){
        temp=max(temp,abs(a[i+1]-a[i]));
    }
    temp=max(temp,abs(k-a[n-1])+a[0]);
    cout<<k-temp<<endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if(A==7){
    if(B==5){
      if(C==5){
        cout << "YES" << endl;
      }else{
        cout << "NO" << endl;
      }
    }else{
        cout << "NO" << endl;
    }
  }else if(A==5){
    if(B==7){
      if(C==5){
        cout << "YES" << endl;
      }else{
        cout << "NO" << endl;
      }
    }else if(A!=5){
        cout << "NO" << endl;
    }
    if(B==5){
      if(C==7){
        cout << "YES" << endl;
      }else{
        cout << "NO" << endl;
      }
    }else if(B!=7){
        cout << "NO" << endl;
    }
  }else{
    cout << "NO" << endl;
  }      
}

Measured memory_bytes: 256
import itertools
import math
N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]
distance = 0
pt = list(itertools.permutations(xy, N))
bunbo = len(pt)

for i in pt:
    for j in range(N-1):
        distance += math.sqrt((i[j][0] - i[j+1][0])**2 + (i[j][1] - i[j+1][1])**2)


print(distance/bunbo)

Measured memory_bytes: 13848
import math

zisin,tansin,hour,mini=map(float,input().split())
tankaku = math.radians(6*mini)
zikaku = math.radians(30*hour + 0.5*mini)

print(math.sqrt(zisin**2 + tansin**2 - 2*zisin*tansin*math.cos(tankaku-zikaku)))


Measured memory_bytes: 9412
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	/**
	 * @param args
	 */
	static int[] score;
	static int number;
	public static void main(String[] args) {
		// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
		while(read()){
			slove();
		}
	}
	static boolean read(){
		number = sc.nextInt();
		if(number == 0)
			return false;
		
		score = new int[number];
		for(int i = 0; i < number; i++){
			score[i] = sc.nextInt();
		}
		return true;
	}
	static void slove(){
		java.util.Arrays.sort(score);
		int sum = 0;
		for(int i = 1; i < number-1; i++){
			sum = sum + score[i];
		}
		System.out.println(sum/(number-2));
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<bitset>
int main()
{
	std::bitset<10000>o[10];
	int R,C,i,j,k,x,r,s;
	while(scanf("%d%d",&R,&C),R)
	{
		for(i=0;i<R;++i)for(j=0;j<C;++j)scanf("%d",&x),o[i][j]=x;
		for(i=r=0;i<1024;++i)
		{
			for(j=0;j<R;++j)(i&(1<<j)?o[j].flip():o[j]);
			for(s=j=0;j<C;++j)
			{
				for(x=k=0;k<R;++k)x+=o[k][j];
				s+=(x>R-x?x:R-x);
			}
			r=(r>s?r:s);
			for(j=0;j<R;++j)(i&(1<<j)?o[j].flip():o[j]);
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 776
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
}

Measured memory_bytes: 256
//counting.cpp
#include<iostream>
#include<string>
using namespace std;

int main()
{
    string s;
    char t;
    int n,i,ans[26],flag;
    for ( i = 0; i < 26; i++) ans[i]=0;
    flag=0;
    while (flag==0)
    {
        getline(std::cin, s);
        n=(int)(s.length());
        if (n>0)
        {
                for ( i = 0; i < n; i++)
            {
                if (s[i]>='A' && s[i]<='Z') ans[s[i]-'A']+=1;
                else if (s[i]>='a' && s[i]<='z') ans[s[i]-'a']+=1;
            }
        }
        else flag=1;
    }
    t='a';
    for ( i = 0; i < 26; i++) 
    {
        cout<<t<<" : "<<ans[i]<<endl;
        t+=1;
    }
}


Measured memory_bytes: 3156
#include<stdio.h>
int main()
{
	int a,b,x,y,z;
	scanf("%d%d",&a,&b);
	
	x=a+b;
	y=a-b;
	z=a*b;
	
	if(x>=y){
		if(x>=z) printf("%d\n",x);
        else printf("%d\n",z);
	}
	
	else{
	    if(y>=z) printf("%d\n",y);
        else printf("%d\n",z);
	}
 
	return 0;
}

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

long long n, m;
vector<long long> a;
priority_queue<long long> pq;

long long solve();

int main() {
  cin >> n >> m;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  cout << solve() << endl;
  return 0;
}
long long solve() {
  long long ans = 0;
  sort(a.begin(), a.end());
  for(int i = 0; i < n; ++i) pq.push(a[i]);
  for(int i = 0; i < m; ++i) {
    long long now = pq.top();
    pq.pop();
    now /= 2;
    pq.push(now);
  }
  while(pq.size() > 0) {
    ans += pq.top();
    pq.pop();
  }
  return ans;
}

Measured memory_bytes: 2168
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
typedef vector<int> vi;

int main(void){
	int n,m,l;
	cin >> n;
	cin >> m;
	cin >> l;
	cout << (n-l)/(m+l) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int s=0;
		
		String str=sc.next();
		char[] c=str.toCharArray();
		for(int i=0;i<4;i++){
			if(c[i]=='+'){
				s++;
			}else if(c[i]=='-'){
				s--;
			}
		}
		System.out.println(s);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;

int main() {
	int a;
	string s;
	cin >> a >> s;
	
	if(a>=3200) cout << s << endl;
	else cout << "red" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>

using namespace std;

bool comp(const pair<int, int>& l, const pair<int, int>& r){
    return l.second < r.second;
}

int main(){
    int n;
    cin >> n;
    int ans[2] = {n / 2, n / 2};
    vector<int> input;
    map<int, int> cnt[2];
    for(int i = 0; i < n; i++){
        int num;
        cin >> num;
        input.push_back(num);
        cnt[i % 2][num]++;
    }
    auto cnt0 = max_element(begin(cnt[0]), end(cnt[0]), comp);
    auto cnt1 = max_element(begin(cnt[1]), end(cnt[1]), comp);
    ans[0] = n / 2 - cnt0->second;
    ans[1] = n / 2 - cnt1->second;
    int first = cnt0->first;
    int second = cnt1->first;
    if(first == second){
        cnt[0][first] = 0;
        cnt[1][second] = 0;
        int check0 = n / 2 - (max_element(begin(cnt[0]), end(cnt[0]), comp)->second);
        int check1 = n / 2 - (max_element(begin(cnt[1]), end(cnt[1]), comp)->second);
        cout << min(ans[0] + check1, ans[1] + check0) << "\n";
        return 0;
    }
    cout << ans[0] + ans[1] << "\n";
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, k, l[50], s;

int main() {
	cin >> n >> k;
	rep(i,n) cin >> l[i];
	sort(l, l+n);
	rep(i,k) s += l[n-1-i];
	cout << s << ln;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int digit(int a){
    int resto,div,sum=0;
    while(1){
        resto=a%10;
    div=a/10;
    sum=sum+resto;
    a=div;
    if(a==0)break;
    }
    return sum;
 
}
main()
{
    int n,i=1,sum=0,min=1000000,a,b;
    cin >> n;
    while(i<n){
    a=i;
    b=n-i;
 
    sum=digit(a)+digit(b);
    if(sum<min)min=sum;
    i++;
 
 
    }
    cout << min << endl;
    return 0;
}

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

int main(void){
  int N,Q,num[100005],l[100005],r[100005],x[100005],i,j;
  char str[100005],*p,s[100005];
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  N=atoi(p);
  p=strtok(NULL," \n");
  Q=atoi(p);
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  strcpy(s,p);
  
  for(i=0;i<Q;i++){
    fgets(str,sizeof(str),stdin);
  	p=strtok(str," \n");
  	l[i]=atoi(p);
  	p=strtok(NULL," \n");
  	r[i]=atoi(p);
  }
  
  for(i=1,num[0]=0;i<N;i++){
    if(s[i-1]=='A' && s[i]=='C'){
      num[i]=num[i-1]+1;
    }else{
      num[i]=num[i-1];
    }
  }
  
  for(i=0;i<Q;i++){
    x[i]=num[r[i]-1]-num[l[i]-1];
    printf("%d\n",x[i]);
  }
  
  return 0;
}

Measured memory_bytes: 2176
def minfunc(i,s,cost,p):
  iter=0
  k=i-1
  mini=abs(s[i]-s[i-1])+cost[i-1]
  while(k>=0 and iter<p):
    if abs(s[i]-s[k])+cost[k]<mini:
      mini=abs(s[i]-s[k])+cost[k]
    k=k-1
    iter=iter+1
  return mini
    
    


l=list(map(int,input().split()))
n=l[0]
p=l[1]
s=list(map(int,input().split()))
cost=[0]*n
cost[1]=abs(s[1]-s[0])
if n==2:
  
  print(abs(s[1]-s[0]))
  
else:
  for i in range(2,len(s)):
  	cost[i]=minfunc(i,s,cost,p)
  print(cost[n-1])


Measured memory_bytes: 52832
S = input()
o, x = 0, 0
for i in range(len(S)):
  if S[i] == 'o':
    o += 1
  elif S[i] == 'x':
    x += 1
if 15 - len(S) + o >= 8:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>

using namespace std;

#define EXIST '1'
#define NONE '0'

typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<VVS> VVVS;
typedef vector<int> VI;
typedef vector<VI> VVI;

bool check(int x, int y, int z){
	if(x>=5||x<0)return false;
	if(y>=5||y<0)return false;
	if(z>=5||z<0)return false;
	return true;
}

int main(){
	int t = 1;
	while (1){
		int N,M;
		cin >> N;
		if (N == 0)return 0;
		if (t>=2)cout << endl;
		VVVS box(N+1,VVS(5, VS(5,"00000")));

		for (int z = 0; z < 5; z++){
			for (int x = 0; x < 5; x++){
				cin >> box[0][z][x];
			}
		}
		VVI pt(100, VI(27,NONE));
		cin >> M;
		for (int i = 0; i < M; i++){
			int t; cin >> t;
			pt[NONE][t] = EXIST;
		}
		cin >> M;
		for (int i = 0; i < M; i++){
			int t; cin >> t;
			pt[EXIST][t] = EXIST;
		}

		for (int i = 0; i < N; i++){
			for (int z = 0; z < 5; z++)
			for (int x = 0; x < 5; x++)
			for (int y = 0; y < 5; y++){
				int cnt = 0;
				for (int dz = -1; dz <= 1; dz++)
				for (int dx = -1; dx <= 1; dx++)
				for (int dy = -1; dy <= 1; dy++){
					if (dx == 0 && dy == 0 && dz == 0)continue;
					int xx = x + dx;
					int yy = y + dy;
					int zz = z + dz;
					if (check(xx, yy, zz))
					cnt += (box[i][zz][xx][yy] == EXIST);
				}

				box[i + 1][z][x][y] = pt[box[i][z][x][y]][cnt];
			}
		}

		cout << "Case " << t << ":" << endl;
		t++;
		for (int z = 0; z < 5; z++){
			for (int x = 0; x < 5; x++)
				cout << box[N][z][x] << endl;
			if (z != 4)cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define PI 3.14159265359
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<int> Eratosthenes(const int N)
{
    vector<bool> is_prime(N+1, true);
    vector<int> P;
    for(int i=2; i<=N; i++) {
        if (is_prime[i]) {
            for(int j=2*i; j<=N; j+=i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,m;
    cin >> a >> b >> m;
    vector<int> A(a);
    vector<int> B(b);
    rep(i,a) {
        cin >> A[i];
    }
    rep(i,b) {
        cin >> B[i];
    }
    int total = *min_element(all(A))+*min_element(all(B));
    int x,y,c;
    rep(i,m) {
        int _total = 0;
        cin >> x >> y >> c;
        _total = A[x-1] + B[y-1] -c;
        total = min(total,_total);
    }
    cout << total << "\n";
} 

Measured memory_bytes: 1024
k = int(input())
a = list(map(int,input().split()))
def g(x):
    for i in range(k):
        x = (x//a[i])*a[i]
    return x
#最小値を求める
l,r = 0,2+k*max(a)
while abs(r-l) > 1:
    mid = (l+r)//2
    if g(mid) >=2:
        r = mid
    else:
        l = mid
m = r
#最大値を求める
l,r = 0,2+k*max(a)
while abs(r-l) > 1:
    mid = (l+r)//2
    if g(mid) <= 2:
        l = mid
    else:
        r = mid
M = l
if m <= M:
    print(m,M)
else:
    print(-1)

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

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> as(n), bs(n);
	for (int64_t i = 0; i < n; i++)
	{
		cin >> as[i] >> bs[i];
	}

	vector<pair<int64_t, int64_t>> ps(n);
	for (int64_t i = 0; i < n; i++)
	{
		ps[i] = {as[i], bs[i]};
	}

	sort(ps.begin(), ps.end(), [](auto &p, auto &q) {
		return (p.second == q.second) ? (p.first < q.first) : (p.second < q.second);
	});

	for (int64_t i = 0, now = 0; i < n; i++)
	{
		if (ps[i].second - ps[i].first < now)
		{
			cout << "No" << endl;
			return 0;
		}
		now = min(now + ps[i].first, ps[i].second);
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 6528
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 62;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int ser(Int n, Int k, const vector<Int> &p, const vector<Int> &c, Int index) {
    Int cycle_size = 0;
    Int cycle_score = 0;

    Int i = index;
    Int ma = -INF;
    while (true) {
        cycle_size++;
        i = p[i];
        cycle_score += c[i];
        if (cycle_size <= k) {
            ma = max(ma, cycle_score);
        }
        if (i == index) {
            break;
        }
    }

    if (cycle_score <= 0) {
        return ma;
    } else {
        Int ret = (k / cycle_size - 1) * cycle_score;
        Int tem = ret;
        i = index;
        ma = -INF;
        Int ro = cycle_size + (k % cycle_size);
        for (Int j = 0; j < ro; j++) {
            i = p[i];
            tem += c[i];
            ret = max(ret, tem);
        }

        return ret;
    }
}

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

    Int n, k;
    cin >> n >> k;
    vector<Int> p(n), c(n);
    for (Int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }
    for (Int i = 0; i < n; i++) {
        cin >> c[i];
    }

    Int ans = -INF;
    for (Int i = 0; i < n; i++) {
        ans = max(ans, ser(n, k, p, c, i));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3732
x = list(map(int,input().split()))
point = 0
def count(x,point):
    if x[0]%2 == 1 or x[1]%2 == 1 or x[2]%2 == 1:
        return(point)
    else:
        point += 1
        x = [(x[0]+x[1])/2,(x[0]+x[2])/2, (x[1]+x[2])/2]
        return(count(x,point))

if x[0] == x[1] == x[2] and x[0]%2==0:
    print(-1)
else:
    print(count(x,point))

Measured memory_bytes: 38256
#include <stdio.h>
#include <string.h>
char sig[3]={'-','+','*'};
char g[50],a[50],b[50],c[50],d[50];
char* sign(char *x,char *y,int c){
	if(c<3)sprintf(g,"(%s %c %s)",x,sig[c%3],y);
	else sprintf(g,"(%s %c %s)",y,sig[c%3],x);
	return g;
}
int calc(int x,int y,int c){
	switch(c){
	case 0:return x-y;
	case 1:return x+y;
	case 2:return x*y;
	case 3:return y-x;
	}
	return 0;
}
int check(char *a,char *b,char *c,char *d,int o){
	int i,j,k;
	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			for(k=0;k<3;k++){
				if(o){
					if(calc(calc(a[0]-'0',b[0]-'0',i),calc(c[0]-'0',d[0]-'0',j),k)==10){
						strcpy(a,sign(a,b,i));
						strcpy(c,sign(c,d,j));
						strcpy(a,sign(a,c,k));
						printf("%s\n",a);return 1;}
				}

				if(calc(calc(calc(a[0]-'0',b[0]-'0',i),c[0]-'0',j),d[0]-'0',k)==10){
					strcpy(a,sign(a,b,i));
					strcpy(a,sign(a,c,j));
					strcpy(a,sign(a,d,k));
					printf("%s\n",a);return 1;}
			}
		}
	}
	return 0;
}
int main(void){
	while(scanf("%s %s %s %s",a,b,c,d)!=EOF){
		if(a[0]=='0' && b[0]=='0' && c[0]=='0' && d[0]=='0')break;
		if(check(a,b,c,d,1))continue;
		if(check(a,c,b,d,1))continue;
		if(check(a,d,c,b,1))continue;
		if(check(c,d,a,b,1))continue;
		if(check(b,d,a,c,1))continue;
		if(check(b,c,a,d,1))continue;
		if(check(a,b,d,c,0))continue;
		if(check(a,c,d,b,0))continue;
		if(check(a,d,b,c,0))continue;
		if(check(c,d,b,a,0))continue;
		if(check(b,d,c,a,0))continue;
		if(check(b,c,d,a,0))continue;
		printf("0\n");
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    string s;cin>>s;
    int ans=0;
    rep(i,n){
        string a=s.substr(i),b=s.substr(0,i);
        map<char,int>A;
        int cnt=0;
        rep(j,a.size()){
            A[a[j]]++;
        }
        sort(all(b));
        b.erase(unique(all(b)),b.end());
        rep(j,b.size()){
            if(A[b[j]]>0)cnt++;
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}

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

#define ll long long
#define ii pair<int,int>
#define INF 1e9 + 7
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define add emplace_back
#define LEFT 1
#define TOP 2
#define DIAGONAL 3

int main(){ios_base::sync_with_stdio(false);
    
    string s, t;
    cin >> s >> t;
    int n=s.size(), m=t.size();

    vvi dp(n+2, vi(m+2, 0)), parent(n+2, vi(m+2, 0));

    for(int i=0; i<n; ++i){
        for(int j=0; j<m; ++j){
            if(s[i]==t[j] && dp[i][j]+1 > dp[i+1][j+1]){
                dp[i+1][j+1] = dp[i][j]+1;
                parent[i+1][j+1] = DIAGONAL;
            }
            if(dp[i][j] > dp[i][j+1]){
                dp[i][j+1] = dp[i][j];
                parent[i][j+1] = LEFT;
            }
            if(dp[i][j] > dp[i+1][j]){
                dp[i+1][j] = dp[i][j];
                parent[i+1][j] = TOP;
            }
        }
    }
    
    
    /*
    for(int i=0; i<=n; ++i){
        for(int j=0; j<=m; ++j)
            cout << parent[i][j] << " ";
        cout << endl;
    }
    */

    string ans;
    int a=n, b=m;
    for(int i=0; i<=n; ++i)
        for(int j=0; j<=m; ++j)
            if(dp[i][j] > dp[a][b]){
                a=i;
                b=j;
            }

    while(dp[a][b]){
        if(parent[a][b]==DIAGONAL){
            ans += s[a-1];
            --a;
            --b;
        }
        else if(parent[a][b] == LEFT) --b;
        else if(parent[a][b] == TOP) --a;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 70912
#include <stdio.h>
int main(void){
    int x,y;
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0 && y==0)break;
        if(x<y){printf("%d %d\n",x,y);}
        else{printf("%d %d\n",y,x);}
    }
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n), t(n);
  rep(i, n){
    int h_t;
    cin >> h_t;
    h[i] = h_t;
    t[i] = 1;
  }
  rep(i, m){
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if(h[a] >= h[b]) t[b] = 0;
    if(h[a] <= h[b]) t[a] = 0;
  }
  cout << int(accumulate(t.begin(), t.end(), 0)) << endl;
}


Measured memory_bytes: 3952
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define fi first
#define se second
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int main(){
	fu(1,10){
		for(int s=1;s<10;s++){
			cout<<i<<"x"<<s<<"="<<i*s<<endl;
		}
	}
}

Measured memory_bytes: 1116
#include <iostream>
#include<vector>
using namespace std;
typedef long long ll;
int main() {
	int n;cin>>n;
	int minh=-1;
	ll sum=0;
	vector<ll> a(n),b(n);
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		if(a[i]>b[i]){
			if(~minh==0)minh=b[i];
			if(minh>b[i])minh=b[i];
		}
		sum+=a[i];
	}
	if(~minh){
		cout<<sum-minh<<endl;
	}else{
		cout<<0<<endl;
	}


	return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Prac
{
    class Program
    {
        static void Main(string[] args)
        {
            var temp = new int[3];
            var Score = new List<ScoreData>();
            while (true)
            {
                temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if ((temp[0] == -1) && (temp[1] == -1) && (temp[2] == -1))
                    break;
                Score.Add(new ScoreData(temp));

            }
            foreach(var s in Score)
                Console.WriteLine(s.ToString());
        }
    }
    class ScoreData
    {
        int?[] scores = new int?[3];
        Grades grade;
        public override string ToString()
        {
            return grade.ToString();  
        }
        public ScoreData(int[] scores)
        {

            for (var i = 0; i < 3; i++)
            {
                if (scores[i] == -1)
                    this.scores[i] = null;
                else
                    this.scores[i] = scores[i];
            }
            if ((scores[0] == -1) | (scores[1] == -1))
                grade = Grades.F;
            else if (scores[0] + scores[1] >= 80)
                grade = Grades.A;
            else if ((scores[0] + scores[1] >= 65) && (scores[0] + scores[1] < 80))
                grade = Grades.B;
            else if ((scores[0] + scores[1] >= 30) && (scores[0] + scores[1] < 50) && (scores[2] >= 50))
                grade = Grades.C;
            else if ((scores[0] + scores[1] >= 50) && (scores[0] + scores[1] < 65))
                grade = Grades.C;
            else if ((scores[0] + scores[1] >= 30) && (scores[0] + scores[1] < 50))
                grade = Grades.D;
            else
                grade = Grades.F;
        }
    }
    enum Grades
    { S, A, B, C, D, F }
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

ll calc(ll a)
{
    ll ret=0;
    ll tmp=a%4;
    if(tmp==0) ret=a;
    else if(tmp==1) ret=1;
    else if(tmp==2) ret=1^a;
    else if(tmp==3) ret=0;
    
    return ret;
}

int main()
{
    ll a,b,ans;
    cin>>a>>b;
    ans=calc(a-1)^calc(b);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
arr = []
arr << gets.to_i
arr << gets.to_i
arr << gets.to_i
arr << gets.to_i
arr << gets.to_i
k = gets.to_i
check = 0
(arr.size - 1).times do |i|
  (1...5).each do |j|
  co = arr[j] - arr[i]
  check = 1 if co > k
  end
end
puts check.zero? ? :Yay! : ':('

Measured memory_bytes: 1788
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<numeric>
#include<functional>
#include<utility>
#include<tuple>
#include<math.h>
using namespace std;
const long long int big = 1152921504606846976;
double dig = 98765432100000000;//10の9乗を軽く超えます
//xi,yi,5に合うのは
//  xj+yj+5==xi+yi  &&  xi-yi+5>=xj-yj>=xi-yi-5であるもの
//xj+yj,xj-yj,xi+yi,xi-yiを受け取って、それができるのをキューに入れて保持
//チェビシェフ距離の考え方

int main(void) {
	int  i,j,a,b,c,e,N,ter;//mt->そこまでの時間
	long double d,mt;
	static long double x[1010] = { 0 };
	static long double y[1010] = { 0 };
	static long double r[1010] = { 0 };
	static long double time[1010] = { 0 };
	priority_queue<pair<long double,int>,vector<pair<long double,int>>,greater<pair<long double,int>>> pque;
	scanf("%d %d %d %d", &a, &b, &c, &e);
	x[0] = a; y[0] = b; x[1] = c; y[1] = e;
	r[0] = 0; r[1] = 0; time[0] = dig; time[1] = dig;
	scanf("%d", &N);
	for (i = 2; i < N + 2; i++) {
		scanf("%d %d %d", &a, &b, &c);
		x[i] = a;
		y[i] = b;
		r[i] = c;
		time[i] = dig;//無限大で初期化
	}
	pque.push(make_pair(0, 0));//time[0]=0;
	while (!pque.empty()) {
		mt = pque.top().first;
		ter = pque.top().second;
		pque.pop();
		if (time[ter]<mt) { continue; }//もしtime[ter]がすでにある時間より短いなら飛ばす
		for (i = 1; i < N+2; i++) {//0に飛ばす必要はない
			d = hypot(x[ter] - x[i], y[ter] - y[i]);
			d -= (r[ter]+r[i]);
			if (d < 0) { d = 0; }
			if (mt + d < time[i]) { pque.push(make_pair(mt + d, i)); time[i] = mt + d; }
		}
		
	}
	printf("%.16Lf", time[1]);
	return 0;
}

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

using namespace std;

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

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

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

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

const ll mod = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//











struct UnionFind {

        vector<int> par;

        UnionFind(int n) : par(n) {
                for(int i = 0; i < n; i++) par[i] = i;
        }

        int root(int x){
                if(par[x] == x) return x;
                return par[x] = root(par[x]);
        }

        void Union(int x, int y){
                int nx = root(x);
                int ny = root(y);

                if(nx == ny) return;

                par[nx] = ny;
        }
};

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

        UnionFind tree(n);
        for(int i = 0; i < m; i++)
        {
                int X, Y, Z;
                cin >> X >> Y >> Z;
                X--;
                Y--;

                tree.Union(X, Y);
        }

        int sum = 0;
        for(int i = 0; i < n; i++){
                if(i == tree.root(i)) sum++;
        }

        cout << sum << endl;
}






















Measured memory_bytes: 896
k = int(input())
s = '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'

arr = [int(x) for x in s.split(', ')]
print(arr[k - 1])


Measured memory_bytes: 2940
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

x,n=nii()
p=lnii()

dist=1000
for i in range(101,-1,-1):
  if i in p:
    continue

  t_dist=abs(x-i)
  if t_dist<=dist:
    dist=t_dist
    ans=i

print(ans)

Measured memory_bytes: 9036
n=int(input())
p=list(map(int, input().split()))
q=list(map(int, input().split()))

def fact(n):
  if n == 1: return 1
  return n*fact(n-1)

def p_count(n, s, nums):
  if isinstance(nums, int):
    return 1
  idx=nums.index(s[0])
  nums.pop(idx)
  if len(nums) != 0:
    return (idx) * fact(n-1) + p_count(n-1, s[1:], nums)
  else:
    return 1
  
nl1=list(range(1,n+1))
nl2=list(range(1,n+1))
print(abs(p_count(n, p, nl1)-p_count(n, q, nl2)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    string s;
    map<string, int> m;
    rep(i,n) {
        cin >> s;
        m[s]++;
    }
    int maxv = 0;
    for (auto x: m) {
        int v = x.second;
        if(v>maxv) maxv = v;
    }
    for (auto x: m) {
        if(x.second == maxv) cout << x.first << endl;
    }
    // for (auto it = m.begin(); it != m.end(); it++) {
    //     if(it->second == maxv) cout << it->first << endl;
    // }
	return 0;
}


Measured memory_bytes: 25216