akhauriyash/Code-Regression huggingface dataset:
#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>
#include <stack>
#include <queue>
#include <list>
#include <cstring>
#include <unordered_set>
#include <cmath>
#include <iomanip>
#include <map>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::getline(stream, buf);
		std::stringstream sstr(buf);

		std::vector<int> retval;
		retval.reserve(num);

		std::string input;;
		for (int i = 0; i < num && std::getline(sstr, input, delim); ++i)
		{
			retval.push_back(std::stoi(input));
		}

		return retval;
	}

	int GetValue(std::istream& stream)
	{
		int in;
		stream >> in;

		return in;
	}

	std::vector<std::string> GetValueString(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<std::string> retval;
		retval.reserve(num);

		std::getline(stream, buf);
		std::stringstream sstr(buf);

		for (int i = 0; i < num && std::getline(sstr, buf, delim); ++i)
		{
			retval.push_back(std::move(buf));
		}

		return retval;
	}

	template<typename Itr>
	void PrintLine(Itr begin, Itr end)
	{
		bool first = true;

		for (int i = 0; begin != end; ++begin, ++i)
		{
			if (!first)
			{
				std::cout << ' ';
			}

			std::cout << (*begin);

			first = false;
		}
		std::cout << std::endl;
	}

	template<typename T>
	void Print(const std::vector<T>& sequence)
	{
		for (const auto& e : sequence)
		{
			std::cout << e << '\n';
		}

		std::cout << std::flush;
	}

}

int main(int argc, char* argv[])
{
	auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;
	if (argc == 1)
	{
		std::cin.tie(0);
		std::ios::sync_with_stdio(false);
	}

	int n1, n2, n3;
	stream >> n1 >> n2 >> n3;

	if (22 <= n1 + n2 + n3)
	{
		std::cout << "bust" << std::endl;
	}
	else
	{
		std::cout << "win" << std::endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
//v?????????????????卒??????v?????????(??????)
//??\?賊??????属????????????1????????????(??卒?????????)
using namespace std;
int main(){
  int floor[4][3][10]={{{}}},n,b,f,r,v;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> b >> f >> r >> v;
    floor[b-1][f-1][r-1] += v;
  }
  for(int i=0;i<4;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<10;k++){
	cout << " " << floor[i][j][k];
      }
      cout << endl;
    }
    if(i!=3)
    cout << "####################" << endl; //?????贈(??????)
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.size();
    ll ans = INF;
    map<ll,ll> mp;
    rep(i,0,N){
        mp[S[i]]++;
    }
    rep(i,0,26){
        char c = i + 'a';
        if(mp[c] == 0) continue;
        ll cnt = 0;
        string ss = S;
        bool ok = true;
        rep(i,0,ss.size()){
            if(ss[i] != c) ok = false;
        }
        if(ok){
            ans = 0;
            continue;
        }
        while(1){
            string tt = "";
            ll sz = ss.size();
            rep(i,0,sz-1){
                if(ss[i] == c || ss[i+1] == c){
                    tt += c;
                }else{
                    tt += ss[i];
                }
            }
            cnt++;
            bool ok = true;
            rep(i,0,tt.size()){
                if(tt[i] != c) ok = false;
            }
            ss = tt;
            if(ok) break;
        }
        ans = min(ans, cnt);
    }
    print(ans);

 }

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
#define fprint(NUM,X) cout << fixed << setprecision(NUM) << (X) << endl
#define fprints(NUM,X,Y) cout << fixed << setprecision(NUM) << (X) << " " << (Y) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];
double w[1000],v[1000];
double box[200010];

ll fib(int i){
  if(i == 1 || i == 0)return 1;
  if(d[i] != 0)return d[i];
  return d[i] = fib(i-1) + fib(i-2);
}

int main(){
  cin >> n;
  print(fib(n));
  return 0;
}


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

public class Main {

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

	void run() {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int C = sc.nextInt();
		int[] s = new int[N];
		int[] t = new int[N];
		int[] c = new int[N];
		int[][] a = new int[C][100000];
		for (int i = 0; i < N; ++i) {
			s[i] = sc.nextInt();
			--s[i];
			t[i] = sc.nextInt();
			--t[i];
			c[i] = sc.nextInt();
			--c[i];
			for (int j = s[i]; j <= t[i]; ++j) {
				if (a[c[i]][j] == 0)
					a[c[i]][j]++;
			}
		}

		int ans = 0;
		for (int i = 0; i < 100000; ++i) {
			int tmp = 0;
			for (int j = 0; j < C; ++j) {
				tmp += a[j][i];
			}
			ans = Math.max(ans, tmp);
		}
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 112000
#include <stdio.h>


int main () {
    int n, x[50], y[50], i, seq = 0;

    while ((scanf("%d", &n)) != EOF && n) {
        double area = .0;
        int j;
        for (i = 0; i < n; i++) {
            scanf("%d%d", &x[i], &y[i]);
        }

        for (i = 0; i < n; i++) {
            j = (i + n -1) % n;
            area += (x[i] - x[j]) * (y[i] + y[j]);
        }

        printf("%d %.1f\n", ++seq, area * .5);
    }

    return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using P = pair<ll,ll>;
// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0) x /= p, ++y;
      if (y != 0) res.emplace_back(p,y);
    }
    if (x != 1) res.emplace_back(x,1);
    return res;
  }
};

template <typename T> vector<pair<T, T>> prime_factor(T n) {
    vector<pair<T, T>> ret;
    for (T i = 2; i * i <= n; i++) {
        T tmp = 0;
        while (n % i == 0) {
            tmp++;
            n /= i;
        }
        if(tmp != 0) ret.push_back(make_pair(i, tmp));
    }
    if (n != 1) ret.push_back(make_pair(n, 1));
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    Sieve s(1e6);
    set<ll> x;
    bool pairwise_comp = true;
    rep(i,n) {
        vector<pair<ll,ll>> pf = prime_factor(a[i]);
        for(auto p: pf) {
            if(x.find(p.first) != x.end()) {
                pairwise_comp = false;
                break;
            } else {
                x.insert(p.first);
            }
            if(pairwise_comp == false) break;
        }
    }
    if(pairwise_comp) {
        cout << "pairwise coprime" << endl;
        return 0;
    }
    ll gcd = a[0];
    rep(i,n-1) {
        gcd = __gcd(gcd,a[i+1]);
    }
    if(gcd == 1) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }
}


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

int main()
{
    char s[26];
    cin >> s;

    int n = strlen(s);

    string ans = "yes";

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (s[i] == s[j]) {
                ans = "no";
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
   string s;
  int h[26],i;
  cin>>s;
  for(i=0;i<26;++i)
       h[i]=0;
  
  for(i=0;i<s.length();++i)
  {
     h[s[i]-97]++;
  }
  
  int flag=0;
  for(i=0;i<26;++i)
  {
    if(h[i]%2!=0)
    {
      flag=1;
      break;
    }
  }
  if(flag==1)
      printf("No");
  
  else
     printf("Yes");
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_L = 2e5;
ll L;
ll a[MAX_L];
ll dp[MAX_L + 1][6];
ll func(ll i, ll k){
   if(k == 1 || k == 5) return a[i];
   if(k == 2 || k == 4) return (a[i] == 0) ? 2 : a[i] % 2;
   else return 1 - (a[i] % 2);
}
int main(){
   cin >> L;
   REP(i, L) cin >> a[i];
   REP(k, 6) dp[0][k] = 0;
   REP(i, L) dp[i + 1][0] = INF;

   REP(i, L){
      REP(k, 5){
         dp[i + 1][k + 1] = dp[i + 1][k];
         dp[i + 1][k + 1] = min(dp[i + 1][k], dp[i][k + 1] + func(i, k + 1));
      }
   }
   cout << dp[L][5] << endl;

}


Measured memory_bytes: 11264
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int n;
    int64_t a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    int64_t s = b - a;

    rep(i, n)
    {
        int j = n - 1 - i;

        int64_t lb = i * c - j * d, ub = i * d - j * c;
        if (lb <= s && s <= ub) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(){
	int a,b,c;
	int d[4];
	cin>>a>>b>>c;
	d[0]=abs(a-b);
	d[1]=abs(a-c);
	d[2]=abs(b-c);
	sort(d,d+3);
	cout<<d[0]+d[1]<<endl;
	return 0;
}

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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    int res = 0;
    for(int i = 1; i < n; i++){
        vector<bool> alpha(26,false);
        int ans = 0;
        for(int j = 0; j < i; j++){
            alpha[s[j] - 'a'] = true;
        }
        for(int j = i; j < n; j++){
            if(alpha[s[j] - 'a']){
                alpha[s[j] - 'a'] = false;
                ans++;
            }
        }
        if(res < ans){
            res = ans;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#define llint long long

using namespace std;

struct UnionFind{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};

llint n, m, Q;
llint u[100005], v[100005], t[100005];
set<llint> S;
UnionFind uf(100005);

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m >> Q;
	for(int i = 1; i <= Q; i++) cin >> u[i] >> v[i] >> t[i];
	
	llint cnt = 0;
	for(int i = 1; i <= Q; i++){
		if(t[i] == 0) uf.unite(u[i], v[i]), cnt++;
	}
	for(int i = 1; i <= Q; i++){
		if(t[i] == 1 && uf.same(u[i], v[i])){
			cout << "No" << endl;
			return 0;
		}
	}
	
	for(int i = 0; i < n; i++) S.insert(uf.root(i));
	llint c = S.size();
	
	llint l = n - 1, r = n-c + c*(c-1)/2;
	
	if(cnt == Q){
		if(l <= m && m <= r) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else{
		if(l < m && m <= r) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

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

float A, B, T;


int main()
{

    cin >> A >> B >> T;
    float res = 0;
    for(int i = 1; T - i*A >= 0; ++i )
    {
        res += B;
    }
    cout <<  res << endl ;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    ll ans = 0;
    ll A[N+1]; rep(i, N+1) cin >> A[i];
    if(N == 0) {if(A[0] == 1) cout << 1 << endl; else cout << -1 << endl;}
    else{
        if(A[0] != 0) cout << -1 << endl;
        else{
            ans = 1;
            vector<ll> revsum(N+1, 0);
            revsum[N] = A[N];
            for(int i = N-1; i >= 0; i--) revsum[i] = revsum[i+1] + A[i];
            ll par_nodenum = 1; //一個上のノードの個数
            for(int i = 1; i <= N; i++){
                //par_nodenum*2 は伸ばせる
                //par_nodenum*2 <= A[i] なら-1
                //else -> min(revsum[i] - A[i], par_nodenum*2 - A[i]) がこの階層の葉でないノード数
                if(par_nodenum*2 < A[i]){
                    cout << -1 << endl;
                    return 0;
                }
                else if(par_nodenum*2 == A[i]){
                    if(i == N) ans += A[i];
                    else{
                        cout << -1 << endl;
                        return 0;
                    }
                }
                else{
                    par_nodenum = min(revsum[i] - A[i], par_nodenum*2 - A[i]);
                    ans += par_nodenum + A[i];
                }
            }
            cout << ans << endl;
        }
    }
    return 0;
}

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

int main()
{
        int n, b, f, r, v;
        int regident[4][3][10] = {0}; // <--- input number of people.

        cin >> n;

        for(int i = 0; i < n; i++) {
                cin >> b >> f >> r >> v;
                regident[b-1][f-1][r-1] += v;
        }


        for(int i = 0; i < 4; i++) {
          for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 10; k++) {
                cout << ' ' << regident[i][j][k];
            }
            cout << endl;
          }
          if(i != 3) cout << "####################" << endl;
        }

        return 0;
}


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

#define equals(a, b) (fabs((a)-(b)) < EPS)
const double EPS = (1e-10);

class Point {
public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p) {
        return Point(x+p.x, y+p.y);
    }
    Point operator - (Point p) {
        return Point(x-p.x, y-p.y);
    }
    Point operator * (double a) {
        return Point(x*a, y*a);
    }
    Point operator / (double a) {
        return Point(x/a, y/a);
    }

    double abs() {
        return sqrt(norm());
    }
    double norm() {
        return x*x + y*y;
    }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
    }
};

typedef Point Vector;
// 内積
double dot(Vector a, Vector b) {
    return a.x*b.x + a.y*b.y;
}
// 外積
double cross(Vector a, Vector b) {
    return a.x*b.y - a.y*b.x;
}

class Segment {
public:
    Point p1, p2;

    Segment(Point p1, Point p2): p1(p1), p2(p2) {}
};
typedef Segment Line;

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
int ccw(Point p0, Point p1, Point p2) {
    Vector a = p1 - p0;
    Vector b = p2 - p0;

    if (cross(a, b) > EPS) return COUNTER_CLOCKWISE;
    if (cross(a, b) < -EPS) return CLOCKWISE;
    if (dot(a, b) < -EPS) return ONLINE_BACK;
    if (a.norm() < b.norm()) return ONLINE_FRONT;

    return ON_SEGMENT;
}

int main(void) {
    int x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;
    Point p0(x0, y0), p1(x1, y1);

    int q; cin >> q;
    int x, y;
    for (int i = 0; i < q; i++) {
        cin >> x >> y;
        Point p2(x, y);

        switch(ccw(p0, p1, p2)) {
        case COUNTER_CLOCKWISE:
            cout << "COUNTER_CLOCKWISE" << endl;
            break;
        case CLOCKWISE:
            cout << "CLOCKWISE" << endl;
            break;
        case ONLINE_BACK:
            cout << "ONLINE_BACK" << endl;
            break;
        case ONLINE_FRONT:
            cout << "ONLINE_FRONT" << endl;
            break;
        case ON_SEGMENT:
            cout << "ON_SEGMENT" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
struct edges
{
	int to,next;
}edge[202020];
int first[101010],now;
void adde(int x,int y)
{
	now++;
	edge[now].to=y;
	edge[now].next=first[x];
	first[x]=now;
}
char s[101010];
int nd[101010];
int siz[101010],d[101010];
int dep[101010];
int fa[101010];
int cv[101010];
void work(int p)
{
	siz[p]=nd[p];
	for(int e=first[p];e;e=edge[e].next)
		if(edge[e].to!=fa[p])
		{
			fa[edge[e].to]=p;
			dep[edge[e].to]=dep[p]+1;
			work(edge[e].to);
			if(siz[edge[e].to])
			{
				siz[p]+=siz[edge[e].to];
				d[p]++;
			}
		}
}
int dp0[101010],dp1[101010];
int ans1=0;
void work1(int p)
{
	int h0,h1;
	dp0[p]=dp1[p]=0;
	for(int e=first[p];e;e=edge[e].next)
		if(edge[e].to!=fa[p]&&siz[edge[e].to])
		{
			work1(edge[e].to);
			h0=dp0[edge[e].to]+cv[edge[e].to]-1;
			h1=dp1[edge[e].to]+cv[p]-1;
			ans1=min(ans1,dp0[p]+h1);
			ans1=min(ans1,dp1[p]+h0);
			dp0[p]=min(dp0[p],h0);
			dp1[p]=min(dp1[p],h1);
		}
}
int main()
{
	int n,x,y,rt,ans=0;
	scanf("%d",&n);
	memset(first,0,sizeof(first));
	now=0;
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		adde(x,y);
		adde(y,x);
	}
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
		if(s[i]=='W')
			nd[i]=1;
		else
			nd[i]=0;
	fa[1]=0;
	siz[0]=0;
	memset(d,0,sizeof(d));
	work(1);
	rt=1;
	dep[1]=0;
	for(int i=1;i<=n;i++)
		if(siz[i]==siz[1]&&dep[i]>dep[rt])
			rt=i;
	if(siz[1]==0)
	{
		printf("0");
		return 0;
	}
	for(int i=2;i<=n;i++)
		if(siz[i]&&dep[fa[i]]>=dep[rt])
			d[i]++;
	for(int i=1;i<=n;i++)
		if(dep[i]>=dep[rt]&&siz[i])
		{
			ans+=d[i];
			if((d[i]&1)==nd[i])
				cv[i]=1;
			else
			{
				cv[i]=-1;
				ans++;
			}
		}
	work1(rt);
	printf("%d",ans+ans1);
	return 0;
}

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

int main(void)
{
	int n, mod, d1[31], d2[31];
	long x[1000], y[1000], k, u, v;
	char ans[31];
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%ld%ld", &x[i], &y[i]);
	}
	k=2000000000;
	mod=((x[0]+y[0])+k+2)%2;
	for (int i = 0; i < n; ++i)
	{
		if (((x[i]+y[i])+k+2)%2 != mod)
		{
			printf("%d\n", -1);
			return 0;
		}
	}

	if (mod==0)
	{
		printf("%d\n", 32);
		for (int i = 0; i < n; ++i)
		{
			x[i]-=1;
		}
		printf("%d ", 1);
		for (int i = 0; i < 31; ++i)
		{
			printf("%ld ", (long)pow(2,i));
		}
		printf("\n");
	}
	else
	{
		printf("%d\n", 31);
		for (int i = 0; i < 31; ++i)
		{
			printf("%d ", (int)pow(2,i));
		}
		printf("\n");
	}
	for (int j = 0; j < n; ++j)
	{
		u=(x[j]+y[j]-1)/2+(long)pow(2,30);
		v=(x[j]-y[j]-1)/2+(long)pow(2,30);
		for (int i = 30; i >= 0; i--)
		{
			if (u>=(long)pow(2, i))
			{
				d1[i]=1;
				u-=(long)pow(2, i);
			}
			else
			{
				d1[i]=0;
			}
			if (v>=(long)pow(2, i))
			{
				d2[i]=1;
				v-=(long)pow(2, i);
			}
			else
			{
				d2[i]=0;
			}
			if (d1[i]==1 && d2[i]==1)
			{
				ans[i]='R';
			}
			else if (d1[i]==1 && d2[i]==0)
			{
				ans[i]='U';
			}
			else if (d1[i]==0 && d2[i]==1)
			{
				ans[i]='D';
			}
			else if (d1[i]==0 && d2[i]==0)
			{
				ans[i]='L';
			}
		}
		if (mod==1)
		{
			printf("%s\n", ans);
		}
		else
		{
			printf("R%s\n", ans);
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define double long double
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

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

    int a;
    cin >> a;
    cout << (a + a * a + a * a * a) << '\n';

    fflush(stdout);
    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<numeric>

using namespace std;

int par[1001];

int find(int x){
  return (par[x]==x)?x:par[x]=find(par[x]);
}

bool unite(int a,int b){
  int pa=find(a);
  int pb=find(b);
  par[pa]=pb;
  return pa!=pb;
}

int main(){
  for(int n,m;cin>>n>>m,n;){
    int s[10000],t[10000],c[10000];
    for(int i=0;i<m;i++){
      cin>>s[i]>>t[i]>>c[i];
    }
    int l=0,h=1000;
    while(h-l>1){
      int mid=(h+l)/2;
      iota(begin(par),end(par),0);
      int nu=0;
      for(int i=0;i<m;i++){
	if(c[i]<=mid){
	  nu+=unite(s[i],t[i]);
	}
      }
      if(nu>=n/2){
	h=mid;
      }else{
	l=mid;
      }
    }
    cout<<h<<endl;
  }
}

Measured memory_bytes: 1280
#include <iostream>
#include <sstream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#define n 100
using namespace std;
int main(){
	int a[n],b[n];
	int c = 0;
	int d,e;
	char f;
	while(1){
		cin >> d >> f >> e;
		if(d+e==0) break;
		a[c] = d;
		b[c] = e;
		c++;
	}
	while(1){
		bool out = true;
		for(int i=0;i<c-1;i++){
			if(b[i]<b[i+1]){
				out = false;
				int t = b[i];
				b[i] = b[i+1];
				b[i+1] = t;
				t = a[i];
				a[i] = a[i+1];
				a[i+1] = t;
			}
		}
		if(out) break;
	}
	while(cin >> d){
		int s = 1;
		int t = b[0];
		for(int i=0;i<c;i++){
			if(b[i]!=t){
				t = b[i];
				s++;
			}
			if(d==a[i]) break;
		}
		cout << s << endl;
	}
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


signed main() {
    long double a, b, c; cin >> a >> b >> c;
    long double eps = 1e-15;
    if (sqrt(a) + sqrt(b) + eps < sqrt(c)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々


Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n;
	cin>>n;
	cout<<n*(n-1)/2<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}







Measured memory_bytes: 3472
import sys
import itertools
import math

def propare():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    
    tokens = iterate_tokens()
    N = int(next(tokens))
    x_list = []
    y_list = []
    for i in range(N):
        x_list.append(int(next(tokens)))
        y_list.append(int(next(tokens)))

    solve(N, x_list, y_list)

def solve(N: int, x_list: list, y_list: list):
    total_dist = 0
    for n_iter in itertools.permutations(range(N)):
        total_dist += measure_distance(n_iter, x_list, y_list)
    print(total_dist/math.factorial(N))
    return

def measure_distance(n_iter: tuple, x_list: list, y_list: list):
    dist = 0
    for i in range(len(n_iter)-1):
        tmp_dist_x = x_list[n_iter[i]] - x_list[n_iter[i+1]]
        tmp_dist_y = y_list[n_iter[i]] - y_list[n_iter[i+1]]
        dist += math.sqrt(tmp_dist_x**2 + tmp_dist_y**2)
    return dist

if __name__ == "__main__":
    propare()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x;
void solve()
{
    ll a,b,k;
    ll A,B;
    cin>>a>>b>>k;
    A=k-a;
    B=b-A;
    ll ans=a-k;
    if(B<0)
        B=0;
    if(a-k<0)
        ans=0;
    //cout<<A<<" "<<B;
    if(k>a)
      cout<<0<<" "<<B<<endl;
    else
      cout<<ans<<" "<<b<<endl;

}

int main()
{
#ifndef oj
    // freopen("in", "r", stdin);
    //freopen("out.txt","w",stdout);
#endif
    // system("cls");
    //getchar();

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



}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){

    int N, M;
    cin >> N >> M;
    
    int ans[51] = {};
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        ans[a]++;
        ans[b]++;
    }
    
    for(int i = 1; i <= N; i++){
        cout << ans[i] << endl;
    }
    
    
    

}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  cout<<n*n*n<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+7;
const ll mod = 1e9 + 7;
#define afdafafafdafaf y1;
int ar[maxn], n, m, k;


int main()
{
    cin>>n;
    for(int i=1;i<=9;i++){
        if(n % i == 0 && n / i >= 1 && n / i <= 9){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
 
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vpi;
typedef map<int,int> mapii;
typedef map<int,bool> mapib;
typedef map<char,int> mapci;

#define small 1e-9
#define big5 1000000005
#define big7 1000000007
#define big 100000
#define large 200001
#define pi 3.1415926

#define inp(arr,n) for(int i=0;i<n;i++)cin>>arr[i];
#define cum(arr,n,cumm) cumm[0]=0;for(int i=0;i<n;i++)cumm[i+1]=cumm[i]+arr[i];
#define bsdk ios_base::sync_with_stdio(false);cin.tie(NULL);
#define disp(arr) for(auto i:arr)cout<<i<<" ";cout<<"\n"
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define m1 cout<<"-1\n"
#define nl <<endl
#define hs cout<<"#"

#define fori(a, b, c) for (a = (b); (a) <= (c); ++(a))
#define ford(a, b, c) for (a = (b); (a) >= (c); --(a))
#define rep(i,n) fori(i,0,n-1)
#define rep1(i,n) fori(i,1,n-1)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define ub upper_bound
#define lb lower_bound
#define allv(v) v.begin(), v.end()
#define sorti(v) sort(allv(v))
/*bool isprime[big+1];
vector<int> primes;
void makesieve()
{
    ll i,j;
    rep(i,1000001)
        isprime[i]=false;
    isprime[2]=true;
    for(i=3;i<=big;i+=2)
        isprime[i]=true;
    for(i=3;i<=big;i+=2)
    {
        if(isprime[i])
            for(j=i*i;j<=big;j+=i)
            isprime[j]=false;
    }
    rep(i,big+1)
    {
        if(isprime[i])
            primes.pb(i);
    }
}
ll poww(ll n,ll m){
    if(m==0)return 1;
    if(m==1)return n;
    ll ans = poww(n,m/2);
    if(m%2==1) return (ans*ans)*n;
    else return (ans*ans);
}*/
ll f(ll n)
{
    ll l=0,h=n,mid;
    ll ans=0;
    while(l<=h)
    {
        mid=(l+h)/2;
        if((mid*(mid+1))/2 <= n)
           {
               ans=mid;
               l=mid+1;
           }
           else
            h=mid-1;
    }
    return ans;
}
void solve()
{
   ll n,i,c;
   cin>>n;
   vector<pair<ll,ll> > v;
   for(i=2;i*i<=n;i++)
   {
       if(n%i==0)
       {
           c=0;
           while(n%i==0)
           {
               c++;
               n=n/i;
           }
           v.pb(mp(i,c));
       }
   }
   if(n!=1)
    v.pb(mp(n,1));
    //for(auto x:v)
      //  cout<<x.fi<<" "<<x.se nl;
    ll ans=0;
   for(auto x:v)
       ans+=f(x.se);
   cout<<ans;
}
int main()
{
    bsdk
    int t;
    //cin>>t;
    t=1;
    while(t--) solve();
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  set<string> S;
  string x;
  rep(i, N){
     cin >> x;
    S.insert(x);
  }
  cout << S.size() << endl;
  return 0;
}

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

int main() {
  string s;
    cin >> s;
    int ans = 0;
  if (s[0] == '1') ans++;
  if (s[1] == '1') ans++;
  if (s[2] == '1') ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	int n; cin >> n; int a[n], b[n];
	Rep(i, n){
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b, b + n);
	int k = b[(n/2) - 1], l = b[(n/2)];
	Rep(i, n){
		if(a[i] <= k){
			cout << l << endl;
		}else if(a[i] >= l){
			cout << k << endl;
		}
	}
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <ctime>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, x, t;
  	cin >> n >> x >> t;
  	cout <<  (int)ceil((double)n / x) * t;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  cout<<*max_element(all(a))-*min_element(all(a))<<endl;

  return 0;

}


Measured memory_bytes: 256
n=int(input())
l=list(map(int, input().split()))
l.sort()
if n<=2:
    print(0)
    exit()
ans=0
for i in range(n):
    for j in range(i):
            for k in range(j):
                if any([i==j,j==k,k==i,l[i]==l[j],l[j]==l[k],l[k]==l[i]]):
                    continue
                if l[i]<l[j]+l[k]:
                    ans+=1
print(ans)

Measured memory_bytes: 9240
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int a = input[0];
            int b = input[1];
            Console.WriteLine(a * b % 2 == 0 ? "No" : "Yes");
        }
    }
}

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

int main() {
  int N, K, sum = 0;
  cin >> N >> K;

  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;

    if (x < K - x) {
      sum += x;
    }
    else {
      sum += K - x;
    }
  }
  cout << sum * 2 << endl;
}

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

using namespace std;
typedef long long ll;

int main() {
    ll h, w;
    cin >> h >> w;
    if (h == 1 || w == 1)cout << 1 << endl;
    else {
        ll ret = h / 2 * w;
        if (h % 2 == 1)ret += (w + 1) / 2;
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector<int64_t> p(n), q(n);
    for (auto&& pp : p) {
        cin >> pp;
    }
    for (auto&& qq : q) {
        cin >> qq;
    }
    if (p > q) {
        swap(p, q);
    }

    int64_t ans = 0;
    while (p < q) {
        ++ans;
        next_permutation(p.begin(), p.end());
    }

    cout << ans << endl;
}

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

int main(){
    int n,a,b;
    cin >> n>> a>> b;
    string s;
    cin >> s;
    int sum=0,sumf =0;
    for(int i=0;i<n;i++){
        if(s.at(i) == 'a' && a + b > sum){
            cout << "Yes" << endl;
            sum++;
        }
        else if(s.at(i) == 'b' && a + b>sum && b > sumf){
            cout << "Yes" << endl;
            sum++;
            sumf++;
        }
        else if(s.at(i) == 'c')cout << "No" << endl;
        else cout << "No" << endl;
    }
}


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

using namespace std;

constexpr long long INF64 = 1e18;

using Weight = long long;

struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};

auto operator<(const Edge &e, const Edge &f) {
  if (e.weight != f.weight)
    return e.weight > f.weight;
  else if (e.src != f.src)
    return e.src < f.src;
  else
    return e.dst < f.dst;
}

using Edges = vector<Edge>;
using Graph = vector<Edges>;
//経路復元可能
void dijkstra(const Graph &g, int s, vector<Weight> &dist, vector<int> &prev) {
  priority_queue<Edge> q;
  dist[s] = 0;
  for (q.emplace(-2, s, 0); !q.empty();) {
    Edge e = q.top();
    q.pop();
    if (prev[e.dst] != -1)
      continue;
    prev[e.dst] = e.src;
    // if(prev[t]!=-1)return;
    for (auto ge : g[e.dst]) {
      if (dist[ge.dst] > e.weight + ge.weight) {
        dist[ge.dst] = e.weight + ge.weight;
        q.emplace(ge.src, ge.dst, e.weight + ge.weight);
      }
    }
  }
}

int main() {
  cin.sync_with_stdio(false);
  int n;
  cin >> n;
  Graph g(n);
  for (int i = 0; i < n - 1; ++i) {
    int s, t, d;
    cin >> s >> t >> d;
    --s;
    --t;
    g[s].emplace_back(s, t, d);
    g[t].emplace_back(t, s, d);
  }
  int Q, K;
  cin >> Q >> K;
  vector<Weight> dist(n, INF64); //ここまでの距離が入る
  vector<int> prev(n, -1);       //最短路の親が入る
  dijkstra(g, K - 1, dist, prev);
  for (int i = 0; i < Q; ++i) {
    int s, t;
    cin >> s >> t;
    cout << dist[s - 1] + dist[t - 1] << endl;
  }
}
// be checked by AOJ(GRL-1-A).

Measured memory_bytes: 11504
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<string>
#include<vector>
char gun[100001];
int main()
{
    gets(gun);
    int i,js=0;
    for(i=1;i<strlen(gun);i++)
    if(gun[i]!=gun[i-1])
    js++;
    printf("%d\n",js);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;


template<int MOD>
struct ModInt {
    static const int Mod = MOD;
    unsigned x;
    ModInt() : x(0) { }
    ModInt(signed sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
    ModInt(signed long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
    int get() const { return (int)x; }

    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }

    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }

    ModInt inverse() const {
        signed a = x, b = MOD, u = 1, v = 0;
        while (b) {
            signed t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        if (u < 0) u += Mod;
        ModInt res; res.x = (unsigned)u;
        return res;
    }

    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1;
    while (k) {
        if (k & 1) r *= a;
        a *= a;
        k >>= 1;
    }
    return r;
}
typedef ModInt<1000000007> mint;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    mp[-1] = 3;
    for (int i = 0; i < n; ++ i) {
        int x;
        cin >> x;
        a[i] = mp[x - 1] - mp[x];
        mp[x] ++;
    }
    mint ans(1);
    for (int i = 0; i < n; ++ i) {
        ans *=  mint(a[i]);
    }
    cout << ans.get();
}

Measured memory_bytes: 5376
a,b,k = map(int,input().split())
i = 0
while i < k:
  if a%2 == 1:
    a -= 1 
  a = a//2
  b += a
    
  if k-i == 1:
    break
  if b%2 == 1:
    b -= 1 
  b = b//2
  a += b
  i += 2
print(a,b)

Measured memory_bytes: 3060
def resolve():
    A = []
    ans = "No"
    for i in range(3):
        A.append(list(map(int, input().split())))
    n = int(input())
    b = 0
    for j in range(n):
        b = int(input())
        for p in range(3):
            for q in range(3):
                if A[p][q] == b:
                    A[p][q] = 0
    for g in range(3):
        if A[g][0]+A[g][1]+A[g][2] == 0 or A[0][g]+A[1][g]+A[2][g] == 0 or A[0][0]+A[1][1]+A[2][2] == 0 or A[0][2]+A[1][1]+A[2][0] == 0:
             ans ="Yes"
    print(ans)
resolve()

Measured memory_bytes: 3064
import java.util.*;

public class Main{
	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      
      	int x = sc.nextInt();
      	int y = sc.nextInt();
      
        for(int i = 0; i <= x; i++){
        	int a = 2 * i;
          	int b = 4 * (x - i);
          	
          	if(a + b == y){
              System.out.print("Yes");
          	  return;
            }
        }
      	
        System.out.print("No");
    }
}


Measured memory_bytes: 27076
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll q; cin >> q;
	while(q--){
		ll a,b; cin >> a >> b;
		ll s = sqrt(a*b);
		if(a*b==s*s) s--;
		if(a==b) cout << 2*s << endl;
		else{
			ll ans = 2*s - 1;
			if(s*(s+1) >= a*b) ans--;
			cout << ans << endl;
		}
	}
}


Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        Console.WriteLine(GetAns(s));
    }
    public static int GetAns(string s)
    {
        var count = 0;
        var start = 0;
        var a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        foreach (var x in s)
        {
            var t = a.IndexOf(x);
            if (t <= start) count++;
            start = t;
        }
        return count;
    }
}

Measured memory_bytes: 9148