akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

bool check(int x,int y,vector<string> a,vector<string> b ){
    for(auto i = 0; i<b.size();i++){
        for(auto j =0; j<b.size();j++){
            if(a[x+i][y+j]!= b[i][j]) return false;
        }
    }
    return true;
}

int dist(pii a, pii b){
    return abs(a.first-b.first) + abs(a.second-b.second);
}

int main() {
    string o,e;cin>>o;cin>>e;
    
    int io = 0;
    int ie = 0;
    
    while(1){
        if(io==o.size())break;
        cout<<o[io];
        io++;
        if(ie==e.size())break;
        cout<<e[ie];
        ie++;
    }
    cout<<endl;
    
    return 0;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
int main(){
	int n;
	cin>>n;
	vector<int>	A(n);
	vector<int>	B(n);
	vector<int>	C(n);
	rep(i,n){
		cin>>A[i];
		A[i]--;
		//i番目に食べた料理がkの時、B,Cはk-1番目の要素の点を得るから。
	}
	rep(i,n){
		cin>>B[i];
	}
	rep(i,n-1){
		cin>>C[i];
	}
	//入力ここまで
	int bef = -1; //mae ni tabeta
	int ans  = 0 ;
	rep(i,n){
		int a = A[i];
		ans+=B[a];
		if(bef==a-1&&bef!=-1){
			ans+=C[bef];
		}
		bef=a;
	}
	cout<<ans<<endl;
}


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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int H, W;
  cin >> H >> W;

  vector<int> X = {0, -1, 1, 0};
  vector<int> Y = {-1, 0, 0, 1};

  vector<vector<char>> s(H);
  rep(i, H) {
    s[i].resize(W);
    rep(j, W) {
      cin >> s[i][j];
    }
  }

  bool achieve = true;
  rep(i, H) {
    rep(j, W) {
      if (s[i][j] == '#') {
        bool black = false;
        rep(k, X.size()) {
          if ((0 <= j + X[k] && j + X[k] <= W - 1) 
            &&(0 <= i + Y[k] && i + Y[k] <= H - 1)) {
              if (s[i+Y[k]][j+X[k]] == '#') black = true;
          }
        }
        if (black == false) {
          achieve = false;
          break;
        }
      }
    }
  }

  if (achieve) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K = map(int, readline().split())
    point = list(map(int, readline().split()))
    T = readline().strip()

    T = T.translate(str.maketrans('rsp', '012'))
    T = list(map(int, T))

    hand = [0] * N
    ans = 0
    for i in range(N):
        win = (T[i] - 1) % 3
        if i < K or hand[i - K] != win:
            hand[i] = win
            ans += point[win]
        else:
            hand[i] = -1

    print(ans)
    return


if __name__ == '__main__':
    main()


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

int main(){
  int a,b,x;
  cin >> a >> b;
   x = a + b;
  if(x % 2 == 0){
    cout << x /2 << endl;
  }
  else{
    cout << x / 2 + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

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

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

const int mod = 1e9 + 7;
using modint = ModInt< mod >;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    modint ans = 1;
    vector<int> boxes(3, 0);
    rep (i, n) {
        int idx = 0;
        int ctr = 0;
        rep (j, 3) {
            if (boxes[j] == a[i]) {
                ctr++;
                idx = j;
            }
        }
        ans *= ctr;
        boxes[idx]++;
    }
    cout << ans << endl;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  int cnt = 0;
  rep(i, n) {
    int d1, d2;
    cin >> d1 >> d2;
    if (d1 == d2) cnt++;
    else cnt = 0;
    if (cnt >= 3) {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 3636
s=input()+' '
p=0
l=list()
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        p+=1
    else:
        if s[i]=='<':
            l.append([0,'<',p+1])
        else:
            l.append([p+1,'>',0])
        p=0
a=sum([sum(range(i[2]+1)) if i[1]=='<' else sum(range(i[0]+1)) for i in l])
b=sum([min(l[i][2],l[i+1][0]) for i in range(len(l)-1)])
print(a-b)

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 1000005;

/* ...o(^-^)o... */

bool used_prime[MAX];

void prime_factorization(int x){
    for(int k = 2; k*k <= x; k++){
        while(x % k == 0){
            used_prime[k] = true;
            x /= k;
        }
    }
    if(x != 1) used_prime[x] = true;
}

int main(){
    int n; cin >> n;
    vector<int> a(n); rep(i,n) cin>>a[i];

    int now, g = gcd(a[0], a[1]);
    if(g == 1) now = 0;
    else now = 2;
    prime_factorization(a[0]);
    prime_factorization(a[1]);

    for(int i = 2; i < n; i++){
        if(now == 0){
            if(a[i] == 1) continue;
            for(int k = 2; k*k <= a[i]; k++){
                while(a[i] % k == 0){
                    if(used_prime[k]) now = 1;
                    a[i] /= k;
                }
            }
            if(a[i] != 1 && used_prime[a[i]]) now = 1;
            if(now == 0) prime_factorization(a[i]);
        }
        else if(now == 1){
            continue;
        }
        else{
            g = gcd(g, a[i]);
            if(g == 1) now = 1;
        }
    }
    vector<string> ans = {"pairwise coprime", "setwise coprime", "not coprime"};
    out(ans[now]);
}

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

typedef long long ll;

int N;
vector<int> A, B, C;
ll ans;

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

	cin >> N;
	A.resize(N); B.resize(N); C.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];
	for (int i = 0; i < N; ++i)
		cin >> B[i];
	for (int i = 0; i < N; ++i)
		cin >> C[i];

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	ans = 0;
	vector<int>::iterator it_a, it_c;
	for(int i = 0; i < N; ++i) {
		it_a = upper_bound(A.begin(), A.end(), B[i] - 1);
		int id_a;
		if (it_a == A.end())
			id_a = N;
		else
			id_a = distance(A.begin(), it_a);
		it_c = upper_bound(C.begin(), C.end(), B[i]);
		if (it_c == C.end())
			break;
		int id_c = distance(C.begin(), it_c);
		ans += (ll)id_a * (N - id_c);
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
  int  n, i, y;
  float a, t, h, min=100000.0, x;
  
  scanf("%d", &n);
  scanf("%f %f", &t, &a);
  for(i=1; i<=n; i++){
    scanf("%f", &h);
    x = fabs(a - (t - h*0.006));
    if(x < min){
      min = x;
      y = i;
    }
  }
  printf("%d\n", y);
  
  return 0;
}

Measured memory_bytes: 128
var     n:longint;
        a:array[0..10]of longint;

procedure nhap;
begin
        readln(n);
end;

procedure xuli;
var i:longint;
begin
        a[0]:=1;
        for i:=1 to 10 do a[i]:=a[i-1]*2;
        for i:=0 to 6 do
            if (a[i]<=n)and (n<a[i+1]) then writeln(a[i]);
end;

begin
       // assign(input,'at_b.inp');reset(input);
        //assign(output,'at_b.out');rewrite(output);
                nhap;
                xuli;
end.


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

typedef pair<int, int> P;

P f(int x) {
    int a = x % 10;
    int b = 0;
    while (x) {
        b = x;
        x /= 10;
    }
    return P(a, b);
}

int main()
{
    int n; cin >> n;
    map<P, int> freq;
    for (int i = 1; i <= n; i++) {
        P p = f(i);
        freq[p]++;
    }

    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        P p = f(i);
        P q(p.second,p.first);
        ans += freq[q];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
const int N = 1e2 + 10;
const int mod = 1e9 + 7;
#define int long long
int k;
queue < pair < int, int > > q;

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

    cin >> k;

    for (int i = 1; i <= 9; ++i)
    {
        q.push({i, i});
    }
    int cur = 9;
    while (q.size())
    {
        auto t = q.front();
        q.pop();
        if (t.y == k)
        {
            cout << t.x;
            return 0;
        }
        if (t.x % 10 == 0) q.push({t.x * 10 + 0, ++cur}), q.push({t.x * 10 + 1, ++cur});
        else if (t.x % 10 == 9) q.push({t.x * 10 + 8, ++cur}), q.push({t.x * 10 + 9, ++cur});
        else q.push({t.x * 10 + t.x % 10 - 1, ++cur}), q.push({t.x * 10 + t.x % 10, ++cur}), q.push({t.x * 10 + t.x % 10 + 1, ++cur});
    }
    return 0;
}


Measured memory_bytes: 3456
#include<stdio.h>
int main (void)
{
    int a,b,c,k,i;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&k);
    if(a>k){
        printf("%d\n",k);
    }else if(a+b>k)
    {
        printf("%d\n",a);
    }
    else
    {
        printf("%d\n",a-(k-a-b));
    }
    
}

Measured memory_bytes: 1732
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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


signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];
    int ans = 0;
    loop(i,1,n-1){
        if((a[i-1] < a[i] && a[i] < a[i+1]) || (a[i-1] > a[i] && a[i] > a[i+1]))ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int

	fmt.Scan(&n)

	a := 0
	for i := 1; i <= n; i++ {
		if i%2 == 1 {
			a++
		}
	}

	fmt.Println(float64(a) / float64(n))
}


Measured memory_bytes: 512
use proconio::{input, fastout};

#[fastout]
fn main() {
  input!{
    N: i32
  }
  let mut ans:i32 = 0;
  for i in 1..=N {
      if i.to_string().len() % 2 == 1{
        ans += 1;
      }
  }
  println!("{}",ans);
}


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

const ll INF = 1LL << 60;

ll A, B;

// 0 ~ x までの xor を求める
// 周期2を利用するパターン
ll f(ll x) {
    ll tmp = (x + 1) / 2;
    tmp %= 2;
    // x が偶数の時、はみ出る (0-indexed)
    if (x % 2 == 0) {
        tmp ^= x;
    } 
    return tmp;
}

int main() {
    cin >> A >> B;
    // cout << f(A - 1) << endl;
    // cout << f(B) << endl;

    ll ans = f(B) ^ f(A - 1);
    cout << ans << endl;
}

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

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


Measured memory_bytes: 256
H,W=list(map(int,input().split()))
c=[list(map(int,input().split())) for _ in range(10)]
A=[list(map(int,input().split())) for _ in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j]=min(c[i][j],c[i][k]+c[k][j])
res=0

for i in range(H):
    for j in range(W):
        a=A[i][j]
        if a>=0:
            res+=c[a][1]

print(res)

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


using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	
	int ma = max(max(a,b) ,c);
	a = ma - a;
	b = ma - b;
	c = ma - c;
	
	int res = a%2 + b%2 + c%2;
	int ans = a/2 + b/2 + c/2;
	
	if(res == 2) cout << ans+1;
	else if(res == 1) cout << ans+2;
	else cout << ans;
	
	cout << endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long int
#define hmap        unordered_map
#define pii         pair<int,int>
#define pdd         pair<double, double> 
#define M           1000000007
#define MOD         998244353
#define fast        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test        ll t; cin>>t; while(t--)
#define inp(a,n)    int a[n]; for(int i=0;i<n;i++)  cin>>a[i];
#define inpl(a,n)   ll a[n];  for(ll i=0;i<n;i++)   cin>>a[i];
#define out(a,n)    for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define outl(a,n)   for(ll i=0;i<n;i++)  cout<<a[i]<<" "; cout<<endl;
#define outv(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";  cout<<endl;
#define all(s)      (s).begin(),(s).end()

struct pair_hash {
    template <class T1, class T2>
    std::size_t operator () (const std::pair<T1,T2> &p) const {
        auto h1 = std::hash<T1>{}(p.first);
        auto h2 = std::hash<T2>{}(p.second);
        return h1 ^ h2;  
    }
};
using vote = pair<ll,ll>;
using Unordered_map = unordered_map<vote, ll, pair_hash>;

int main()
{
      fast
      int n,k;
      cin>>n;
      int a[n],b[n],c[n];
      for(int i=0;i<n;i++)
            cin>>a[i]>>b[i]>>c[i];
      int dp[n][3];
      
      dp[0][0] = a[0];
      dp[0][1] = b[0];
      dp[0][2] = c[0];
      
      for(int i=1;i<n;i++)
      {
            dp[i][0] = a[i]+ max(dp[i-1][1],dp[i-1][2]);
            dp[i][1] = b[i]+ max(dp[i-1][0],dp[i-1][2]);
            dp[i][2] = c[i]+ max(dp[i-1][0],dp[i-1][1]);
      }
      cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
      
      
      
}

Measured memory_bytes: 2560
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        _n: usize, m: usize,
        mut ab: [(usize1, usize1); m]
    }

    ab.sort();
    let mut ret = 1;
    let mut range = ab[0];
    for i in 1..m {
        let (a, b) = ab[i];
        if range.1 <= a {
            ret += 1;
            range = (a, b);
        } else {
            range = (a, std::cmp::min(range.1, b));
        }
    }
    println!("{}", ret);
}

Measured memory_bytes: 6396
S = input().split()

A = abs(int(S[0]) - int(S[1]))
ans = 0
if A % 2 == 0:
  ans = int(A / 2) 
  if int(S[0]) > int(S[1]):
    print(ans + int(S[1]))
  else:
    print(ans + int(S[0]))
else:
  print('IMPOSSIBLE')

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

using namespace std;

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

const int MAX_T=100;

int K,T;
int A[MAX_T];

int main(){
	scanf("%d %d",&K,&T);
	REP(i,T){
		scanf("%d",&A[i]);
	}
	int ans=0;
	int pre=-1;
	REP(i,K){
		int next=-1;
		REP(j,T){
			if (j==pre) continue;
			if (A[j]==0) continue;
			if (next==-1 || A[j]>A[next]){
				next=j;
			}
		}
		if (next==-1){
			A[pre]--;
			ans++;
		}else{
			A[next]--;
			pre=next;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#define MOD 1000000007
using namespace std;
const int MAXN = 3005;
int f[MAXN][MAXN],n,m,r[MAXN];
int sum[MAXN];
char s[MAXN];
inline void add(int &x,int a)
{
	x+=a;
	if(x>=MOD)x-=MOD;
}
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for(int i=1;i<=n;++i)r[i]=i,sum[i]=sum[i-1]+s[i]-'0';
	for(int i=1,x,y;i<=m;++i){
		scanf("%d%d",&x,&y);
		r[x]=max(r[x],y);
	}
	for(int i=1;i<=n;++i)r[i]=max(r[i],r[i-1]);
	f[1][sum[r[1]]]=1;
	for(int i=1;i<=n;++i){
		for(int j=0;j<=n;++j){
			if(!f[i][j])continue;
			int baseline=sum[r[i+1]]-sum[r[i]];
			if(j<r[i]-i+1)add(f[i+1][baseline+j],f[i][j]);
			if(j>=1)add(f[i+1][baseline+j-1],f[i][j]);
		}
	}
	cout<<(f[n][0]+f[n][1])%MOD<<endl;
	return 0;
}

Measured memory_bytes: 33920
#include <stdio.h>
 
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
 
#define MAX  40002
#define BASE 20000
 
int a[MAX];
int sum[MAX]; int sz;
int left[MAX];
 
int main()
{
    int i, j, k, x, h, s, ans;
    int c;
 
    h = BASE, ans = s = 0;
    for (x = 1; ; x++) {
        c = gc();
        if (c <= ' ') break;
        if (c == '\\') {
            if (s > 0) ans += s, sum[sz++] = s, s = 0;
            a[--h] = x;
        } else if (c == '/') {
            if (a[h] > 0) left[sz] = a[h], s += x-a[h];
            else if (s > 0) ans += s, sum[sz++] = s, s = 0;
            h++;
        }
    }
    if (s > 0) ans += s, sum[sz++] = s;
 
    printf("%d\n", ans);
    k = sz;
    i = sz-1; while (i > 0) {
        j = i-1; while (j >= 0 && left[j] > left[i]) {
            sum[i] += sum[j], sum[j] = 0, j--, k--;
        }
        i = j;
    }
 
    printf("%d", k);
    for (i = 0; i < sz; i++) if (sum[i] > 0) printf(" %d", sum[i]);
    putchar('\n');
    return 0;
}


Measured memory_bytes: 2768
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define rep2(i,j,k) for(int i=j;i>=k;i--) 
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}
string S[200010];int cnt[26];;
struct wzy{
	int pos[26];bool en;
}t[1500010];
int tot=1;

int main(){
	int n;read(n);
	int ans=0;
	rep(i,1,n){
		rep(j,0,25)cnt[j]=0;
		cin>>S[i];int len=S[i].length();
		rep(j,0,len-1)cnt[S[i][j]-'a']++;
		int ret=1;
		rep2(j,len-1,0){
			rep(k,0,25)ans+=(cnt[k]&&t[t[ret].pos[k]].en);
			if(!t[ret].pos[S[i][j]-'a'])t[ret].pos[S[i][j]-'a']=++tot;
			ret=t[ret].pos[S[i][j]-'a'];cnt[S[i][j]-'a']--; 
		}
		t[ret].en=1;
	}
	
	rep(i,1,tot){
		rep(j,0,25)t[i].pos[j]=0;
		t[i].en=0;
	}
	tot=1;
	
	rep2(i,n,1){
		rep(j,0,25)cnt[j]=0;int len=S[i].length();
		rep(j,0,len-1)cnt[S[i][j]-'a']++;
		int ret=1;
		rep2(j,len-1,0){
			rep(k,0,25)ans+=(cnt[k]&&t[t[ret].pos[k]].en);
			if(!t[ret].pos[S[i][j]-'a'])t[ret].pos[S[i][j]-'a']=++tot;
			ret=t[ret].pos[S[i][j]-'a'];cnt[S[i][j]-'a']--; 
		}
		t[ret].en=1;
	}
	write(ans);
	return 0;
}

Measured memory_bytes: 116516
def solve():
    from collections import deque, namedtuple
    from operator import attrgetter
    import sys

    input = sys.stdin.readline
    Sushi = namedtuple('Sushi', 'taste kind')

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

    e = []
    for _ in range(n):
        t, d = map(int, input().split())
        e.append(Sushi(taste=d, kind=t - 1))

    e.sort(key=attrgetter('taste'), reverse=True)

    ret = 0
    used = [False] * n  # 選択されている種類
    q = deque()  # 選択から外す候補,[high->low]
    x = 0  # 暫定選択の種類数
    for s in e[:k]:  # 美味しさ降順k個
        if used[s.kind]:
            q.append(s)  # 同じ種類の2個目以降のみ交換候補になる
        else:
            used[s.kind] = True
            x += 1
        ret += s.taste
    ret += pow(x, 2)  # 種類ボーナス

    t = ret
    r = iter(e[k:])  # 交換で入れる候補
    while q:
        rem = q.pop()  # 選択から外す
        t -= rem.taste
        for s in r:
            if used[s.kind]:
                continue
            used[s.kind] = True
            t += s.taste + x * 2 + 1
            x += 1
            ret = max(ret, t)
            break
        else:
            break

    return ret


if __name__ == '__main__':
    print(solve())

# k個持っておいて、下位を交換する


Measured memory_bytes: 19392
#include <iostream>
#include <vector>

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

struct ModInt {
    using lint = long long;
    int val;
    static int MOD;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }
    bool operator<(const ModInt& b) const { return val < b.val; }
    bool operator<=(const ModInt& b) const { return val <= b.val; }
    bool operator>(const ModInt& b) const { return val > b.val; }
    bool operator>=(const ModInt& b) const { return val >= b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept {
        lint v;
        is >> v;
        x = v;
        return is;
    }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

int ModInt::MOD;
using mint = ModInt;

void solve() {
    int n;
    std::cin >> n >> ModInt::MOD;

    auto dp = vec(n + 1, vec(n * 3 + 1, mint(0)));
    dp[0][0] = 1;

    for (int k = 0; k < n * 3; ++k) {
        for (int i = 0; i <= n; ++i) {
            dp[i][k + 1] += dp[i][k];

            if (i + 1 > n) continue;

            if (k + 2 <= n * 3) dp[i + 1][k + 2] +=
                                dp[i][k] * (k + 1);
            if (k + 3 <= n * 3) dp[i + 1][k + 3] +=
                                dp[i][k] * (k + 1) * (k + 2);
        }
    }

    mint ans = 0;
    for (int i = 0; i <= n; ++i) ans += dp[i][n * 3];
    std::cout << ans << "\n";
}

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

    solve();

    return 0;
}


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

LL a, b;

int main(){
    cin >> a >> b;
    if((a + b)%2){
        cout << "IMPOSSIBLE" << endl;
    }else{
        cout << (a + b)/2 << endl;
    }
}

Measured memory_bytes: 764
#include"bits/stdc++.h"
#define F(i,j,n) for(register int i=j;i<=n;i++)
#define D(i,j,n) for(register int i=j;i>=n;i--)
#define ll long long
using namespace std;
namespace io{
	const int L=(1<<19)+1;
	char ibuf[L],*iS,*iT,c;int f;
	char gc(){
		if(iS==iT){
			iT=(iS=ibuf)+fread(ibuf,1,L,stdin);
			return iS==iT?EOF:*iS++;
		}
		return*iS++;
	}
	template<class I>void gi(I&x){
		for(f=1,c=gc();c<'0'||c>'9';c=gc())if(c=='-')f=-1;
		for(x=0;c<='9'&&c>='0';c=gc())x=x*10+(c&15);x*=f;
	}
};
using io::gi;
using io::gc;
int n,m;
int main(){
	#ifdef JHR
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
	#endif
	gi(n);gi(m);
	puts(m*2<=n+1?"YES":"NO");
	return 0;
}



Measured memory_bytes: 256
//https://atcoder.jp/contests/abc117/tasks/abc117_a
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};


int main(){
    cout<<fixed;
    cout<<setprecision(5);
    double T,X;
    cin>>T>>X;
    cout<<T/X<<endl;
    return 0;
}

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

int main(void) {
  long long N, K;
  cin >> N >> K;

  if (K == 0) {
    cout << N * N << endl;
    return 0;
  }
  long long ret = 0;
  for (long long b = 1; b <= N; b++) {
    ret += (N / b) * max(0LL, (b - K)) + max(0LL, (N % b - K + 1LL));
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    char s[3][11];
    for(int i = 0; i < 3; i++){
        scanf(" %s",&s[i]);
    }

    int count[3];
    for(int i = 0; i < 3; i++){
        count[i] = 0;
    }
    for(int i = 0; i < 3; i++){
        for(int j = 0;; j++){
            if(s[i][j] == '\0'){
                count[i] = j;
                break;
            }
        }
    }

    if(s[0][count[0] - 1] == s[1][0] && s[1][count[1] - 1] == s[2][0]){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}

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

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

int main()
{
  int i, a[3];
  REP(i, 3) cin >> a[i];
  sort(a, a + 3);
  cout << a[0] << " " << a[1] << " " << a[2] << endl;
}

Measured memory_bytes: 1180
object Main {
  import java.util.Scanner
  import scala.annotation.tailrec

  def readStrings(n: Int)(implicit sc: Scanner): Array[String] = Array.fill(n) { sc.next() }
  def readInts(n: Int)(implicit sc: Scanner): Array[Int] = Array.fill(n) { sc.nextInt() }
  def readLongs(n: Int)(implicit sc: Scanner): Array[Long] = Array.fill(n) { sc.nextLong() }
  def readLineStrings(implicit sc: Scanner): Array[String] = sc.nextLine().split(' ')
  def readLineInts(implicit sc: Scanner): Array[Int] = readLineStrings.map(_.toInt)
  def readLineLongs(implicit sc: Scanner): Array[Long] = readLineStrings.map(_.toLong)

  def main(args: Array[String]): Unit = solve(new Scanner(System.in))

  def solve(implicit sc: Scanner): Unit = {
    @tailrec def gcd(a: Long, b: Long): Long = if (b == 0) a else gcd(b, a % b)

    val Array(n, m) = readLineLongs
    val S = sc.nextLine()
    val T = sc.nextLine()

    val gcdLength = gcd(n, m)
    val lcm = m * n / gcdLength
    val nStep = (n / gcdLength).toInt
    val mStep = (m / gcdLength).toInt
    val compareIndices = (0 until gcdLength.toInt).map { i => (i * nStep, i * mStep) }
    if (compareIndices.forall { case (x, y) => S.charAt(x) == T.charAt(y) }) {
      println(lcm)
    } else {
      println(-1)
    }
  }
}

Measured memory_bytes: 31588
#include <iostream>
#include <string>
#include<vector>
#include <algorithm>
#include<math.h>

using namespace std;


int main(){
    int n,A=0,B=0;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end(),std::greater<int>());
    for(int i=0;i<n;i++){
        if(i%2==0){
            A+=a[i];
        }else{
            B+=a[i];
        }
    }
    cout<<A-B<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const P<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}

class UnionFind
{
   private:
      vector<int> par, myrank;
   public:
      UnionFind(int n) {
         par.resize(n);
         myrank.resize(n, 0);
         for (int i = 0; i < n; i++) {
            par[i] = i;
         }
      }
      int find(int x) {
         if (par[x] == x) return x;
         return par[x] = find(par[x]);
      }
      void unite(int x, int y) {
         x = find(x);
         y = find(y);
         if (x == y) return;
         if (myrank[x] < myrank[y]) {
            par[x] = y;
         } else {
            par[y] = x;
            if(myrank[x] == myrank[y]) myrank[x]++;
         }
      }
      bool same(int x, int y) {
         return find(x) == find(y);
      }
};
int kruskal(const vector<edge>& E, int N) {
   UnionFind uni(N);
   vector<edge> E_tmp(E.size());
   copy(E.begin(), E.end(), E_tmp.begin());
   SORT(E_tmp);
   int sum = 0;
   for(int i = 0; i < E_tmp.size(); i++) {
      edge e = E_tmp[i];
      if (!uni.same(e.from, e.to)) {
         uni.unite(e.from, e.to);
         sum += e.cost;
      }
   }
   return sum;
}

signed main()
{
   int N; cin >> N;
   V<P<int,int>> x(N), y(N);
   REP(i, N) {
      int s, t; cin >> s >> t;
      x[i] = MP(s, i); y[i] = MP(t, i);
   }

   SORT(x); SORT(y);
   V<edge> E;
   REP(i, N-1) {
      E.PB((edge){ x[i].second, x[i+1].second, x[i+1].first - x[i].first });
      E.PB((edge){ y[i].second, y[i+1].second, y[i+1].first - y[i].first });
   }

   int ans = kruskal(E, N);
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 15724
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

char s[30007];
bool v[3][107][107][107] = {};

int main()
{
    int i,j,k,h;
    int N;

    scanf("%d", &N);
    scanf("%s", s);

    int cnt = 0;
    for( i=0; i<N; i++)
    {
        int now = s[i]-'0';
        for( j=0; j<=9; j++)
        {
            for( k=0; k<=9; k++)
            {
                if( !v[1][j][k][0])
                    continue;
                if( !v[2][j][k][now])
                    cnt++;
                v[2][j][k][now] = 1;
            }
        }
        for( j=0; j<=9; j++)
        {
            if( !v[0][j][0][0])
                continue;
            v[1][j][now][0] = 1;
        }
        v[0][now][0][0] = 1;
    }

    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> vec(N);
    for(int i=0;i<N;i++){
        cin>>vec.at(i);
    }
    int count=0;
    for(int i=0;i<N-2;i++){
        if(vec.at(i)<vec.at(i+1)&&vec.at(i+1)<vec.at(i+2)||vec.at(i)>vec.at(i+1)&&vec.at(i+1)>vec.at(i+2)){
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3596
//Never stop chasing!-MD.SOURAV.

// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll             long long int
#define li             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)       __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())

using namespace std;

double pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664 ;
typedef vector<ll> vll ;
typedef vector<int> vii ;
typedef vector<pair<ll,ll>> vpll;
typedef vector<pair<int,int>> vpii;
typedef map<ll,ll> mpllll;
typedef map<char,ll> mpchll;
typedef map<string,ll>mpsll;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

       int n;
       cin>>n;
       vii v;
       v.pb(0);
       enter(v,n);
       int cnt=0;
       for(int i=1;i<=n;i++)
	   {
	   	if(i&1)
		{
			if(v[i]&1)
			{
				cnt++;
			}
		}
	   }
	   cout << cnt;




}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
    //cin>>test_case ;
    while(test_case--)
	{
		 solve();
	}

	return 0;
}


Measured memory_bytes: 3620
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
void solv() {

	string s;
	cin >> s;

	for (size_t i = 1; i < s.size(); i++)
	{
		if (s[i] == s[i - 1]) {
			cout << "Bad" << endl;
			return;
		}
	}
	cout << "Good" << endl;
}

int main() {
	//	COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 256
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())


Ax = A1 * T1 + A2 * T2
Bx = B1 * T1 + B2 * T2
diff = abs(Ax - Bx)

if diff == 0:
    print('infinity')
    exit()

if not ((A1 * T1 > B1 * T1 and Ax < Bx) or (A1 * T1 < B1 * T1 and Ax > Bx)):
    print(0)
    exit()


ans = 2 * ((abs(B1 - A1) * T1) // diff)
if (abs(B1 - A1) * T1) % diff != 0:
    ans += 1
print(ans)



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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

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

const int MAXN = 1e5 + 5;

int v[3][MAXN];

int per[MAXN];
int fl[MAXN];

int per1[MAXN];
int tmp[MAXN];

ll get_inversions(int *per, int l, int r){
	if (l == r){
		return 0ll;
	}
	int mid = (l + r) / 2;
	ll ans = get_inversions(per, l, mid) + get_inversions(per, mid + 1, r);
	for(int i1 = l, i2 = mid + 1, i = l; i1 <= mid || i2 <= r; ){
		if (i2 == r + 1 || i1 <= mid && per[i1] <= per[i2]){
			tmp[i++] = per[i1++];
		} else {
			ans += mid + 1 - i1;
			tmp[i++] = per[i2++];
		}
	}
	REPN(i, l, r){
		per[i] = tmp[i];
	}
	return ans;
}

void invert(int ind){
	swap(per[ind - 1], per[ind + 1]);
	swap(fl[ind - 1], fl[ind + 1]);
	REPN(k, ind - 1, ind + 1){
		fl[k] ^= 1;
	}
}

bool check(int n){
	REP(i, 0, n){
		if (fl[i] || per[i] != i){
			return false;
		}
	}
	return true;
}

void process_4(int s){
	REP(k, 0, 8){
		invert(s + 1 + k % 2);
		int flag = 0;
		REP(j, 0, 4){
			flag |= fl[s + j];
		}
		if (!flag){
			return;
		}
	}
}

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, 3){
		REP(j, 0, n){
			scanf("%d", &v[i][j]);
		}
	}
	REP(j, 0, n){
		if (v[1][j] % 3 != 2){
			printf("No\n");
			return;
		}
		per[j] = v[1][j] / 3;
		if (per[j] % 2 != j % 2){
			printf("No\n");
			return;
		}
		if (v[0][j] == v[1][j] + 1 && v[2][j] == v[1][j] - 1){
			fl[j] = 1;
		} else if (!(v[0][j] == v[1][j] - 1 && v[2][j] == v[1][j] + 1)){
			printf("No\n");
			return;
		}
	}
	
	REP(j, 0, n - 3){
		if (fl[j]){
			if (!(fl[j + 2])){
				invert(j + 2);
			}
			invert(j + 1);
		}
	}
	if (fl[n - 3] && !fl[n - 2]){
		invert(n - 2);
	}
	if (fl[n - 2] && !fl[n - 1]){
		process_4(n - 5);
	}
	if (fl[n - 1]){
		process_4(n - 4);
	}	

	REP(i, 0, 2){
		int top = 0;
		for(int j = i; j < n; j += 2){
			per1[top++] = per[j] / 2;
		}
		if (get_inversions(per1, 0, top - 1) % 2 == 1){
			printf("No\n");
			return;
		}
	}
	printf("Yes\n");
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 2560