akhauriyash/Code-Regression huggingface dataset:
/** 
If comrades that you trust gather around you, hope can take physical form and become visible. That’s what I believe.
*/
#include <bits/stdc++.h>
using namespace std;
/**
(▀̿Ĺ̯▀̿ ̿) (ง ͠° ͟ل͜ ͡°)ง
*/
const int N = 2e5 + 7;
int64_t cross[3][N];
int64_t track[3][N];
set<int64_t> now[3];
#define debug(x) cerr << #x << "  ->> " << x << endl
auto solve() -> void {
    int64_t n; cin >> n;
    int64_t res = (n  - 2) * (n - 2);

    int q; cin >> q;
    while (q --) {
        int query, idx; cin >> query >> idx; --query;
        if (cross[query][idx]++) continue;
        auto &dir = now[query];
        auto prev = dir.lower_bound(idx);
        int reduce = -1;
        if (prev != dir.begin()) {
            --prev;
            // closest smallest
            reduce = track[query][*prev];
        } else {
            if (now[query ^ 1].empty()) {
                reduce = n - 2;
                // strike all
            } else {
                // strike the smallest from opposite
                // debug(*now[query ^ 1].begin());
                reduce = *now[query ^ 1].begin() - 2;
            }  
        }
        // debug(query);
        // debug(idx);
        // debug(reduce);
        res -= reduce;
        assert(reduce > -1);
        track[query][idx] = reduce;
        dir.emplace(idx);
    }
    cout << res << '\n';
}
auto main() -> int {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int tc = 1;
    while (tc--) {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 19228
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <stdlib.h>

using namespace std;

const long long int MAX = 1000000007;


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

  if(s.length()< 4)
    cout << "No" << endl;
  else{
    if( s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I' )
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }


  return 0;
}


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

int main(){

int a,b,c,d;
cin >> a >> b >> c >> d;
while (1){
    c-=b;
    if(c<=0) break;
    a-=d;
    if(a<=0) break;
}

if(c<=0) cout << "Yes" << endl;
else cout << "No" << endl;

}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a, b;
    cin >> a >> b;
    if(a == 1){
        a += 13;
    }
    if(b == 1){
        b += 13;
    }

    if(a > b){
        cout << "Alice" << endl;
    }else if(a < b){
        cout << "Bob" << endl;
    }else{
        cout << "Draw" << endl;
    }
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func readInt() int {
	i, _ := strconv.Atoi(read())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	check := make(map[string]int, 0)
	for i := 0; i < n; i++ {
		color := read()
		check[color]++
	}
	if len(check) == 3 {
		fmt.Println("Three")
	} else {
		fmt.Println("Four")
	}
}


Measured memory_bytes: 640
#include<cstdio>
int main(void){char s[101],p[101],i,j,m=0,n=0;scanf("%s%s",s,p);while(s[m++]!=0);--m;while(p[n++]!=0);--n;for(i=0;i<m;++i){for(j=0;(s[(i+j)%m]==p[j])&&(j<n);++j);if(j==n){puts("Yes");return(0);}}puts("No");return(0);}


Measured memory_bytes: 2620
#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;
    cin >> N;

    vector<int> A(N);
    rep(i,N-1) {
        int tmp;
        cin >> tmp;
        A[tmp - 1]++;
    }

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


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

bool in(int64 f, int64 t, int64 x) {
	t = t - 60*(f/60); f = f%60; x = x%60;
	if (f > t) f -= 60;
	return f <= x && x <= t;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 n;
	cin >> n;
	vector<int64> a(n);
	REP(i, n) cin >> a[i];
	vector<int64> v;
	REP(i, n) {
		int64 now = 0;
		REP(j, 5) {
			if (i+j >= n) break;
			now = now*10+a[i+j];
			v.push_back(now);
		}
	}
	sort(all(v));
	v.erase(unique(all(v)), v.end());
	int now = 0;
	bool ok = 0;
	REP(i, v.size()) {
		if (v[i] == now) {
			now++;
		} else {
			cout << i << endl;
			break;
		}
	}
}



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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " = " << x << endl
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)1e9
#define infll 1e18
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };



//===========================DEBUG======================//
#define XOX 1
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

//================================================================//



//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;


int main(){
 //    #ifndef ONLINE_JUDGE
 //    freopen("../../input.txt", "r", stdin);
 //    freopen("../../output.txt", "w", stdout);
	// #endif
    fast

    ll k,a,b; cin>>k>>a>>b;
    ll val = k* ((a+k-1)/k );
    pt((val<=b?"OK":"NG"));
}


/*



*/





Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  while(n>=1000)
    n=n-1000;
  if(n%1000==0)
    cout<<"0";
  else 
  {
    cout<<1000-n;
  }
  
}


Measured memory_bytes: 3632
#include<stdio.h>
#include <stdlib.h>
long long k;
int compare_int(const void *a, const void *b)
{
    k = *(long long*)a - *(long long*)b;
    if (k > 0)
        k = 1;
    if (k < 0)
        k = -1;
    return k;
}
int main() {
    int n, i,j;
    long long a[200001], sum[200002],ans=0, count;
    scanf("%d", &n);
    for (i = 1; i <= n; i++)
        scanf("%lld", &a[i]);
    sum[0] = 0;
    for (i = 1; i <= n; i++)
            sum[i] = sum[i - 1] + a[i];
    qsort(sum, n+1, sizeof(long long), compare_int);
    count = 0;
    long long memory=sum[0];
    for (i = 0; i <= n; i++) {
        if (sum[i] == memory)
            count++;
        else {
            if (count > 1)
                ans += count * (count - 1) / 2;
            count = 1;
            memory = sum[i];
        }
    }
    if (count > 1)
        ans += count * (count - 1) / 2;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4860
(n, k) = tuple(map(lambda x: int(x), input().split(' ')))
x = input().split(' ')
cnt = 0
for i in range(0, n):
    if int(x[i]) % 2 == 1: cnt += 1

ans = 2 ** (n - cnt)
if cnt % 2 == 1:
    ans *= 2 ** (cnt - 1)
else:
    cur = cnt
    if k == 0: cur = 1
    counter = cur
    for m in range(k, cnt - 1, 2):
        # print(cnt, m, cur)
        cur = cur * (cnt - m) * (cnt - m - 1) // ((m + 1) * (m + 2)) 
        # print(cnt, m, cur)
        counter += cur
    ans *= counter
print(ans)




Measured memory_bytes: 38384
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 100000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define T long long
#define mat vector<vector<T>>
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define cld complex<long double>
using namespace std;
const int N = 100005;
vector<int> g[N];
bool vis[N];
int col[N];
int n,k;

bool check(int cur, int par){
	bool val = true;
	for(int a:g[cur]){
		if(a != par){
			if(abs(col[a] - col[cur]) != 1)val = false;
			val = val && check(a, cur);
		}
	}
	return val;
}

int main(){
	fast_io();	
	cin >> n;
	cu(i,0,n-1){
		int x,y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	cin >> k;
	priority_queue<pii> pq;
	cu(i,0,k){
		int x,y;
		cin >> x >> y;
		col[x] = y;
		vis[x] = 1;
		pq.push({y, x});
	}
	while(pq.size()){
		int c = pq.top().S;
		pq.pop();
		for(int a:g[c]){
			if(!vis[a]){
				vis[a] = 1;	
				col[a] = col[c] - 1;
				pq.push({col[a], a});
			}
		}
	}
	if(check(1,0)){
		cout << "Yes" << '\n';	
		fu(i,1,n){
			cout << col[i] << '\n';
		}
	}
	else{
		cout << "No" << '\n';
	}
}


Measured memory_bytes: 9980
import sys
import math
import numpy as np
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    s = S()
    cnt = 0
    for i in range(s.count("R")):
        if s[i] == "W":cnt += 1
    s = s[::-1]
    for i in range(s.count("W")):
        if s[i] == "R":cnt += 1
    print(cnt//2)

Measured memory_bytes: 27296
#include <iostream>
#include <vector>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)

class _stone{
public:
	int begin,end;
	_stone(int s,int e){
		begin = s;
		end   = e;
	}
};

int main(){
	int n;
	while(cin>>n,n){
		vector<_stone> stone[2];
		for(int i=1; i<=n; i++){
			int color; cin>>color;
			if( i%2==0 ){ //even
				if( !stone[color^1].empty() && stone[color^1][stone[color^1].size()-1].end==i-1 ){
					if( stone[color].empty() ){
						stone[color].push_back( _stone(1,i) );
						stone[color^1].pop_back();
					}else{
						stone[color][stone[color].size()-1].end = i;
						stone[color^1].pop_back();
					}
				}else{
					if( stone[color].empty() ) stone[color].push_back( _stone(i,i) );
					else                       stone[color][stone[color].size()-1].end = i;
				}
			}else{ //odd
				if( stone[color].empty() || stone[color][stone[color].size()-1].end != i-1)
					stone[color].push_back( _stone(i,i) );
				else
					stone[color][stone[color].size()-1].end = i;
			}
			/*
			printf("i:%d\n",i);
			REP(j,stone[0].size())printf("w:%d_%d\n",stone[0][j].begin,stone[0][j].end);
			REP(j,stone[1].size())printf("b:%d_%d\n",stone[1][j].begin,stone[1][j].end);
			*/
		}
		int ans = 0;
		for(int i=0; i<stone[0].size(); i++){
			ans += stone[0][i].end - stone[0][i].begin + 1;
			//printf("%d_%d\n",stone[0][i].begin,stone[0][i].end);
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 912
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
# tuple:listの中に()で要素を表すi.e.[(1,2)(2,3)]

l = list(itertools.permutations(P)) #イテレータ
m = sorted(l)
a = m.index(P)
b = m.index(Q)
ans = abs(a - b) #abs:正の数を返す
print(ans)

Measured memory_bytes: 8308
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 2e5 + 10;
const double eps = 1e-8;
int n;
inline __int128 read() {
	__int128 x = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}

inline void print(__int128 x) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	if (x > 9)
		print(x / 10);
	putchar(x % 10 + '0');
}
__int128 ans = 1, t = 1000000000000000000, x;
__int128 a[N];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		a[i] = read();
	}
	sort(a, a + n);
	if (a[0] == 0) { puts("0"); return 0; }
	for (int i = 0; i < n; i++) {
		ans *= a[i];
		if (ans > t) { puts("-1"); return 0; }
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 5256
# 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); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
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)        sort(ALL((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)

int x1, x2, y11, y2;
int nx, ny;
int main(){
    INIT;
    cin >> x1 >> y11>> x2 >> y2;
    nx = x2 - x1;
    ny = y2 - y11;
    cout << x2 - ny <<" " << y2 + nx << " " << x1 - ny << " " << y11 + nx << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
//#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
/* -- template -- */

const int MAX = 1000100;
ll 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;//拡張euclid互除法によるi!の逆元計算
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int main() {
    int N, K;
    cin >> N >> K;
    int V[N];
    int ans = 0;
    rep(i, N) cin >> V[i];
    for(int a = 0; a <= K; ++a) {
        for(int b = 0; b <= K - a; ++b) {
            priority_queue<int, vector<int>, greater<int>> que;
            int tmp = 0;
            if(a + b > N) {
                rep(i, N)que.push(V[i]);
                rep(i, min(K - (a + b), N)){
                    if(que.top() < 0)
                        que.pop();
                    else
                        break;
                }

            }else {
                rep(i, a)que.push(V[i]);
                rep(i, b)que.push(V[N - 1 - i]);
                rep(i, min(K - (a + b), a + b)){
                    if(que.top() < 0)
                        que.pop();
                    else
                        break;
                }
            }
            while(!que.empty()) {
                tmp += que.top();que.pop();
            }
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
}


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

using namespace std;

struct UnionFind{
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}
    int find(int x){
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y){
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x]>d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y){ return find(x) == find(y);}
    int size(int x){ return -d[find(x)];}
};
/*
UnionFind
子なら親のIDをもち、非負
親ならマイナスサイズ
まず初期化して、すべて－１をいれる
Find--そのグループの親を探す
Unite--小さいほうに大きいほうをくっつける（経路縮約）
*/

int deg[100005];
vector<int> to[100005];

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    UnionFind uf(n);  //初期化
    rep(i,m){  //友達関係を入力
        int a,b;
        cin >> a >> b;
        a--; b--;  //a,b>=1なので-1
        deg[a]++;  //deg[a]は友達の数
        deg[b]++;
        uf.unite(a,b);
    }
    rep(i,k){
        int a,b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i,n){
        int ans = uf.size(i) -1 -deg[i];
        for(int u : to[i]){
            if(uf.same(i,u)) ans--;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 6784
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

from math import gcd
n = int(input())
a = list( map(int, input().split()))


g = 0
for aa in a:
    g = gcd(g,aa)
if g > 1:
    print('not coprime')
    exit()

MAXN = 10**6+10

def eratosthenes3(limit):
    sieve = [i for i in range(limit+1)]
    p = 2
    while p*p <= limit:
        if sieve[p] == p:
            for q in range(2*p,limit+1,p):
                if sieve[q] == q:
                    sieve[q] = p
        p += 1

    return sieve

sieve = eratosthenes3(MAXN)

st = set()
for aa in a:
    tmp = set()
    while aa > 1:
        tmp.add(sieve[aa])
        aa //= sieve[aa]
    for p in tmp:
        if p in st:
            print('setwise coprime')
            exit()
        st.add(p)
print('pairwise coprime')




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

int digit(int C, int d);
int f(int C);

int A, B, j=0;

int main() {
  cin >> A >> B;
  int times = B-A+1;
  for (; A<B+1; A++){
    j += f(A);
  }
  cout << j << endl;
}

int digit(int C, int d){
  int x=0, y=1;
  for(int i=0; i<d; i++){
    x = (C%(y*10) -x)/y;
    y *= 10;
  }
  return x;
}

int f(int C){
  bool i;
  if(digit(C, 1) == digit(C, 5) && digit(C, 2) == digit(C, 4)){
    i = 1;
  } else {
    i = 0;
  }
  return i;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

double table[3000][3000];
long N;
double p[3000];

double solve(long allcoins, long poscoins)
{
    if(table[allcoins][poscoins]<0){
        if(allcoins==0){
            table[0][0]=1;
        }else{
            if(poscoins==0){
                table[allcoins][0]=solve(allcoins-1,0)*(1-p[allcoins]);
            }else{
                table[allcoins][poscoins]=solve(allcoins-1,poscoins-1)*p[allcoins];
                if(allcoins!=poscoins){
                    table[allcoins][poscoins]+=solve(allcoins-1,poscoins)*(1-p[allcoins]);
                }
            }
        }
    }
    return table[allcoins][poscoins];
}

void init()
{
    for(long i=0; i<3000; i++){
        for(long j=0; j<3000; j++){
            table[i][j]=-1;
        }
    }
}

int main()
{   
    std::cin >> N;
    p[0]=0;
    for(long i=1; i<=N; i++){
        std::cin >> p[i];
    }
    init();

    for(long i=N; i>=0; i--){
        solve(N,i);
    }

    double result=0;
    for(long i=(N+1)/2; i<=N; i++){
        result+=table[N][i];
    }
    std::cout << std::setprecision(10) <<result << std::endl;
    return 0;
}

Measured memory_bytes: 70784
n=int(input());e=[[]for _ in[0]*-~n];q=[(1,0)];f=[-1]*n
while n>1:v,w,c=map(int,input().split());e[v]+=(w,c),;e[w]+=(v,c),;n-=1
while q:
 v,c=q.pop();f[v-1]=c%2
 for w,d in e[v]:q+=[(w,c+d)]*(f[w-1]<0)
print(*f)

Measured memory_bytes: 40328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int main(){
  int N; cin >> N;
  vi a(N); vi b(N-1);
  rep(i,N-1) cin >> b[i];
  a[0] = b[0];
  rep2(i,1,N){
    a[i] = b[i-1];
    if(a[i-1] > b[i-1]) a[i-1] = b[i-1];
  }
  int ans = 0;
  rep(i,N) ans += a[i];
  cout << ans << endl; 
  return 0;
}

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

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

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 1;
  rep(i,n) ans = min(ans*2, ans+k);
  cout << ans;
}

Measured memory_bytes: 256
import math

a,b,x = map(int,input().split())

x = x/a

if x > a*b/2:
    ans = math.atan(2*(a*b-x)/a/a)
    ans = math.degrees(ans)

else:
    ans = math.atan(b*b/2/x)
    ans = math.degrees(ans)

print(ans)

Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        s: Chars,
    }
    let n = s.len() + 1;

    let mut v = vec![0; n];
    for i in 1..n {
        if s[i - 1] == '<' {
            v[i] = v[i - 1] + 1;
        }
    }
    for i in 1..n {
        let i = n - (i + 1);
        if s[i] == '>' {
            v[i] = v[i].max(v[i + 1] + 1);
        }
    }
    println!("{}", v.iter().sum::<i64>());
}


Measured memory_bytes: 8484
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int cnt[N];
const int M = 101;

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   f(i,1,M){
      f(j,1,M){
         f(k,1,M){
            int v = i*i+j*j+k*k+i*j+j*k+k*i;
            if(v <= n){
               cnt[v]++;
            }
         }
      }
   }
   f(i,1,n+1){
      cout << cnt[i] << '\n';
   }
   return 0;
} 

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

int main() {
  int N;
  cin >> N;
  
  bool True = true;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (A % 2 == 0) {
      if (A % 3 == 0 || A % 5 == 0) continue;
      else {
        True = false;
        break;
      }
    }
    else continue;
  }
  
  True ? cout << "APPROVED" << endl : cout << "DENIED" << endl;
}


Measured memory_bytes: 256
Z = list(map(int, input().split()))
ans = 10 ** 18
for i in range(3):
    a, b, c = Z[i % 3], Z[(i + 1) % 3], Z[(i + 2) % 3]
    # print(a, b, c)
    left = c // 2
    right = c - left
    ans = min(ans, abs(left - right) * a * b)

print(ans)


Measured memory_bytes: 9144
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=200006
for i in range(M):
    x,y,c=map(int,input().split())
    ans=min(ans,a[x-1]+b[y-1]-c)
a=sorted(a)
b=sorted(b)
print(min(a[0]+b[0],ans))


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

using namespace std;

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

	string str;
	cin >> str;
	if(str.back()=='s') str+="es";
	else str+="s";
	cout << str << endl;

	return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <climits>
#include <map>

using namespace std;

int c[10][10];
int A[200][200];
int dst[10];
int main(){
  int H;
  int W;
  cin >> H >> W;
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      cin >> c[i][j];
    }
  }

  for(int i = 0; i < 10; i++){
    dst[i] = -1;
  }
  dst[1] = 0;


  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      for(int k = 0; k < 10; k++){
        if(dst[j] >= 0){
          if(dst[k] < 0){
            dst[k] = dst[j] + c[k][j];
          } else {
            dst[k] = min(dst[k], dst[j] + c[k][j]);
          }
        }
      }
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> A[i][j];
    }
  }

  int ans = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(A[i][j] >= 0){
        ans += dst[A[i][j]];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n, a ,b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int ca, cb;
  ca = cb = 0;
  rep(i,n) {
    if(s[i] == 'c') {cout << "No" << endl; continue;}
    if(s[i] == 'a') {
      if(ca+cb < a+b) {
        ca++;
        cout << "Yes" << endl;
      }
      else cout << "No" << endl;
    }
    if(s[i] == 'b') {
      if(ca+cb < a+b && cb < b){
        cb++;
        cout << "Yes" << endl;
      }
      else cout << "No" << endl;
    }
  }
}

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

int main() {
	int H, A;
	int sum = 0;

	cin >> H >> A;

	/*�v�񂷂�ƁAH �� A �������Ă�悤�ȃC���[�W�B
	��)H = 12; A = 3;�̎��A�́��̂悤�ȃC���[�W�B
	(0| 1 2 3 | 4 5 6 | 7 8 9 | 10 11 12 | ...)
	(0| 1 1 1 | 2 2 2 | 3 3 3 | 4  4  4  |...)
	*/
	sum = (H + A - 1) / A;

	cout << sum << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
//#define rf(x) (x)=0;while(*p<48)im=*p=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define INFST (0x7f7f7f7f)
#define INFLLST (0x7f7f7f7f7f7f7f7fll)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
typedef complex<ld> base;
const ld EPS = (ld)1e-7;
const ld PI = acos(0) * 2;
bool isZero(const ld& x) { return abs(x) <= EPS; }
int sign(const ld& x) { return isZero(x) ? 0 : (0 < x ? 1 : -1); }
ll gcd(ll a, ll b) { for(;b;a%=b,swap(a,b)){} return abs(a); }
pll operator + (const pll& a, const pll& b) { return pll(a.first+b.first, a.second+b.second); }
pll operator - (const pll& a, const pll& b) { return pll(a.first-b.first, a.second-b.second); }
pll operator * (const pll& a, const ll& b) { return pll(a.first*b, a.second*b); }
ll operator * (const pll& a, const pll& b) { return a.first*b.second - b.first*a.second; }
ll ccw(const pll& a, const pll& b, const pll& c) { return a*b + b*c + c*a; }
void fg(vector<int> G[], int a, int b) { G[a].pb(b); G[b].pb(a); }
void fg(vector<pii> G[], int a, int b, int c) { G[a].pb({b, c}); G[b].pb({a, c}); }

const int MOD = 1000000007;
const int MAXN = 200005;
const int MAXX = 2005;

int d[MAXX*2][MAXX*2];
ll fac[MAXX*8], invfac[MAXX*8];

int A[MAXN], B[MAXN];

int N, Ans;

ll pw(ll n, ll k) {
	ll r = 1; for(n %= MOD; k; k >>= 1) {
		if(k&1) r = r * n % MOD;
		n = n * n % MOD;
	}
	return r;
}

int main() {
	ios::sync_with_stdio(false);

	fac[0] = 1; for(int i = 1; i < MAXX*8; i++) fac[i] = fac[i-1] * i % MOD;
	invfac[MAXX*8-1] = pw(fac[MAXX*8-1], MOD-2);
	for(int i = MAXX*8-1; i; i--) invfac[i-1] = invfac[i] * i % MOD;
	
	cin >> N;
	for(int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
		d[-A[i]+MAXX][-B[i]+MAXX]++;
	}
	for(int i = 1; i < MAXX*2; i++) for(int j = 1; j < MAXX*2; j++)
		d[i][j] = (d[i][j] + (d[i-1][j] + d[i][j-1]) % MOD) % MOD;
	
	for(int i = 0; i < N; i++) {
		Ans = (Ans + d[A[i]+MAXX][B[i]+MAXX]) % MOD;
		Ans = (Ans - fac[A[i]*2+B[i]*2] * invfac[A[i]*2] % MOD * invfac[B[i]*2] % MOD + MOD) % MOD;
	}

	Ans = (ll)Ans * pw(2, MOD-2) % MOD;
	
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 64896
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 99999999999999999
#define MOD 1000000007 

void func()
{
    ll x,y;
    cin>>x>>y;
    loop(i,0,x+1){
        ll t=2*i+(x-i)*4;
        if(t==y){
            cout<<"Yes"<<"\n";
            return;
        }
    }
    cout<<"No"<<"\n";
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
 
    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

Measured memory_bytes: 3644
mod = 10**9 + 7

def comb(n, k):
    x, y = 1, 1
    k = min(k, n-k)
    for i in range(k):
        x *= n - i
        x %= mod
        y *= i + 1
        y %= mod
    return x*pow(y, mod-2, mod) % mod

N, M, K = map(int, input().split())
print((M*M%mod*((N**3-N)//6%mod)%mod+N*N%mod*((M**3-M)//6%mod)%mod)%mod*comb(N*M-2,K-2)%mod)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n; cin>>n;
	long long sum=0;
	for(int i=1;i<=n;i++)
		if((i%3) && (i%5))sum+=i;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3636
/* Author : icoder211 */

#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define ln "\n"
#define mp make_pair
#define forn(i,e) for( i=0; i<e; i++)
#define forsn(i,s,e) for( i=s; i<e; i++)
#define rforn(i,e) for( i=e; i>=0; i--)
#define rforsn(i,s,e) for( i=e; i>=s; i--)
#define vasort(v)         sort(v.begin(), v.end());
#define vdsort(v)         sort(v.begin(), v.end(),greater<int>());

#define all(x) x.begin(), x.end()

#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define out5(x1,x2,x3,x4,x5) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << ln
#define out6(x1,x2,x3,x4,x5,x6) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << " " << x6 << ln

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4
#define in5(x1,x2,x3,x4,x5) cin >> x1 >> x2 >> x3 >> x4 >> x5
#define in6(x1,x2,x3,x4,x5,x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6

#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

typedef long long ll;
using namespace std;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
typedef vector<int> vi;
typedef vector<ll> vll;



// fast exponentiation - O(log(n))
ll exp(ll n, ll m, ll md){
        ll a = 1;
        while (m > 0){
                if (m&1) a = (a * n%md) % md;
                m /= 2;
                n = (n*n) % md;
        }
        return a % md;
}

void disp(vll v){
        for(auto u:v)
                cout<<u<<" ";
        cout<<"\n";
}



//function for primality checking - O(sqrt(n))
bool prime(ll n) {
        if (n < 2) return false;
        for (ll x = 2; x*x <= n; x++) {
                if (n%x == 0) return false;
        }
        return true;
}




void solve1(){
        ll s, w;
        cin >> s >> w;
        cout << (w >= s ? "unsafe" : "safe");
}

int main(){
        fio;
        //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

        chrono::high_resolution_clock::time_point start = chrono::high_resolution_clock::now();

        ll tt = 1;
        //cin >> tt;
        ll t = tt;
        cout<<fixed<<setprecision(10);


        while(tt--){
                //cout << "Case #" << t - tt << ": ";
                solve1();
        }

        chrono::high_resolution_clock::time_point end = chrono::high_resolution_clock::now();
        long double time_spent = (chrono::duration_cast<chrono::duration<long double> >(end-start)).count();
        //double time_taken = time_spent / double(CLOCKS_PER_SEC);
        cerr<<time_spent<<'\n';
        return 0;
}


Measured memory_bytes: 3792
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] li = new int[N];
    int[] num = new int[N+1];
    num[0] = 0;
    for(int i=0;i<N;i++){
      li[i] = sc.nextInt();
      num[li[i]] = i+1;
    }
    for(int j=1;j<=N;j++){
      System.out.print(num[j]+" ");
    }
  }
}

Measured memory_bytes: 63376
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
C_A = Counter(A)
S = 0
for ca in C_A:
  S += ca * C_A[ca]

Q = int(input())
for q in range(Q):
  b, c = map(int,input().split())
  S += (c - b) * C_A[b]
  C_A[c] += C_A[b]
  C_A[b] = 0
  
  print(S)



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


//TEMPLATE
#define pb                push_back
#define mp                make_pair
#define ll                long long
#define ld                long double
#define pii               pair <ll, ll>
#define piii              pair <ll, pii>
#define F                 first
#define S                 second

#define newline           printf("\n")
#define minusone          printf("-1\n")
#define zeroo             printf("0\n")
#define scl1(a)           scanf("%lld", &a)
#define scl2(a, b)        scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)     scanf("%lld %lld %lld", &a, &b, &c)
#define prl1(a)           printf("%lld\n", a)
#define prl2(a, b)        printf("%lld %lld\n", a, b)
#define ssl1(s)           scanf(" %[^\n]", s)
#define scd1(a)           scanf("%lf", &a)
#define scd2(a, b)        scanf("%lf %lf", &a, &b)
#define prd(a)            printf("%lf\n", a)
#define prld(a)           printf("%Lf\n", a)
#define prcase(cs)        printf("Case %lld: ", cs)
#define cin1(a)           cin >> a
#define cin2(a, b)        cin >> a >> b
#define cin3(a, b, c)     cin >> a >> b >> c
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d
#define cot1(a)           cout << a << "\n"
#define cot2(a, b)        cout << a << " " << b << "\n"
#define cot3(a, b, c)     cout << a << " " << b << " " << c << "\n"
#define cot4(a, b, c, d)  cout << a << " " << b << " " << c << " " << d << "\n"
#define cotline           cout << "\n"
#define cotminus          cout << "-1\n"
#define cot0              cout << "0\n"
#define cotyes            cout << "YES\n"
#define cotno             cout << "NO\n"
#define cotcase(cs)       cout << "Case " << cs << ": "

#define reversed(s)       reverse(s.begin(), s.end())
#define asort(s)          sort(s.begin(), s.end())
#define dsort(s)          sort(s.rbegin(), s.rend())
#define all(s)            s.begin(), s.end()
#define uniq(s)           s.resize(distance(s.begin(),unique(s.begin(), s.end())))
#define found(s, x)       (s.find(x) != s.end())

#define for0(i, n)        for (i = 0; i < n; i++)
#define for1(i, n)        for (i = 1; i <= n; i++)
#define fora(i, a, b)     for (i = a; i <= b; i++)
#define forb(i, b, a)     for (i = b; i >= a; i--)
#define fori(it, s)       for(auto it = s.begin(); it != s.end(); it++)

#define FR                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(a, x)          memset(a, x, sizeof a)
#define bitcount(n)       __builtin_popcountll(n)

//#define pi              3.1415926536
#define pi                acos(-1)

const ll INF = LLONG_MAX;
const ll SZ = 4e5+5;
const ll mod = 1e9+7;


ll n;
ll a[SZ];
//ll b[SZ];

set <pii> st;

int main() {
    ll cs = 0, tc = 1, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0, t = 0;
//    ll a, b, d;
    string s, s1, s2;

    cin1(n);
    for1(i, n) cin1(a[i]);

    ans = 1;
    st.insert({a[1], ++c});

    fora(i, 2, n) {
        auto it = st.lower_bound({a[i], 0});
        if(it == st.begin()) {
            ans++;
        }
        else {
            it--;
            st.erase(it);
        }
        st.insert({a[i], ++c});
    }

    cot1(ans);

    return 0;
}



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

int main(){

    int a[4];
    int k;
    int res=0;

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

    cin >> k;

    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            if (a[i] - a[j] > k)
            {
                res ++;
            }
            
        }
        
    }
    
    if (res > 0)
    {
        cout << ":(" << endl;
    }else
    {
        cout << "Yay!" << endl;
    }
    
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int dp[3001][3001][4];
int arr[3002][3002];
int r,c,K;
int solve(int i, int j, int k){
   if(dp[i][j][k]!=-1)return dp[i][j][k];
   if(k==3 and arr[i][j]!=0)return 0;
   int ans=0;
   if(j<c)ans=max(ans,arr[i][j]+solve(i,j+1,arr[i][j]>0?k+1:k));
   if(j<c)ans=max(ans,solve(i,j+1,k));
   if(i<r)ans=max(ans,arr[i][j]+solve(i+1,j,0));
   dp[i][j][k]=ans;
   return ans;
}
int32_t main(){
    cin>>r>>c>>K;
   rep(i,0,r+1)rep(j,0,c+1)dp[i][j][0]=-1,dp[i][j][1]=-1,dp[i][j][2]=-1,dp[i][j][3]=-1,arr[i][j]=0;
   rep(i,0,K){
      int a,b,v; cin>>a>>b>>v;
      --a,--b;
      arr[a][b]=v;
   }
   //print2d(arr,r+1,c+1);
   cout<<solve(0,0,0)<<"\n";
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read question. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


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

#define FOR(i,a,b) for(ll i=a; i<b; i++)
#define IN(a) cin>>a
#define OUT(a) cout<<a<<endl

int main(){
  int n;
  IN(n);
  vector<int> a(4);
  FOR(i,0,n){
    string b; IN(b);
    if(b=="AC"){
      a.at(0)++;
    }else if(b=="WA"){
      a.at(1)++;
    }else if(b=="TLE"){
      a.at(2)++;
    }else if(b=="RE"){
      a.at(3)++;
    }
  }
  cout << "AC x " << a.at(0) << endl;
  cout << "WA x " << a.at(1) << endl;
  cout << "TLE x " << a.at(2) << endl;
  cout << "RE x " << a.at(3) << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n, k;
    cin >> n >> k;
    vector<lli> v;
    if (n <= abs(n - k))
    {
        cout << n << endl;
    }
    else
    {
        if (n >= k)
        {
            n %= k;
        }
        n = min(n, abs(n - k));
        cout << n << endl;
    }
}

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

#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int N;
int B[110];
int ans = 0;

int main() {
	cin >> N;
	REP(i, N - 1) cin >> B[i];
	REP(i, N - 2) {
		ans += min(B[i], B[i + 1]);
	}
	ans += B[0] + B[N - 2];
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n, k, q, m;
int a[2000];
int comp[2000];

int checkInterval(int s, int e, int mx) {
    int ret = 0;
    for (int i = s; i <= e; ++i) {
        if (a[i] <= comp[mx]) ++ret;
    }
    return max(min(ret, e - s - k + 2), 0);
}

bool check(int mx, int mn) {
    int p = 0, sum = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] < comp[mn]) {
            sum += checkInterval(p, i - 1, mx);
            p = i + 1;
        }
    }
    sum += checkInterval(p, n - 1, mx);
    return q <= sum;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> k >> q;
	for (int i = 0; i < n; ++i) {
        cin >> a[i];
        comp[i] = a[i];
	}
	sort(comp, comp + n);
	m = unique(comp, comp + n) - comp;
	int ans = 1e9;
	for (int i = m; i--; ) {
        int s = -1, e = i;
        while (s < e) {
            int d = (s + e + 1) / 2;
            if (check(i, d)) s = d;
            else e = d - 1;
        }
        if (s != -1) ans = min(ans, comp[i] - comp[s]);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
#define N 100005


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

   ll t = n/(a+b);    
   ll rem = n%(a+b);
   
   t = t*a;
   rem  = min(rem,a);
   
   cout<<t+rem<<endl;


}

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

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

    int64_t left = -1, right = 1e9;
    while (abs(right - left) > 1) {
        int64_t middle = left + (right - left) / 2;
        int64_t c = 0;
        for (auto& e : h) {
            c += (max(0l, e - middle * b) + a - b - 1) / (a - b);
        }
        (c > middle ? left : right) = middle;
    }

    cout << right << endl;
}


Measured memory_bytes: 1024