akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;

int collatz(int n) {
	int answer;
	if (n % 2 == 0)answer = n / 2;
	else answer = 3 * n + 1;
	return answer;
}

int main() {
	vector<int> a(1000000);
	cin >> a.at(1);
	bool m = false;
	for (int i = 2; i < 1000000; ++i) {
		a.at(i) = collatz(a.at(i - 1));
		for (int j = 1; j < i; ++j) {
			if (a.at(j) == a.at(i)) {
				cout << i << endl;;
				 m = true;
				break;
			}
		}
		if (m)break;
	}
}

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

using int_ = int;
#define int int_least64_t

int_ main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);

  string s, t; cin >> s >> t;
  cout << ([&](){
             for (int i=0; i<=s.size(); ++i) {
               if (s == t) return true;
               rotate(s.begin(), s.end()-1, s.end());
             }
             return false;
           }() ? "Yes" : "No") << '\n';
}

/*
 * Local variables:
 * compile-command:"g++ -D_GLIBCXX_DEBUG -g3 -ggdb3 -O0 -Wall -Wextra -std=c++14 b.cc -o b && for f in *.in; do echo \"--- $f -------------\"; ./b <$f; done"
 * end:
 */


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#define SM 500
using namespace std;
long long n,S[SM],F[SM][SM],a[SM];
int main()
    {
        long long i,j,d=0,mid=0;
        cin>>n;
        for (i=1;i<=n;i++)
            for (j=i;j<=n;j++) F[i][j]=1e18;
        for (i=1;i<=n;i++)
        {
            cin>>a[i];
            S[i]=S[i-1]+a[i];
            F[i][i]=0;
        }
        for (d=1;d<=n-1;d++)
            for (i=1;i<=n-d;i++)
            {
                j=i+d;
                for (mid=i;mid<j;mid++)
                    F[i][j]=min(F[i][j],F[i][mid]+F[mid+1][j]);
                F[i][j]=F[i][j]+S[j]-S[i-1];
            }
        cout <<F[1][n];
        return 0;
    }


Measured memory_bytes: 4744
#include "bits/stdc++.h"
using namespace std;

/*
vector.push_back()
vector<int> hoge(3,-1); {-1,-1,-1}
vector<vector<int>> hogehoge(2,vector<int>(2,-1)); {{-1,-1},{-1,-1}} 
cin >>temp;
scanf("%d %d %d",&A,&B,&Q);
sort(a.begin(),a.end());
a.push_back(4000000000000);
a.insert(a.begin(),-1000000000000);
upper_bound(a.begin(),a.end(),x); // list[i] > x のイテレータ取得. *itrで数値化 
    std::priority_queue<
      int,
      std::vector<int>,
      decltype(compare) // 比較関数オブジェクトを指定
    > que(comp);
*/
template <typename T> void debug(T arr);
template <typename T> void debug (T arr, int dim);


int main(void){
  int n;
  string s;
  cin >> n;
  cin >> s;
  s = s + '?';
  int ans = 0;
  char bef = s[0];
  for (int i = 0; i < n+1; ++i){
    if (bef != s[i]){
      ans += 1;
      bef = s[i];
    }
  }
  cout << ans << endl;

};


template <typename T> void debug(T arr){
    for (auto col:arr){
        cout << col << " ";
    }
    cout <<endl;
};

template <typename T> void debug (T arr, int dim){
    for (auto raw:arr){
        for(auto col:raw){
            cout << col << " ";
        }
        cout << endl;
    }
};


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
//#include<array>
#include<algorithm>
//#include<queue>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>
//#include<bitset>
//#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}
//long nHr(int n, int r) {
//	n = n + r - 1;
//	return nCr(n, r);
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	int MIN = 1e9;
	string S;
	cin >> S;
	for (int i = 0; i < S.size() - 2; i++) {
		MIN = min(abs(753 - stoi(S.substr(i, 3))), MIN);
	}
	cout << MIN << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){

	char a[100];
	int i, n, k;

	scanf("%s",a);
	n = strlen(a);

	for(i=0; i<n-1-i; i++){
		if(a[i] != a[n-1-i]){
			puts("No");
			return 0;
		}
	}

	n = (n-1)/2;

	for(i=0; i<n-1-i; i++){
		if(a[i] != a[n-1-i]){
			puts("No");
			return 0;
		}
	}

	n = strlen(a);
	k = ((n+3)/2)-1;

	for(i=0; k+i<(n-1)-i; i++){
		if(a[k+i] != a[(n-1)-i]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  ll N; cin >> N;

  ll ok = N;    // compare(ok) is always true
  ll ng = 0;    // compare(ng) is always false
  
  while(abs(ok-ng) > 1) {
    ll mid = (ok + ng) / 2LL;
    (mid * (mid - 1) / 2 >= N - mid ? ok : ng) = mid;
  }

  ll sum = 0;
  for(int i = ok - 1; i>=1; i--) {
    if(sum + i > N - ok) continue;
    printf("%d\n", i);
    sum += i;
  }

  cout << ok << endl;
  
  return 0;
}

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

typedef long long ll;
typedef tuple<ll, ll, ll> mytuple;
const ll INF = 1e9;
const ll MOD = 1000000007;
const double pi = 3.141592653589793238;

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) { if (b == 0) {return a;} else {return GCD(b, a % b);} }
// a と b の最小公倍数を返す関数
long long LCM(long long a, long long b) { return a/GCD(a,b)*b; }

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

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

  if(S == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }

  return 0;
}


Measured memory_bytes: 3628
#include<cctype>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cmath>
#include<cassert>
#include<algorithm>
#include<numeric>
#include<vector>
#include<string>
#include<map>
#include<unordered_map>
#include<queue>
#include<tuple>
using namespace std;
typedef long long int lnt;
typedef unsigned long long int unt;
typedef unsigned ust;
typedef double dou;
typedef pair<int,int> P;
#define FZ(i,n)       for(int i=0;i<(n);++i)
#define FB(i,n)       for(int i=(n)-1;i>=0;--i)
#define FV(i,st,ed)   for(int i=st;i<(ed);++i)
#define FC(i,n)       for(int i=n;i;--i)
#define FZU(i,n)      for(ust i=0;i!=(n);++i)
#define FVU(i,st,ed)  for(ust i=st;i<(ed);++i)
#define FCU(i,n)      for(ust i=n;i;--i)
#define SZ(x)         ssize_t(x.size())
#define ALL(x)        std::begin(x),std::end(x)
#define likely(x)     __builtin_expect(!!(x), 1)
#define unlikely(x)   __builtin_expect(!!(x), 0)

#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d %d",&(x),&(y))
#define RS(x) scanf("%s",x)
#define RI64(x) scanf("%I64d",&(x))
#define RII64(x,y) scanf("%I64d%I64d",&(x),&(y))

#define FIR first
#define SEC second
#define pritnf printf
constexpr ust N = 100514u;
char s[N];
bool sol(){
    if(RS(s)==EOF)return 0;
    int j = 0;
    for(int i = 0 ;s[i];i++){
        if(j==0&&s[i]=='C')j++;
        if(j==1&&s[i]=='F')j++;
    }
    puts(j==2?"Yes":"No");
    return 1;
}
int main(){
    while(sol());
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<string> blue(n);
  for (int i = 0; i<blue.size(); i++){
    cin >> blue.at(i);
  }//set blue up
  
  int m;
  cin >> m;
  vector<string> red(m);
  for (int i = 0; i<red.size(); i++){
    cin >> red.at(i);
  }//set red up
  
  vector<int> point(n);
  
  for (int i = 0; i<blue.size(); i++){
    int inner = 1;
    
    for (int j = 0; j<blue.size(); j++){
      if (i == j){
        continue;
      }
      if (blue.at(i) == blue.at(j)){
        inner++;
      }
    }
    
    int dbcount = 0;
    for (int k = 0; k<red.size(); k++){
      if (blue.at(i) == red.at(k)){
        dbcount++;
      }
    }
    point.at(i) = inner - dbcount;
  }
  
  int max = 0;
  for (int i = 0; i<point.size(); i++){
    if (max <point.at(i)){
      max = point.at(i);
    }
  }
  
  if (max <= 0){
    cout << 0 << endl;
  }else{
    cout << max << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

const int N = 1000000;

int main() {
  int s;
  cin >> s;
  
  vi a(N+1,0);
  a.at(1) = s;
  repi(i,2,N) {
    if (a.at(i-1)%2==0) {
      a.at(i) = a.at(i-1)/2;
    }
    else {
      a.at(i) = 3*a.at(i-1)+1;
    }
    
    repi(j,1,i-1) {
      if (a.at(j)==a.at(i)) {
        cout << i << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll n; cin >> n;
  vector<vll> memo(10, vll(10, 0));
  REPC(i, 1, n) {
    int lower = i % 10;
    int m = i;
    while(m > 9) m /= 10;
    int upper = m;
    memo[upper][lower]++;
  }
  ll ans = 0;
  rep(i, 10) rep(j, 10) {
    ans += memo[i][j] * memo[j][i];
  }
  cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, l;
  cin >> n >> l;
  int ans = 0;
  int m = 1e8;
  rep(i, n) {
    int num = l + i;
    ans += num;
    if(abs(m) > abs(num)) m = num;
  }
  ans -= m;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    ll n;
    ll b;
    map <ll,ll> a;
    cin >>n;
    ll sum = 0;
    for(ll i = 0;i<n;i++) {
        cin >> b;
        a[b]++;
        sum += b;
    }
    ll q;
    cin >> q;
    pair <ll,ll> c;
    vector <ll> ans(q);
    for(ll i = 0;i<q;i++) {
        cin >> c.first >> c.second;
        decltype(a)::iterator it = a.find(c.first);
        if (it != a.end()) {
            ll f = a[c.first];
            a[c.first] = 0;
            a[c.second] += f; 
            sum -= c.first *f;
            sum += c.second * f;
            cout << sum << endl;
        } else {
            cout << sum << endl;
        }
    }
}

Measured memory_bytes: 8560
#include<bits/stdc++.h>
using namespace std ;
  int pre, x[5] ;


int main () {
  string a[5] ;
  cin >> a[0] >> a[1] >> a[2] ;
  while(a[pre][x[pre]]) pre=a[pre][x[pre]++]-'a' ;
  cout << char ('A' + pre ) << endl ;
}

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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void precal() {

	return;
}

bool solve() {
	lli n, m, cnt = 0;
	if ( cin >> n >> m );
	else return false;
	
	bitset<20> light[m], st;
	
	for (int i = 0; i < m; ++i) {
		int k; cin >> k;
		for (int j = 0; j < k; ++j) {
			int l; cin >> l;
			light[i][l] = 1;
		}
//		cout << light[i] << '\n';
	}
	
	for (int i = 1; i <= m; ++i) {
		int s; cin >> s;
		st[i] = s;
	}
	
	for (int s = 0; s < (1<<n); ++s) {
		bitset<20> tmp = s << 1;
		bool flag = true;
		for (int i = 0; i < m; ++i) {
			bitset<20> TMP = ( tmp&light[i] );
			int COUNT = TMP.count();
			
//			cout << ( tmp&light[i] ) << ' ';
			if ( COUNT%2 != st[ i+1 ] ) flag = false;
		}
		
//		cout << '\n';
		if ( flag ) cnt++ ;
	}
	
	cout << cnt << '\n';
	
	return true;
}

int main() {
	precal();
	int t = INT_MAX;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		if ( !solve() ) break;
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM 1000000000;
#define mod MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main(){
    ll n; cin >> n;
    ll a[n];
    map<ll, ll> mp, mp_pp, mp_mi;
    vector<ll> v;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        mp[a[i]]++;
        mp[a[i]+1]++;
        mp[a[i]-1]++;
        v.push_back(a[i]);
        v.push_back(a[i]+1);
        v.push_back(a[i]-1);
    }
    ll m = v.size();
    ll ans = 0;
    for(ll i = 0; i < m; i++){
        ans = max(ans, mp[v[i]]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 11248
import Control.Monad
import Control.Applicative

solve :: [Int] -> String
solve [h,w] = 
    unlines . replicate h $ replicate w '#'

main =
    mapM_ putStrLn =<< map solve . takeInputs . lines <$> getContents
    where
    takeInputs :: [String] -> [[Int]]
    takeInputs = takeWhile (not . all (== 0)) . map (map read . words) 


Measured memory_bytes: 4604
#include <stdio.h>
#include <math.h>

int main() {
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    double dx = x1 - x2;
    double dy = y1 - y2;
    double d = sqrt(dx * dx + dy * dy);
    printf("%f\n", d);
    return 0;
}


Measured memory_bytes: 2724
input()
p = [int(x) for x in input().split()]
    
p_sorted = sorted(p)
    
diff = 0
for p_elem, p_sorted_elem in zip(p, p_sorted):
    if p_elem != p_sorted_elem:
        diff += 1
    
if diff == 0 or diff == 2:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main{

	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int[] list = new int[in.nextInt()];
		for(int i = 0; i < list.length; i++ )
		{
			list[i] = in.nextInt();
		}
		System.out.println(HowManyPrime(list));
	}
	
	public static int HowManyPrime(int[] list)
	{
		int counter = 0;
		for(int i = 0; i < list.length ; i++) 
		{
			boolean prime = true;
			if(list[i] == 2 || list[i] == 3)
			{
				//prime
			}
			else if(list[i] == 1 || list[i] % 2 == 0 || list[i] % 3 == 0 )
			{
				//System.out.println("base case:" + list[i]);
				prime = false;
			}else
			{
				for(int j = 1; 6 * j <= Math.sqrt(list[i]) + 1 ; j++)
				{
					if(list[i] % ((j * 6) + 1) == 0)
					{
						//System.out.println(list[i] + " % " + ((j * 6) + 1));
						prime = false;
						break;
					}else if(list[i] % ((j * 6) - 1) == 0)
					{
						//System.out.println(list[i] + " % " + ((j * 6) - 1));
						prime = false;
						break;
					}
				}
			}
			if(prime)
			{
				//System.out.println("Prime: " + list[i]);
				counter++;
			}
		}
		return counter;
	}
}



Measured memory_bytes: 42780
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        long mod = (long)Math.pow(10,9)+7;
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        int xl = 0;
        int xr = w;
        int yd = 0;
        int yu = h;
        for(int i = 0; i < n; i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            int a = sc.nextInt();
            switch(a){
                case 1:
                    xl = Math.max(xl,x);
                    break;
                case 2:
                    xr = Math.min(xr,x);
                    break;
                case 3:
                    yd = Math.max(yd,y);
                    break;
                case 4:
                    yu = Math.min(yu,y);
                    break;
            }
        }
        System.out.println(Math.max(0,xr-xl) * Math.max(0, yu-yd));
    }
}

Measured memory_bytes: 22100
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

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

	cout << (N + 1) / 2 << endl;
	return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 2e5 + 7;
const int maxm = 1e6 + 7;
const int ALP = 26;
const long long mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-8;

int k,n;

int main()
{
	//freopen("1.in","r",stdin);
	scanf("%d%d",&k,&n);
	printf("%s\n",500*k>=n?"Yes":"No");
	return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
s = [list(input()) for j in range(H)]

if s[0][0] == "#":
    #print(0, 0, "黒")
    if not (s[0][1] == "#" or s[1][0] == "#"):
        print("No")
        exit()

for j in range(1, W-1):
    if s[0][j] == "#":
     #   print(0, j, "黒")
        if not (s[1][j] == "#" or s[0][j - 1] == "#" or s[0][j + 1] == "#"):
            print("No")
            exit()

if s[0][-1] == "#":
    #print(0, -1, "黒")
    if not (s[0][-2] == "#" or s[1][-1] == "#"):
        print("No")
        exit()

for i in range(1, H-1):
    if s[i][0] == "#":
     #   print(i, 0, "黒")
        if not (s[i][1] == "#" or s[i-1][0] == "#" or s[i+1][0] == "#"):
            print("No")
            exit()

for i in range(1, H-1):
    if s[i][-1] == "#":
     #   print(i, -1, "黒")
        if not (s[i][-2] == "#" or s[i-1][-1] == "#" or s[i+1][-1] == "#"):
            print("No")
            exit()

if s[-1][0] == "#":
    #print(-1, 0, "黒")
    if not (s[-1][1] == "#" or s[-2][0] == "#"):
        print("No")
        exit()

for j in range(1, W-1):
    if s[-1][j] == "#":
     #   print(-1, j, "黒")
        if not (s[-2][j] == "#" or s[-1][j - 1] == "#" or s[-1][j + 1] == "#"):
            print("No")
            exit()

if s[-1][-1] == "#":
    #print(-1, -1, "黒")
    if not (s[-1][-2] == "#" or s[-2][-1] == "#"):
        print("No")
        exit()

for i in range(1, H-1):
    for j in range(1, W-1):
        if s[i][j] == "#":
     #       print(i, j, "黒")
            if not (s[i - 1][j] == "#" or s[i + 1][j] == "#" or s[i][j - 1] == "#" or s[i][j + 1] == "#"):
                print("No")
                exit()
print("Yes")


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
struct item{
    ll wt;
    ll val;
};
 
 
   ll fun(ll n,ll W,vector<item>ar){
    
      ll max_val = 1000*n;
      ll dp[n+1][max_val+1] ;
      for(ll i=0; i<=max_val; i++){
            dp[1][i] = INT_MAX;
      } 
       dp[1][0] = 0;
       dp[1][ar[1].val] = ar[1].wt;
 
       for(ll i=2; i<=n; i++){
           for(ll val = 0; val<=max_val ; val++){
                dp[i][val] = dp[i-1][val];
 
                if(ar[i].val > val)
                   continue;
 
                dp[i][val] = min(dp[i][val], ar[i].wt+dp[i-1][val-ar[i].val]);
           }
       }
     
       ll ans = -1;
      for(ll val = 1; val <= max_val ; val++){
          if(dp[n][val] <= W){
               ans = val;
          }
 
      }
    return ans;
   }
  int main() {
     ll n,W;
     cin >> n >> W;
      vector<item>v(n+1);
     for(int i=1; i<=n; i++){
         cin >> v[i].wt >>v[i].val;
     }
     
     cout << fun( n, W, v);
     return 0;
}

Measured memory_bytes: 78336
i,t;
main(){
    char W[11],T[1001];
    for(i=0,scanf("%s",W);W[i];W[i]=tolower(W[i]),i++);
    for(;scanf("%s",T),strcmp(T,"END_OF_TEXT");){
        for(i=0;T[i];T[i]=tolower(T[i]),i++);
        if(strcmp(W,T)==0)t++;
    }
    printf("%d\n",t);
}

Measured memory_bytes: 1828
H_list=[]
W_list=[]
while True:
  H,W = map(int, input().split())
  if H == 0 and W == 0: 
    break
  H_list.append(H)
  W_list.append(W)
  
for (Hlist, Wlist) in zip(H_list,W_list):
  for i in range(Hlist):
    for j in range(Wlist):
        if (i%2==0 and j%2==0) or (i%2!=0 and j%2!=0 ):
            print("#", end="")
        else:
            print(".", end="")
    print()
  print()


Measured memory_bytes: 7008
#include <iostream>
using namespace std;
int main() {
  int a, b, c;
  cin >> a;
  cin >> b;
  cin >> c;

  for (int i = 0; i < 100; i++) {
    if (a * i % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int i,j,k,tmp;
  
    scanf("%d %d %d",&i,&j,&k);
  tmp=i;
  i=j;
  j=tmp;
  tmp=i;
  i=k;
  k=tmp;
  printf("%d %d %d\n",i,j,k);
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;int main(){
  int n;
  vector<int> a;
  cin>>n;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    a.push_back(x);
  }
  a.erase(unique(a.begin(),a.end()),a.end());
  for(int i=0;i<a.size();i++){
    if(i!=0) cout<<" ";
    cout<<a[i];
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const ll MOD = 1000000007;
using pint = pair<ll, ll>;

int main() {
  ll N;
  cin >> N;
  vector<ll> rate(9, 0);
  for (int i = 0; i<N; i++){
    ll tmp = 0;
    cin >> tmp;
    if (tmp >= 1 && tmp <= 399) rate[0]++;
    if (tmp >=400 && tmp <= 799) rate[1]++;
    if (tmp >= 800 && tmp <= 1199) rate[2]++;
    if (tmp >= 1200 && tmp <= 1599) rate[3]++;
    if (tmp >= 1600 && tmp <= 1999) rate[4]++;
    if (tmp >= 2000 && tmp <= 2399) rate[5]++;
    if (tmp >= 2400 && tmp <= 2799) rate[6]++;
    if (tmp >= 2800 && tmp <= 3199) rate[7]++;
    if (tmp >= 3200) rate[8]++;
  }
  ll cnt = 0;
  for (int i = 0; i < 8; i++){
    if (rate[i] != 0) cnt++;
  }
  if(cnt==0){
      cout << 1 << " " << rate[8] << endl;
      return 0;
  }
  cout << cnt << " " <<cnt+rate[8] << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include<bitset>
using namespace std;

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

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////

int main() {

	ll N;
	cin >> N;
	vector<ll> A(N + 1), B(N + 1);
	repn(i, N) cin >> A[i] >> B[i];

	ll mn = INF;
	repn(i, N) {
		if (A[i] > B[i]) { mn = min(B[i], mn);}
	}

	ll ans = 0;
	if (mn!=INF) {
		repn(i, N)ans += A[i];
		ans -= mn;
	}

	cout << ans << endl;

	system("PAUSE");

}

Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long  n;
   cin>>n;
   if(n>=400 && n<=599) cout<<"8"<<endl;
   else if(n>=600 && n<=799) cout<<"7"<<endl;
   else if(n>=800 && n<=999) cout<<"6"<<endl;
   else if(n>=1000 && n<=1199) cout<<"5"<<endl;
   else if(n>=1200 && n<=1399) cout<<"4"<<endl;
   else if(n>=1400 && n<=1599) cout<<"3"<<endl;
   else if(n>=1600 && n<=1799) cout<<"2"<<endl;
   else if(n>=1800 && n<=1999) cout<<"1"<<endl;

 return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
const int maxn = 1000000 + 5;
ll N, M;
vector<ll> vec1, vec2;
ll ans[maxn];

class UnionFind 
{
    public:
    vector < ll > par; // 各元の親を表す配列
    vector < ll > siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1)
    {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    void init(ll sz_) 
    {
        par.resize(sz_);
        siz.assign(sz_, 1);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) 
    { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) 
    {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) 
    { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x)
    { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() 
{
    cin >> N >> M;
    for(int i = 0; i < M; i++)
    {
        int a, b; cin >> a >> b; a--; b--;
        vec1.push_back(a);
        vec2.push_back(b);
    }

    UnionFind G(N);
    ans[M-1] = N*(N-1)/2;

    for(int i = M-1; i >= 0; i--)
    {   
        if(G.issame(vec1[i], vec2[i])) ans[i-1] = ans[i];
        else
        {
            ans[i-1] = ans[i] - G.size(vec1[i]) * G.size(vec2[i]);
            G.merge(vec1[i], vec2[i]);
        }
        if(!ans[i-1]) break;
    }

    for(int i = 0; i < M; i++) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 5484
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#pragma comment(linker,"/STACK:102400000,102400000")
#define inf 0x3f3f3f3f
#define mem(x,t) memset(x,t,sizeof(x));
#define maxm 100000
typedef long long ll;
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int cost,n;
    cin>>cost>>n;
    int c[maxm],t[maxm];
    for(int i=1;i<=n;i++)
        cin>>c[i];
    for(int i=0;i<maxm;i++)
    {
        t[i]=inf;
    }
    t[0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=cost;j++)
        {
            if(j>=c[i])
                t[j]=min(t[j],t[j-c[i]]+1);
        }
    }
    cout<<t[cost]<<endl;
    return 0;
}



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

int main() {
    // 入力
    int N, A;
    cin >> N >> A;

    // 処理
    int L = A;
    int R = A + N - 1;

    int eat;
    if (R <= 0)
        eat = R;
    else if (L >= 0)
        eat = L;
    else
        eat = 0;

    int answer = (R + L) * (R - L + 1) / 2 - eat;

    // 出力
    cout << answer << endl;

    return 0;
}

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

int main()
{
  int n, tarosc=0, hanakosc=0;
  string taro, hanako;
  cin >> n;
  for(int i=0;i<n;i++)
    {
      cin >> taro >> hanako;
      if(taro == hanako)
	{
	  tarosc += 1;
	  hanakosc += 1;
	}
      else if(taro > hanako)
	{
	  tarosc += 3;
	}
      else if(taro < hanako)
	{
	  hanakosc += 3;
	}
    }
  cout << tarosc << " " << hanakosc << endl;
}

Measured memory_bytes: 1208
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int graph[201][201] = {};
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			char c;
			cin >> c;
			graph[i][j] = c - '0';
		}
	}
	vector<int> color(n, -1);
	color[0] = 0;
	queue<int> qu;
	qu.push(0);
	while(!qu.empty()){
		int now = qu.front();
		qu.pop();
		for(int i = 0; i < n; i++){
			if(graph[now][i] == 0) continue;
			if(color[i] == -1){
				color[i] = (color[now] + 1) % 2;
				qu.push(i);
			} else if(color[i] == color[now]){
				cout << -1 << endl;
				return 0;
			}
		}
	}

	int ans = 0;
	for(int i = 0; i < n; i++){
		vector<int> len(n, -1);
		len[i] = 1;
		qu.push(i);
		int res = 1;
		while(!qu.empty()){
			int now = qu.front();
			qu.pop();
			for(int j = 0; j < n; j++){
				if(graph[now][j] == 1 && len[j] == -1){
					len[j] = len[now] + 1;
					res = max(res, len[j]);
					qu.push(j);
				}
			}
		}
		ans = max(ans, res);
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
N, M = map(int, input().split())
queans = []
wa = [0] * N
ac = [0] * N
for i in range(M):
  a,b=input().split()
  queans.append((int(a), b))
for i in range(M):
  Q = queans[i][0]
  A = queans[i][1]
  if(A == 'AC'):
    ac[Q-1] = 1 
  else:
    if(ac[Q-1] != 1):
      wa[Q-1] += 1
      
acsum = 0
wasum = 0
for j in range(N):
  acsum += ac[j]
  if(ac[j] != 0):
    wasum += wa[j]

print(acsum, wasum)

Measured memory_bytes: 20556
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int K = nextInt();
        int N = nextInt();

        int[] A = new int[N];
        Arrays.setAll(A, i->nextInt());

        int dis = K-A[N-1] + A[0];
        for(int i=1; i<N; i++){
            dis = Math.max(dis, A[i]-A[i-1]);
        }

        println(K-dis);
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 51404
#include<stdio.h>
#define NIL -1
#define MAX 10000

typedef struct{
  int p, l, r;
}Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int, int);
int setHeight(int);
int getSibling(int);
void print(int);

int main(){
  int v, l, r, root;
  int i;

  scanf("%d", &n);

  /*Initialize*/
  for(i=0;i<n;i++)
    {
      T[i].p = NIL;
    }

  for(i=0;i<n;i++)
    {
      scanf("%d%d%d", &v, &l, &r);
      T[v].l = l; T[v].r = r;
      if( l != NIL) T[l].p = v;
      if( r != NIL) T[r].p = v;
    }

  for( i = 0; i < n; i++)
    {
      if( T[i].p == NIL ) root = i;
    }

  setDepth(root, 0);
  setHeight(root);

  for( i = 0; i < n; i++)
    {
      print(i);
    }
return 0;
}

void setDepth(int u, int d)
{
  if( u == NIL )return;
  D[u] = d;
  setDepth(T[u].l, d + 1);
  setDepth(T[u].r, d + 1);
}

int setHeight(int u)
{
  int h1 = 0, h2 = 0;
  if( T[u].l != NIL ) h1 = setHeight(T[u].l) + 1;
  if( T[u].r != NIL ) h2 = setHeight(T[u].r) + 1;

  if( h1 > h2 ) return H[u] = h1;
  else return H[u] = h2;
}

int getSibling(int u)
{
  if( T[u].p == NIL ) return NIL;
  if( T[T[u].p].l != u && T[T[u].p].l != NIL )return T[T[u].p].l;
  if( T[T[u].p].r != u && T[T[u].p].r != NIL )return T[T[u].p].r;
  return NIL;
}

void print(int u)
{
  printf("node %d: parent = %d, sibling = %d, ", u, T[u].p, getSibling(u));
  int deg = 0;
  if( T[u].l != NIL ) deg++;
  if( T[u].r != NIL ) deg++;
  printf("degree = %d, depth = %d, height = %d, ", deg, D[u], H[u]);

  if(T[u].p == NIL)printf("root\n");
  else if(T[u].l == NIL && T[u].r == NIL)printf("leaf\n");
  else printf("internal node\n");
}



Measured memory_bytes: 1964
#079_D
h, w = map(int,input().split())
c = [list(map(int,input().split())) for _ in range(10)]
a = [list(map(int,input().split())) for _ in range(h)]

def warshall_floyd(d, v):
    for k in range(v):
        for i in range(v):
            for j in range(v):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
            
warshall_floyd(c, 10)
res = 0
for i in range(h):
    for j in range(w):
        if a[i][j] != -1:
            res += c[a[i][j]][1]
print(res)

Measured memory_bytes: 40284
N = int(input())
A = list(map(int, input().split()))

sumF = 0
maxa = A[0]
fumidai = 0
for i in range(N-1):
  if A[i] > A[i+1]:
    sumF += A[i] - A[i+1]
    A[i+1] = A[i]
print(sumF)

Measured memory_bytes: 94144
#include<bits/stdc++.h>
using namespace std;
int dp1[105][105],dp2[105][105],h,w;
string s;
bitset<105>a[105];
int main()
{
	memset(dp1,0x3f,sizeof(dp1));
	memset(dp2,0x3f,sizeof(dp2));
	dp1[0][1]=0;
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++)
	{
		cin>>s;
		for(int j=1;j<=w;j++)a[i][j]=(s[j-1]=='#');
	}
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)if(a[i][j])dp2[i][j]=min(min(dp1[i-1][j],dp1[i][j-1])+1,min(dp2[i][j-1],dp2[i-1][j]));
	else dp1[i][j]=min(min(dp1[i-1][j],dp1[i][j-1]),min(dp2[i-1][j],dp2[i][j-1]));
	printf("%d",min(dp1[h][w],dp2[h][w]));
	return 0;
}


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

n, m, k = map(int, input().split())

class UnionFind:
    def __init__(self, n):
        self.p = [-1]*n
        self.c = None

    def find(self, x):
        if self.p[x] < 0:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def union(self, x, y):
        rx, ry = self.find(x), self.find(y)
        if rx != ry:
            self.p[ry] += self.p[rx]
            self.p[rx] = ry

    def count_member(self, x):
        return -self.p[self.find(x)]


uf = UnionFind(n)

ab = []
for i in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    ab.append((a, b))
    uf.union(a, b)

cd = [list(map(lambda x: int(x)-1, input().split())) for _ in range(k)]
ans = [uf.count_member(i)-1 for i in range(n)]

for a, b in ab:
    if uf.find(a) == uf.find(b):
        ans[a] -= 1
        ans[b] -= 1

for c, d in cd:
    if uf.find(c) == uf.find(d):
        ans[c] -= 1
        ans[d] -= 1

print(*ans)


Measured memory_bytes: 61072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


int main() {
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n/2; i++){
        if(i != n-i){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int e = (a + d - 1) / d;
  int f = (c + b - 1) / b;
  //   dmp(e);
  //   dmp(f);
  if (e < f) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  for (int i=0;i<3;i++){
if(s.at(i)=='1'){s.at(i)='9';
                continue;}
    else if(s.at(i)=='9'){s.at(i)='1';
                         continue;}
  }
  cout<<s<<endl;
}


Measured memory_bytes: 3576
#[allow(unused_macros)]
macro_rules ! for_ { ( $ init : stmt ; $ cond : expr ; $ incr : expr , $ body : block ) => ( { $ init ; while $ cond { $ body $ incr ; } } ) ; }

#[allow(dead_code)]
pub const M: u64 = 1_000_000_007;

fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: u64 = iter.next().unwrap().parse::<u64>().unwrap();
    let m: u64 = iter.next().unwrap().parse::<u64>().unwrap();
    
    let factors = prime_factors(m);
    let mut ret = 1u64;
    for (_, value) in factors.iter() {
        ret *= comb(value + n - 1, *value);
        ret %= M;
    }
    println!("{}", ret);
}

fn comb(n: u64, r: u64) -> u64 {
    let mut ret = 1u64;
    for_!(let mut i = 0; i < r; i+=1, {
        ret *= n - i;
        ret %= M;
    });
    for_!(let mut i = 1; i < r+1; i+=1, {
        ret *= modinv(i as i64, M as i64) as u64;
        ret %= M;
    });
    ret
}

#[doc = " n>=1"]
#[allow(dead_code)]
fn is_prime(n: u64) -> bool {
    for_ ! ( let mut i = 2 ; i * i <= n ; i += 1 , { if n % i == 0 { return false ; } } );
    n != 1
}
#[doc = " n>=1"]
#[allow(dead_code)]
fn divisors(n: u64) -> Vec<u64> {
    let mut ret = vec![];
    for_ ! ( let mut i = 1 ; i * i <= n ; i += 1 , { if n % i == 0 { ret . push ( i ) ; if i != n / i { ret . push ( n / i ) ; } } } );
    ret
}
#[allow(dead_code)]
use std::collections::HashMap;
#[doc = " n>=1"]
#[allow(dead_code)]
fn prime_factors(mut n: u64) -> HashMap<u64, u64> {
    let mut ret = HashMap::new();
    for_ ! ( let mut i = 2 ; i * i <= n ; i += 1 , { while n % i == 0 { * ret . entry ( i ) . or_insert ( 0 ) += 1 ; n /= i ; } } );
    if n != 1 {
        ret.insert(n, 1);
    }
    ret
}
#[doc = " return: (primes, is_prime)"]
#[allow(dead_code)]
fn sieve(n: usize) -> (Vec<usize>, Vec<bool>) {
    let mut primes = vec![];
    let mut is_prime = vec![true; n + 1];
    is_prime[0] = false;
    is_prime[1] = false;
    for i in 2..n + 1 {
        if is_prime[i] {
            primes.push(i);
            for_ ! ( let mut j = 2 * i ; j <= n ; j += i , { is_prime [ j ] = false ; } )
        }
    }
    (primes, is_prime)
}

#[doc = " a / b modulo m == a * modinv(b, m)"]
#[allow(dead_code)]
fn modinv(mut a: i64, m: i64) -> i64 {
    let mut b = m;
    let mut u = 1;
    let mut v = 0;
    while b != 0 {
        let t = a / b;
        a -= t * b;
        std::mem::swap(&mut a, &mut b);
        u -= t * v;
        std::mem::swap(&mut u, &mut v);
    }
    u %= m;
    if u < 0 {
        u += m
    };
    u
}

Measured memory_bytes: 4352
#!/usr/bin/perl
use strict;
use warnings;
use feature qw(:5.10);
use utf8;

<STDIN>;

my @line;
{
    while(<STDIN>){
        my @p = split(/\s+/);
        push(@line, \@p);
    }
}
my $count=0;

for(my $i=0;$i<=$#line;$i++){
    for(my $j=$i+1;$j<=$#line;$j++){
        if(distance_is_integer($line[$i], $line[$j])){
            $count++;
        }
    }
}
say $count;

sub distance_is_integer {
    my $p1 = shift;
    my $p2 = shift;
    my $d2 = 0;
    for(my $i=0;$i<=@{$p1}-1;$i++){
        $d2 += (abs($p1->[$i] - $p2->[$i]))**2;
    }
    my $d = sqrt($d2);
    if($d =~ /^[0-9]+$/){
        return 1;
    }
    else {
        return 0;
    }
}


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

struct Node{
  int key;
  struct Node *right,*left,*parent;
};
struct Node *root, *NIL;

void insert(int k){
  struct Node *y = NIL;
  struct Node *x =root;
  struct Node *z;

  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key < y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}

void inorder(struct Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}



int main(){
  int i,n,x;
  char com[10];
  char s1[10]="insert";
  char s2[10]="print";
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(strcmp(com,s1)==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(com,s2)==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 25120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
const int mx=1e6+5;
long long c[mx];
long long n,d,a;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	/*freopen(".in", "r", stdin);
	freopen(".out", "w", stdout); 
    */	
	cin >> n >> d >> a;
	vector < pair < long long ,long long > > v;
	for(int i=0;i<n;++i){
		ll x,y;cin >> x >> y;
		v.pb(mp(x,y));
	}
	long long ans=0;
	sort(v.begin(),v.end());
	ll j=0;
	for(ll i=0;i<n;++i){
		//j=0;
		while(j<n and v[j].first<=v[i].first+2*d)
			++j;
		ll need=max((v[i].second-c[i]*a+a-1)/a,0ll);
		ans+=need;
		c[j]=c[j]-need;
		c[i]+=need;
		c[i+1]+=c[i];
		//cout << need <<" "<< i << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6512