akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec; }
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

// FAIL
void fail(){ print(-1); std::exit(0); }
//void fail(){ print("No"); std::exit(0); }

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

  std::string S, T;
  std::cin >> S >> T;

  print(T+S);
  
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<stack>
using namespace std;
int main() {
	int n;
	stack<int> S;
	while(~scanf("%d",&n)) {
		if(n)
			S.push(n);
		else {
			printf("%d\n",S.top());
			S.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 1036
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,K=MAP()
AB=[LIST() for i in range(N)]

ans=0
for i in range(N):
    if K|AB[i][0]==K:
        ans+=AB[i][1]

Kb=format(K, 'b')
for i, b in enumerate(Kb):
    if b=='1':
        # あるビットが1だったら、そこは0にしてそこから先を全部1にする
        Kb2=Kb[:i]+'0'+'1'*(len(Kb[i:])-1)
        k=int(Kb2, 2)
        sm=0
        for i in range(N):
            if k|AB[i][0]==k:
                sm+=AB[i][1]
        ans=max(ans, sm)
print(ans)


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

using ll = long long;

int main()
{
    int K;
    string S;
    cin >> K >> S;
    if (K >= S.size())
    {
        cout << S;
        return 0;
    }else
    {
        for (int i = 0; i < K; i++)
        {
            cout<<S[i];
        }
        cout<<"...";
        return 0;
    }
    

}


Measured memory_bytes: 3628
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    vector<ll> x(5);
    REP(i,5) cin>>x[i];

    REP(i,5){
        if(x[i]==0){
            cout<<(i+1)<<endl;
        }
    }

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  double ave;
//cin>>str;
//cout<<str<<endl;
  cin>>a>>b;
  ave = (a + b)/2.0;
  if(ave-int(ave)>0){
    ave = ave + 1;
  }
  cout<<(int)ave<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
const ll mod = 1e9 + 7;
int main() {
  int h, w;
  cin >> h >> w;
  vector <string> a(h);
  REP(i, h) {
	cin >> a[i];
  }
  vector <vector <ll> > dp(h, vector <ll>(w, 0));
  REP(i, h) {
	REP(j, w) {
	  if (a[i][j] == '#') {
		  continue;
		}
	  if (i == 0 && j == 0) {
		  dp[i][j] = 1;
		} else if (i == 0) {
		  dp[i][j] = dp[i][j - 1];
		} else if (j == 0) {
		  dp[i][j] = dp[i - 1][j];
		} else {
		  dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % mod;
		}
	}
  }
  cout << dp[h - 1][w - 1] << endl;
  return 0;
}


Measured memory_bytes: 9216
/*

*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/hash_policy.hpp>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
#define int long long 
#define LL long long 
#define ull unsigned long long 
#define rg register 
#define pt(x) printf("%d ", x);
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 22)], *p1 = buf, *p2 = buf;
//char obuf[1<<24], *O = obuf;
//void print(int x) {if(x > 9) print(x / 10); *O++ = x % 10 + '0';}
//#define OS  *O++ = ' ';
using namespace std;
//using namespace __gnu_pbds;
const int MAXN = 1e6 + 10, INF = 1e9 + 10, mod = 1e9 + 7;
const double eps = 1e-9;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int N;
main() {
	N = read();
	int a, b;
	if(N & 1) a = N / 2 + 1, b = N / 2;
	else a = N / 2, b = N / 2;
	cout << a * b;
	return 0;
}
/*
2 2 1
1 1
2 1 1
*/

Measured memory_bytes: 256
N = int(input())
abc = '_abcdefghijklmnopqrstuvwxyz'
name = ''

def get_name(N):
    if N<=26:
        return abc[N]
    else:
        N_sub = (N-1)%26 + 1
        sub_name = abc[N_sub]
        N_new = (N - N_sub)//26
        return get_name(N_new) + sub_name
print(get_name(N))


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vi cnt(8);
  int free = 0;
  rep(i,n) {
    int a;
    cin >> a;
    if(a >= 3200) free++;
    else {
      cnt[a/400]++;
    }
  }
  int mn = 0;
  rep(i,8) {
    if(cnt[i] > 0) mn++;
  }
  if(mn == 0) cout << 1 << ' ' << free << endl;
  else cout << mn << ' ' << mn + free << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>
inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll r;cin>>r;
    if(r<1200){
        cout<<"ABC"<<endl;
    }else if(r<2800){
        cout<<"ARC"<<endl;
    }else{
        cout<<"AGC"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cmath>

using namespace std;

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

 double ans = 1.;
 for(int i = 1; i <= N; i++){
   ans = fmod(ans*i,pow(10,9)+7);
 }
 
 cout << int(ans) << "\n";
 
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


bool prime[100000];
vector<ll> primes;
void sieve() {
    fill(prime, prime + 100000, 1);
    prime[0] = prime[1] = 0;

    for (int i = 2; i < 100000; i++) {
        if (prime[i]) {
            primes.pb(i);
            for (int j = i * 2; j < 100000; j += i) {
                prime[j] = 0;
            }
        }
    }
}



int main() {
    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    vector<pair<char, int>> a;
    if (s[0] == '0') {
        a.pb(mp('1', 0));
    }
    int c = 1;
    for (int i = 1; i < n; i++) {
        if (s[i] != s[i - 1]) {
            a.pb(mp(s[i - 1], c));
            c = 1;
        }

        else {
            c++;
        }
    }

    a.pb(mp(s.back(), c));
    if (s.back() == '0') {
        a.pb(mp('1', 0));
    }

    int just = 0;
    for (auto  e : a) {
        if (e.first == '0') {
            just++;
        }
    }

    if (just <= k) {
        cout << n;
        return 0;
    }

    n = a.size();
    int b[n];
    b[0] = a[0].second;
    for (int i = 1; i < n; i++) {
        b[i] = b[i - 1] + a[i].second;
    }

    int ans = 0;
    int till = 0;
    ans = b[2 * k];
    int i = 2;
    int j = 2 * k + 2;


    while (j < n) {
        int t = b[j] - b[i - 1];
        ans = max(ans, t);
        i += 2;
        j += 2;
    }

    cout << ans;




}






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

// ABCテンプレート

#define rep(i,n) for (int i = 0; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
#define keta(n) cout << fixed << setprecision((n));
using ll = int64_t;
using v = vector<int>;


int main() {
  int D, T, S;
  cin >> D >> T >> S;
  if(S*T>=D) cout << "Yes";
  else cout << "No";
}

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

using namespace std;

typedef pair<int,int> pii;

#define size(x) ((int) x.size())

const int MAXN = 100 + 5;

int sx, sy, tx, ty;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> sx >> sy >> tx >> ty;
    for (int i = sy + 1; i <= ty; i++)
        cout << "U";
    for (int i = sx + 1; i <= tx; i++)
        cout << "R";
    for (int i = ty - 1; i >= sy; i--)
        cout << "D";
    for (int i = tx - 1; i >= sx; i--)
        cout << "L";
    cout << "L";
    for (int i = sy; i <= ty; i++)
        cout << "U";
    for (int i = sx; i <= tx; i++)
        cout << "R";
    cout << "DR";
    for (int i = ty; i >= sy; i--)
        cout << "D";
    for (int i = tx; i >= sx; i--)
        cout << "L";
    cout << "U" << endl;
    return 0;
}


Measured memory_bytes: 256
n,d = gets.chomp.split.map(&:to_i)
xs = n.times.map{gets.chomp.split.map(&:to_i)}
cnt = 0

(0..n-1).to_a.combination(2) do |i,j|
  dist = 0
  (0..d-1).each do |k|
    dist += (xs[i][k] - xs[j][k])**2
  end
  cnt += 1 if Math.sqrt(dist).to_i**2 == dist
end

puts cnt

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

int main(){
    int n;
    cin >> n ;
    int a[n];
    for (int i=0;i<n;i++){
        cin >> a[i] ;
    }
    sort(a,a+n);
    cout << a[n-1]-a[0] <<endl;
}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n, d;
    vector<vector<int>> v;
    set<int> s;
    cin >> n >> d;
    for (int i = 0; i < n; i++)
    {
        vector<int> tp;
        for (int j = 0; j < d; j++)
        {
            int tmp;
            cin >> tmp;
            tp.push_back(tmp);
        }
        v.push_back(tp);
    }
    for (int i = 1; i * i <= 20000; i++)
    {
        s.insert(i * i);
    }

    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int len2 = 0;
            for (int k = 0; k < d; k++)
            {
                len2 += (v[i][k] - v[j][k]) * (v[i][k] - v[j][k]);
            }
            if (s.find(len2) != s.end())
                cnt++;
        }
    }
    cout << cnt << endl;
}

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

vector<bool> seen;

int n;
bool g[55][55];

void dfs(int v){
    if(seen[v]) return;
    seen[v] = true;

    rep(j,n){
        if(g[v][j] || g[j][v]) dfs(j); 
    }

}

//DFS解答
int main(){
    int m; cin >> n >> m;
    vector<P> edge(m);
    seen.resize(n);

    //隣接グラフの作成。
    rep(i,m){
        cin >> edge[i].first >> edge[i].second;
        edge[i].first--; edge[i].second--;
        g[edge[i].first][edge[i].second] = true;
    }

    int ans = 0;

    rep(k,m){
        g[edge[k].first][edge[k].second] = false;
        rep(i,n) seen[i] = false;

        dfs(0);

        rep(i,n){
            if(!seen[i]){
                ans++;
                break;
            }
        }

        g[edge[k].first][edge[k].second] = true;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>
#include<cmath>

#define DEBUG false

#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
int N,M,X ;
char str[26];
/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  cin >> N >> M >> X ;
  int A[M] ;
  REP(i,M){
    cin >> A[i];
  }
  int ans0 = 0 ;
  int ansN = 0 ;
  int ans ;
  for(int j  = X; j <N ;  j++){
    REP(i,M){
      if(j == A[i])
        ansN ++;
    }
  }
  for(int j = X ; j >= 0 ; j--){
    REP(i,M){
      if(j == A[i])
        ans0++;
    }
  }
  ans = min(ansN,ans0);
  cout << ans << endl ;


  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
p = [0]*(n+1)
ans = 0
for i in range(n):
  p[a[i]] = i+1
l = [i-1 for i in range(n+2)]
l[0] = 0
r = [i+1 for i in range(n+2)]
r[-1] = n+1
for i in range(n,0,-1):
  ans += (p[i]-l[p[i]])*(r[p[i]]-p[i])*i
  l[r[p[i]]] = l[p[i]]
  r[l[p[i]]] = r[p[i]]
print(ans)

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

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

 int main() {
   int N, ans = 0;
   cin >> N;
   vector<int> s(N);
   rep(i, N) {
     cin >> s.at(i);
     ans += s.at(i);
   }

   if (ans % 10 != 0) cout << ans << endl;
   else {
     bool done = false;
     sort(s.begin(), s.end());
     rep(i, N) {
       if (s.at(i) % 10 != 0) {
         ans -= s.at(i);
         done = true;
         break;
       }
     }
     if (done) cout << ans << endl;
     else cout << 0 << endl;
   }
 }


Measured memory_bytes: 256
il1 = [int(k) for k in input().split()]
N = il1[0]
K = il1[1]
A = [0] * (N+1)
A[0] = A[0] + 1
for i in range(K):
    d = int(input())
    tmp_A = [int(k) for k in input().split()]
    for a in tmp_A:
        A[a] = A[a] + 1

print(A.count(0))


Measured memory_bytes: 9188
import java.io.{BufferedReader, InputStreamReader}

object Main {
  val mod: Long = 1000000000 + 7

  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val Array(x, y) = in.readLine().split("\\s+").map(_.toInt)

    System.out.println(
      if (2 * x - y < 0 || (2 * x - y) % 3 != 0 || 2 * y - x < 0 || (2 * y - x) % 3 != 0 || (x + y) % 3 != 0) {
        0
      } else {
        comb((x + y) / 3, (2 * x - y) / 3)
      }
    )
  }

  def comb(n: Long, k: Long): Long = {
    if (n - k > k) {
      comb(n, n - k)
    } else {
      val fn = (2L to n).foldLeft(1L)((cur, i) => mmod(cur, i))
      val invfn = inv(fn)

      val invfk = (n to (k + 1) by -1).foldLeft(invfn)((cur, i) => mmod(cur, i))
      val invfnmk = (k to (n - k + 1) by -1).foldLeft(invfk)((cur, i) => mmod(cur, i))

      mmod(mmod(fn, invfk), invfnmk)
    }
  }

  def inv(n: Long): Long = pow(n, mod - 2)

  def pow(n: Long, p: Long): Long = {
    if (p == 0) {
      1
    } else if (p == 1) {
      n
    } else if (p % 2 == 0) {
      pow(mmod(n, n), p / 2)
    } else {
      mmod(n, pow(n, p - 1))
    }
  }

  @inline
  def mmod(a: Long, b: Long): Long = {
    a * b % mod
  }
}


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

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
typedef pair<int,int> PII;
pair<PII,PII> cut(PII a,int pos)
{  
  int x,y;
  tie(x,y)=a;
  pos%=x+y;
  if(pos<x){
    int l=x-pos;
    if(pos>l) swap(pos,l);
    return MP(MP(pos,y),MP(l,y));
  }else{
    pos-=x;
    int l=y-pos;
    if(pos>l) swap(pos,l);
    return MP(MP(x,pos),MP(x,l));
  }
}

int main(void)
{
  for(;;){
    int n,w,d;
    cin >> n >> w >> d;
    if(!n&&!w&&!d) return 0;
    vector<PII> cakes;
    cakes.PB(MP(w,d));
    REP(i,n){
      int p,s;
      cin >> p >> s;
      --p;
      PII a,b;
      tie(a,b)=cut(cakes[p],s);
      cakes.erase(cakes.begin()+p);
      cakes.PB(a);
      cakes.PB(b);
    }
    REP(i,n+1) cakes[i].first*=cakes[i].second;
    SORT(cakes);
    REP(i,n+1){
      if(i) cout << ' ';
      cout << cakes[i].first;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

long solve(){
  int n;
  cin>>n;
  long ret=0;
  vector<long> h(n+1), a(n+1), d(n+1), s(n+1), t(n+1);
  rep(i,n+1) cin>>h[i]>>a[i]>>d[i]>>s[i];

  repl(i,1,n+1){
    long tmp = a[0]-d[i];
    if(tmp<=0){
      if(a[i]>d[0]) return -1;
      else tmp=1;
    }
    t[i] = (h[i]+tmp-1)/tmp;
  }

  // ?????´?????? ????????¬??????????????????
  repl(i,1,n+1)if(s[0]>s[i]){
    h[0] += max(a[i]-d[0], 0L);
    ret -= max(a[i]-d[0], 0L);
  }

  vector<int> vec(n);
  rep(i,n) vec[i]=i+1;

  sort(all(vec), [&](int i, int j){
    long ia = max(a[i]-d[0],0L);
    long ja = max(a[j]-d[0],0L);
    return ia*t[j] > ja*t[i];
  });

  long acctime = 0;
  rep(i,n){
    int id = vec[i];
    acctime += t[id];
    h[0] -= max(a[id]-d[0],0L) * acctime;
    ret += max(a[id]-d[0],0L) * acctime;
    if(h[0]<=0) return -1;
  }

  return ret;
}

int main(){
  cout<<solve()<<endl;

  return 0;
}

Measured memory_bytes: 4632
#include<bits/stdc++.h>
#define ll     long long int
#define pb     push_back
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std ;
int main()
{
     fast;
     int t=1;
    // cin>>t;
     while(t--)
     {
       ll n,i,j=1,k,l,m,ans=0,sum=0,result,a,b,c,d;
       cin>>k>>a>>b;
       n=b-a;
       if(a%k==0 || b%k==0)
        cout<<"OK"<<endl;
       else
       {
        c=a%k;
        if(n>=k-c)
            cout<<"OK"<<endl;
        else cout<<"NG"<<endl;
       }


     }

     return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

int main(){
  int n,k,a;
  vi data;
  vi diff;
  cin>>n>>k;
  
  rep(i,n){
    cin>>a;
    data.pb(a);
    if(k==a){cout<<"POSSIBLE"<<endl;return 0;}
  }
  sort(all(data));
  if(data[n-1]<k){cout<<"IMPOSSIBLE"<<endl;return 0;}
  REP(i,1,n)diff.pb(abs(data[i]-data[i-1]));
  bool ok=false;
  rep(i,n){
    if(diff[i]!=0&&k%diff[i]==0)ok=true;
  }
  if(ok)cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long n;
    cin >> n;
    string ans("");
    while(n>0){
        n--;
        ans += char('a'+(n%26));
        n /= 26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	int i, N ,x, y, z, t;



	cin >> N;
	vector<int> a(N);
	// vector<int> b(M);
	// for (i = 1; i <= N; i++){
  	for(i = 1; i <= N; i++){
      a[i] = 0;
    }
		for (x = 1; x <= sqrt(N); x++){
			for (y = 1; y <= sqrt(N); y++){
				for (z = 1; z <= sqrt(N); z++){
                  t = pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + x * z;
                  if (t <= N){
					a[t] += 1;
                  }
				}
			}
		}

		for (i = 1; i <= N; i++)
		{
			cout << a[i] << endl;
		}

		return 0;
}

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

using namespace std;

int main(void) {
  int N;
  cin >> N;
  vector<int> H(N);
  for (auto& v : H) {
    cin >> v;
  }

  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < N - 1; ++i) {
    if (H[i] >= H[i + 1]) {
      cnt++;
      ans = max(ans, cnt);
    } else {
      cnt = 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import Counter

def main():
    N, M = LI()
    edges = [[] for _ in range(N)]
    for _ in range(M):
        x, y, xxx = LI_()
        edges[x].append(y)
        edges[y].append(x)
    ans = 0
    visited = [0] * N
    def connect(k):
        visited[k] = 1
        for e in edges[k]:
            if visited[e] == 0:
                connect(e)
    for i in range(N):
        if visited[i] == 0:
            ans += 1
            connect(i)
    return ans

print(main())

Measured memory_bytes: 129276
from functools import reduce
 
 
def cross(a, b):
    return a.real * b.imag - a.imag * b.real
 
 
def graham_scan(points):
    points.sort(key=lambda p: (p.real, p.imag))
    lh = reduce(keep_left, points, [])
    uh = reduce(keep_left, reversed(points), [])
    lh.extend(uh[1:-1])
    return lh
 
 
def keep_left(hull, r):
    if hull:
        prev = hull.pop()
        while hull:
            p = hull[-1]
            if cross(prev - p, r - p) >= 0:
                hull.append(prev)
                break
            prev = hull.pop()
        else:
            hull.append(prev)
    if not hull or hull[-1] != r:
        hull.append(r)
    return hull
 
 
n = int(input())
points = [complex(*map(int, input().split())) for _ in range(n)]
result = graham_scan(points)
lr = len(result)
print(lr)
s = min(range(lr), key=lambda i: (result[i].imag, result[i].real))
for p in (result[s:] + result[:s]):
    print(int(p.real), int(p.imag))


Measured memory_bytes: 22680
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll h,w,n,m;
  cin >> h >> w >> n >> m;
  ll ans=(h-n)*(w-m);
  pr(ans);
}

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


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

int main(){
	int a,b,c,d;
	
	cin>>a>>b>>c>>d;
	
	if(a+b>c+d){
		cout<<"Left"<<endl;
		
	}else if(a+b<c+d){
		cout<<"Right"<<endl;
	}else{
		cout<<"Balanced"<<endl;
	}
	return 0;
	
}

Measured memory_bytes: 256
import java.util.*;

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

        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a-b >= 0){
            System.out.println("delicious");
            return;
        }else {
            if(b-a <= x){
                System.out.println("safe");
                return;
            }else {
                System.out.println("dangerous");
                return;
            }
        }
    }
}

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

using namespace std;

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

char s[200005];

bool checkRock(int start, int end) {
    while (start + 1 < end) {
        if (s[start] == '#' && s[start + 1] == '#') {
            return false;
        }
        ++start;
    }
    return true;
}

bool checkEmpty(int start, int end) {
    while(start + 2 <= end) {
        if (s[start] == '.' && s[start + 1] == '.' && s[start + 2] == '.') {
            return true;
        }
        ++start;
    }
    return false;
}

int main() {
    int N, A, B, C, D;
    scanf("%d %d %d %d %d", &N, &A, &B, &C, &D);
    --A; --B; --C; --D;
    scanf("%s", s);
    bool result = false;
    if (checkRock(A, C) && checkRock(B, D)) {
        result = true;
    }

    if (result) {
        if (C > D) {
            result = false;
            if (checkEmpty(B - 1, D + 1)) {
                result = true;
            }
        }
    }

    printf("%s\n", result ? "Yes" : "No");
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <regex>

int main()
{
  using namespace std;
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

  string S;
  regex re(R"(^(?:dream(?:er)?|eraser?)+$)"); 

  cin >> S;
  cout << (regex_match(S, re) ? "YES" : "NO") << endl;
  
  return 0;
}


Measured memory_bytes: 32208
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#define	int long long
using namespace std;
signed main(){

  int n,a[100000],re0,re1;
  long double r=-1;
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  for(int i=0;i<n;i++){
    int t0=*lower_bound(a,a+n,a[i]/2),t1=(a[0]==t0?a[0]:*(lower_bound(a,a+n,a[i]/2)-1)),tm0,tm1;
    tm0=t0,tm1=t1;
    if(t0<a[i]/2) t0=a[i]-t0;
    if(t1<a[i]/2) t1=a[i]-t1;
    int ho0=a[i]-t0,ho1=a[i]-t1;
    long double r0=(1.*a[i]+t0)/2,r1=(1.*a[i]+t1)/2;
    //cout<<a[i]<<" "<<tm0<<" "<<tm1<<" "<<ho0<<" "<<ho1<<" "<<r0<<" "<<r1<<endl;                                              
    r0*=ho0,r1*=ho1;
    if(r0>r&&tm0!=a[i]){
      r=r0;
      re0=a[i],re1=tm0;
    }
    if(r1>r&&tm1!=a[i]){
      r=r1;
      re0=a[i],re1=tm1;
    }
  }
  cout<<re0<<" "<<re1<<endl;
  return 0;

}



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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  int n; cin >> n;
  string s; cin >> s;
  vector<vector<int>> res(4, vector<int>(n));
  REP(i,4) {
    res[i][0] = i/2;
    res[i][1] = i%2;
  }
  auto next = [&](int b, int b2, char c) {
    if ((b == 1 && c == 'x') || (b == 0 && c == 'o')) return b2;
    else return 1-b2;
  };
  REP(i,4) FOR(j,2,n) {
    res[i][j] = next(res[i][j-1], res[i][j-2], s[j-1]);
  }

  REP(i,4) {
    if (next(res[i][n-1], res[i][n-2], s[n-1]) == res[i][0]
        && next(res[i][0], res[i][n-1], s[0]) == res[i][1]) {
      REP(j,n) {
        if (res[i][j] == 1) cout << 'W';
        else cout << 'S';
      }
      cout << "\n";
      return 0;
    }
  }
  cout << "-1\n";
  return 0;
}


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

#include <math.h>
#include <stdio.h>

using namespace std;

int main(void) {
	int a, b, c, x, y;
	scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);

	int min = a*x + b*y;
	
	for (int i = 1; i <= x || i <= y; i++) {
		int f = a * (x-i<0?0:x-i) + b * (y-i<0?0:y-i) + 2*c*i;
		if (min > f) min = f;
	}

	printf("%d\n", min);
	return 0;
}


Measured memory_bytes: 256
#import math
L = int(input())
#r = math.floor(math.log2(L))
r = L.bit_length()-1
N = r+1
graph = []
append = graph.append
for i in range(1,r+1):
    append([i,i+1,0])
    append([i,i+1,2**(i-1)])

for t in range(N-1,0,-1):
    if L-2**(t-1) >= 2**r:
        append([t,N,L-2**(t-1)])
        L -= 2**(t-1)

print(N,len(graph))
for g in graph:
    print(*g)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<numeric>
#include<limits.h>
#include<utility>
#include<cstdlib>
#include<bitset>
#define LP(i,n) for(int i=0;i<n;i++)
#define LPIN(n,a) for(int i=0;i<n;i++)cin >> a[i]
using namespace std;

int main(){
    long long int a,b;
    cin >> a >> b;
    if((a+b) % 2 != 0)cout << "IMPOSSIBLE" << endl;
    else cout << (a+b) / 2 << endl;
    return 0;
    
}

Measured memory_bytes: 256
//ABC146_A
using System;
namespace AtConderCSharp
{
    class Program
    {
        public static void Main()
        {
            string s = Console.ReadLine();  
            if(s == "SUN")
            {
                Console.WriteLine(7);
            }
            else if(s == "MON")
            {
                Console.WriteLine(6);
            }
            else if(s == "TUE")
            {
                Console.WriteLine(5);
            }
            else if(s == "WED")
            {
                Console.WriteLine(4);
            }
            else if(s == "THU")
            {
                Console.WriteLine(3);
            }
            else if(s == "FRI")
            {
                Console.WriteLine(2);
            }
            else
            {
                Console.WriteLine(1);
            }
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int n,x,num[105],ans,i;
int main(){
    scanf(" %d %d",&n,&x);
    for(i=0;i<n;i++){
        scanf(" %d",&num[i]);
    }
    sort(num,num+n);
    for(i=0;i<n;i++){
        num[i+1]+=num[i];
    }
    for(i=0;i<n;i++){
        if(num[i]==x){
            ans=i+1;
            break;
        }
        if(num[i]>x){
            ans=i;
            break;
        }
        if(i==n-1 && x>num[i]){
            ans=i;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i*10000 + j*5000 + (n - i - j)*1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")

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

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) { 
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};


int main() {
    int n,m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        uf.unite(a,b);
    }
    int ans = 0;
    rep(i,n) {
        ans = max(ans,uf.size(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4020
import numpy as np
N, D = list(map(int, input().split()))
x = []
for n in range(N):
  x.append(np.array(list(map(int, input().split()))))

count = 0
for i in range(len(x) - 1):
  for j in range(i + 1, len(x)):
    u = x[i] - x[j]
    if np.linalg.norm(u).is_integer():
      count += 1
print(count)

Measured memory_bytes: 12396
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    string str;

    while(cin >> str)
    {
		if(str.front() >= 'a' && str.front() <= 'z') cout << 'a' << '\n';
		else cout << 'A' << '\n';
    }


}




Measured memory_bytes: 3604
# https://atcoder.jp/contests/hitachi2020/submissions/10704509
# PyPyなら通る

def main():
    import sys
    input = sys.stdin.readline

    inf = 1 << 30
    L = 30

    N, T = map(int, input().split())

    ps = []
    coef_0 = []
    for _ in range(N):
        a, b = map(int, input().split())
        if a == 0:
            coef_0.append(b + 1)
        else:
            ps.append((a, b))  # namedtupleやめた,coef,const

    ps.sort(key=lambda p: p[0] / (p[1] + 1), reverse=True)
    coef_0.sort()

    dp = [inf] * (L + 1)
    dp[0] = 0
    for coef, const in ps:
        for visited in reversed(range(L)):
            cand = (dp[visited] + 1) * (coef + 1) + const
            if dp[visited + 1] > cand:
                dp[visited + 1] = cand  # 不等式で評価する

    def accumulate(a):
        s = 0
        yield s  # start=x->0
        for x in a:
            s += x
            yield s

    *acc, = accumulate(coef_0)

    ans = 0
    cnt = len(acc) - 1
    for visited, consumption_time in enumerate(dp):
        rest = T - consumption_time
        if rest < 0: break  # le->lt,continue->break,restは狭義単調減少
        while cnt > 0 and acc[cnt] > rest:  # bisect_right->しゃくとり
            cnt -= 1
        visited += cnt
        if visited > ans:
            ans = visited  # 関数呼び出しとどちらが速いか(set->maxよりは逐次が速かった）
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73436
#include<stdio.h>
int main(){
	char a;
  char b;
  scanf("%c %c",&a,&b);
  if(a=='H'&&b=='D'){
  	printf("D");
  }
  else if(a=='H'&&b=='H'){
  printf("H");
  }
  else if(a=='D'&&b=='D'){
  printf("H");
  }
  else if(a=='D'&&b=='H'){
  printf("D");
  }
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 1000006, MAXM = 1003, Mod = 1000000007 , MAXLog = 20;

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    int W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << 1LL * W * H / 2.0 << ' ' << (W % 2 == 0 && W / 2 == x && H % 2 == 0 && H / 2 == y) << '\n';

    return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def same(self, x, y):
        return self.find(x) == self.find(y)
N,M = map(int,input().split())
q = UnionFind(N)

for _ in range(M):
    x,y = map(int,input().split())
    q.union(x-1,y-1)
set_ = set()
cnt = 0
for i in range(N):
    if q.find(i)<0:
        cnt += 1
    else:
        set_.add(q.find(i))
print(cnt + len(set_)-1)



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

char change(char c){
  return (c == '0') ? '1' : '0';
}

int main() {
  string s;
  cin >> s;
  int n = s.length();
  for(int i=1;i<n;i+=2){
    s[i] = change(s[i]);
  }
  int count = 0;
  rep(i,n){if (s[i]=='1') count++;}
  int ans = min(count,n-count);

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


Measured memory_bytes: 512
N, K = map(int, input().split())
N += 1

A = [0] * N
ruiseki = [0] * N
for i in range(1, N):
    ruiseki[i] = ruiseki[i-1] + i

total = 0
for i in range(K, N):
    start = ruiseki[i-1]
    end = ruiseki[N-1] - ruiseki[N-i-1]
    total += end - start + 1

# all select
total += 1

mod = (10**9) + 7
print(total % mod)


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

int main() {
  string c ;
  cin >> c;
  if (c[0] == 'a' || c[0] == 'i' || c[0] == 'u' || c[0] == 'e' || c[0] == 'o') {
  cout << "vowel" << endl;
}
else {
  cout << "consonant" << endl;
}
return 0;
  }


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define maxn 100
using namespace std;
double A[maxn+2];
int main() {
	// your code goes here
	int n; cin>>n;
	double product = 1.0;
	for(int i=0;i<n;i++) {
		cin>>A[i];
		product*=A[i];
	}
	double numerator = product , denominator = 0.0;
	for(int i=0;i<n;i++) {
		
		denominator+=(product/A[i]);
	}
	printf("%lf\n", numerator/denominator);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int n;
double p[10005];
double sum1, max, sum;
int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%lf", &p[i]);
		sum1 += p[i];
	}
	max = p[0];
	for (int j = 0; j < n; j++)
		if (max < p[j])
			max = p[j];
	sum += (sum1 - max / 2);
	printf("%.0lf\n", sum);
}








Measured memory_bytes: 128
//O(n^2) solution
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

void dfs(int n,vector<int> *v, int *r)
{
	int x = 1;
	for(int i = 1;i<=n; i++)
	{
		if(!r[i])
		{
			r[i]= x++;
			queue<int>q;
			q.push(i);
			while(!q.empty())
			{
				int y = q.front();
				q.pop();
				for(auto it:v[y])
					if(!r[it])
					{
						r[it]= r[y];
						q.push(it);
					}
			}
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k,l;
	cin>>n>>k>>l;
	vector<int> v[n+1],h[n+1];
	for(int i = 0,j,y;i <k; i++)
	{
		cin>>j>>y;
		v[j].push_back(y);
		v[y].push_back(j);
	}

	for(int i =0,r,s; i<l; i++)
	{
		cin>>r>>s;
		h[r].push_back(s);
		h[s].push_back(r);
	}

	int rail[n+1]={0}, road[n+1]={0};
	dfs(n, v, road);
	dfs(n, h, rail);
	map<ar<int,2>,int> m;
	for(int i = 1; i<=n; i++)
		m[{road[i],rail[i]}]++;

	for(int i = 1;i<=n;i++)
		cout<<m[{road[i],rail[i]}]<<" \n"[i==n];
	
	return 0;
}

Measured memory_bytes: 27812
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
using namespace std;

int main(){
    int n;cin>>n;
    int a[100010];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    if(a[n-1]%2==0){
        auto itr=lower_bound(a,a+n,a[n-1]/2);
        int m1=*itr;
        int d1=m1-a[n-1]/2;
        itr--;
        int m0=*itr;
        int d0=a[n-1]/2-m0;
        if(d1>=d0)cout<<a[n-1]<<" "<<m0<<endl;
        else cout<<a[n-1]<<" "<<m1<<endl;
    }
    else{
        auto itr=lower_bound(a,a+n,(a[n-1]+1)/2);
        int m1=*itr;
        int d1=m1-(a[n-1]+1)/2;
        itr--;
        int m0=*itr;
        int d0=a[n-1]/2-m0;
        if(d1>=d0)cout<<a[n-1]<<" "<<m0<<endl;
        else cout<<a[n-1]<<" "<<m1<<endl;        
    }
    return 0;
}

Measured memory_bytes: 1148
s = input()

cnt = 0
if s[0] == 'A' and 'C' in s[2:-1] and s.replace("A","").replace("C","").islower():
    for c in s[2:-1]:
        if c == 'C':
            cnt+=1

    if cnt == 1:
        print("AC")
    else:
        print("WA")
else:
    print("WA")


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;


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

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

  }
  int amax;
  amax=*max_element(a.begin(), a.end());
  sort(b.begin(),b.end(),greater<int>());
  int result=0;

  for(int i=0; i<n;i++)
  {
    if(b[i]<amax){break;}
    h-=b[i];
    result+=1;
    if(h<=0){break;}
  }
  if(h>0){result+=h/amax+1*(h%amax!=0);}
  cout << result <<endl;

}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a(3);
    rep(i, 0, 3) cin >> a[i];
    sort(all(a));
    string ans = "No";
    if (a[0] == a[1] && a[1] != a[2])
        ans = "Yes";
    if (a[1] == a[2] && a[1] != a[0])
        ans = "Yes";
    cout << ans << endl;
}

Measured memory_bytes: 256