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

int extgcd(int a, int b, int &x, int &y) {
    x = 1;
    y = 0;
    if (b != 0){
        extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }
}

int main(){
    int a,b,x,y;
    cin >> a >> b;
    extgcd(a,b,x,y);
    cout << x << ' ' << y << endl;
}


Measured memory_bytes: 3088
import collections
b=[]
c=[]
n=int(input())
a=list(map(int,input().split()))
q=int(input())
d=collections.Counter(a)
for i in range(q):
    x,y=map(int,input().split())
    b.append(x)
    c.append(y)
sum=0
for i in range(n):
    sum+=a[i]
for i in range(q):
    tmp=d[b[i]]
    d[b[i]]=0
    d[c[i]]+=tmp
    sum=sum-b[i]*tmp+tmp*c[i]
    print(sum)



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

int main() {
   int n;
   long long a[101];
   cin >> n; 
   for(int i = 0; i < n; i++) {
       cin >> a[i];
   }
   int ans = 0; 
   for(int i = 0; i < n-2; i++) {
       for(int j = i+1; j < n-1; j++) {
           for(int k = j+1; k < n; k++) {
               if(a[i] != a[j] && a[j] != a[k] && a[i] != a[k] && 
               a[i] + a[j] > a[k] && a[k] + a[j] > a[i] && a[i] + a[k] > a[j]) {
               	//cout << i+1 << " " << j + 1 << " " << k + 1 << endl;
                   ans++;
               }
           }
       }
   }
   cout << ans;
	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    cout << (ll)(n/2) + n%2 << endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; ++i)
#define X first
#define Y second
#define MP(x,y) make_pair(x,y)
using namespace std;

int main(void){
  int n, d, w;
  while(cin >> n >> d >> w, n+d+w){
    queue<pair<int,int>> q;
    q.push(MP(d,w));
    rep(k,n){
      int p, s;
      cin >> p >> s;
      p--;
//      cout << "dbg " << endl;
      pair<int, int> t;
      rep(i,k+1){
        if(i == p){
          t = q.front();
//          cout <<"!" <<  q.front().X << " , " << q.front().Y << endl;
          q.pop();
        }else{
          q.push(q.front());
//          cout << q.front().X << " , " << q.front().Y << endl;
          q.pop();
        }
      }

      s %= (t.X + t.Y + t.X + t.Y);
      if(s-(t.X + t.Y) > 0){
        s-=(t.X + t.Y);
      }
      if( s <= t.X){
        if(t.X-s > s){
          q.push(MP(s,t.Y));
          q.push(MP(t.X-s, t.Y));
        }else{
          q.push(MP(t.X-s, t.Y));
          q.push(MP(s,t.Y));
        }

      }else if( s <= t.X + t.Y){
        s-=t.X;
        if(t.Y-s > s){
          q.push(MP(t.X, s));
          q.push(MP(t.X, t.Y-s));
        }else{
          q.push(MP(t.X, t.Y-s));
          q.push(MP(t.X, s));
        }
      }
    }
    vector<int> ans;
    while(!q.empty()){
      ans.push_back(q.front().X * q.front().Y);
      q.pop();
    }
    sort(ans.begin(), ans.end());
    rep(i,ans.size()){
      if(i != 0){
      cout << " ";
      }
      cout << ans[i];
    }
  cout << endl;
  }
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int N,X;cin>>N>>X;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int now=0;
  int ans=1;
  for(int i=0;i<N;i++){
    now=now+v[i];
    if(now<=X)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int si=s.size();
  rep(i,si/2){
    if(s[i]!=s[si-i-1]){
      cout<<"No";
      return(0);
    }
  }
  int count=0;
  rep(i,(si/2/2)+1){
    if(s[i]!=s[si/2-count-1]){
      cout<<"No";
      return(0);
    }
    count++;
  }
  count=0;
  REP(i,(si+1)/2,si-(si/2/2)){
    if(s[i]!=s[si-count-1]){
      cout<<"No";
      return(0);
    }
    count++;
  }
  cout<<"Yes";
  return(0);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 99999999
#define eps 1e-9

bool solve(vector<int> a){
//    rep(i,a.size())cout<<a[i]<<" ";cout<<endl;
    int s=a[1]-a[0];
    for(int i=2;i<a.size();i++){
        if(a[i]-a[i-1]!=s)return false;
    }
    return true;
}

int main(){
    int n;
    while(cin>>n&&n){
        vector<int> vec;
        rep(i,n+1){
            int a;
            cin>>a;
            vec.pb(a);
        }
        vector<int> b;
        rep(i,n+1){
            b=vec;
            b.erase(b.begin()+i);
            if(solve(b)){cout<<vec[i]<<endl;break;}
        }
    }
}

Measured memory_bytes: 1224
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int num[3][3];
    rep(i,3){
        rep(j,3) cin >> num[i][j];
    }
    int n;
    cin >> n;
    int dec[n];
    rep(i,n) cin >> dec[i];

    bool hit[3][3];
    memset(hit,0,sizeof(hit));
    rep(i,3){
        rep(j,3){
            rep(k,n){
                if(dec[k] == num[i][j]) hit[i][j] = true;
            }
        }
    }
    bool bingo = false;
    rep(i,3){
        if(hit[i][0] == true && hit[i][1] == true && hit[i][2] == true) bingo = true;
    }
    rep(j,3){
        if(hit[0][j] == true && hit[1][j] == true && hit[2][j] == true) bingo = true;
    }
    if(hit[0][0] == true && hit[1][1] == true && hit[2][2] == true) bingo = true;
    if(hit[0][2] == true && hit[1][1] == true && hit[2][0] == true) bingo = true;
    if(bingo == true) dunk("Yes");
    else dunk("No");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println((a + b) / 2);
        }
    }
}



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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repi(i, x) for (auto &i : (x))

#ifndef __SOULTCH
#define endl '\n'
#define debug(...) 
#else
#define __debug_a(v) cout << " [+] " << #v << " = " << (v) << endl
#define __debug_b(v) cout << "     " << #v << " = " << (v) << endl
#define debug1(v1) __debug_a(v1);
#define debug2(v1, v2) __debug_a(v1), __debug_b(v2);
#define debug3(v1, v2, v3) __debug_a(v1), __debug_b(v2), __debug_b(v3);
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define debug(...) GET_MACRO(__VA_ARGS__, debug3, debug2, debug1)(__VA_ARGS__)
#endif

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << pai.first << ' ' << pai.second;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    rep(i, sz(v)) cout << v[i] << ' ';
    return os;
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> s) {
    for (T p : s) cout << p << ' ';
    return os;
}

template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> s) {
    for (auto p : s) cout << '(' << p << ") ";
    return os;
}

template<typename T, typename V>
istream &operator>>(istream &is, pair<T, V> &pai) {
	is >> pai.first >> pai.second;
	return is;
}

template<typename T> void umax(T &a, T b) {a = max(a, b);}
template<typename T> void umin(T &a, T b) {a = min(a, b);}

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int N, K; cin >> N >> K;
    cout << (N-K+1) << endl;
}

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


int main(){
    long long  N, Q; 
    cin >> N >> Q;
    vector<pair<char, int>> q;
    string s;
    cin >> s;

    for(int i = 0; i < Q ; i++){
        char t;
        char d;
        cin >> t >> d;
        int num = d == 'R' ? 1 : -1;    // Rなら1,Lなら-1 として取得
        q.push_back(make_pair(t, num));
    }

    // ＝二分法＝

    // 左端と右端を定義
    int L = -1, R = N;
    // 左側の特定
    // R - L > 1 右端と左端が隣合わない時
    while( R - L > 1){
        // 中心の計算
        int M = (L+R)/2;
        int center = M;
        // 左端のフラグ
        bool leftFlag = false;
        // 命令の回数だけ繰り返し
        for(int i = 0; i < Q ; i++){
            // 中心の文字列　== 命令の文字列　ならば
            if( s[center]== q[i].first){
                // 中心をL,Rへ動かす
                center += q[i].second;
            }
            // 中心が右端にたどり着いた時は中心から右はnになるので次
            if(center == N){
                break;
            }
            // 中心が左端にたどり着いた時は中心から左は-1になるので次
            else if(center == -1){
                leftFlag = true;
                break;
            }
        }
        // 中心が左端に行くことがわかったら左を真ん中へ
        if (leftFlag)  L = M;
        // それ以外は右を動かす
        else  R = M;
    }
    // 左の位置
    int Left = L;

    // 右側の特定
    // R - L > 1 右端と左端が隣合わない時
    L = -1, R = N;
    while( R - L > 1){
        // 中心の計算
        int M = (L+R)/2;
        int center = M;
        // 右端のフラグ
        bool rightFlag = false;
        // 命令の回数だけ繰り返し
        for(int i = 0; i < Q ; i++){
            // 中心の文字列　== 命令の文字列　ならば
            if( s[center] == q[i].first){
                // 中心をL,Rへ動かす
                center += q[i].second;
            }
            // 中心が左端にたどり着いた時は中心から左は-1になるので次
            if(center == -1){
                break;
            }
            // 中心が右端にたどり着いた時は中心から右はnになるので次
            else if(center == N){
                rightFlag = true;
                break;
            }
        }
        // 中心が右端に行くことがわかったら右を真ん中へ
        if (rightFlag)  R = M;
        // それ以外は左を動かす
        else  L = M;
    }
    // 右の位置
    int Right = R;
    //左と右が重なっているもしくは入れ替わった時　-> 0
    if ( Left >= Right ) cout << 0 << endl;
    // そうじゃなければ右-左をした数が残りの数
    else cout << Right - Left -1 << endl;
}

Measured memory_bytes: 2680
import math
H,W = input().split()
H=int(H)
W=int(W)
if H==1 or W==1:
  ans=1
elif H%2==0:
  ans=(H*W)/2
else:
  ans=((H-1)*W/2)+math.ceil(W/2)

print('{:.18g}'.format(ans))

Measured memory_bytes: 3060
//2
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cstdlib>
#include<cassert>
using namespace std;
int main(){
    int N;
    cin >> N;
    int a[50];

    bool all_p = true;
    bool all_m = true;
    bool all_z = true;

    int max = -9999999;
    int min = 9999999;
    int max_num = -1;
    int min_num = -1;

    //int kari = 0;
    
    for(int i=0; i<N; i++){
        cin >> a[i];
        //if(a[i-1] > a[i]) kari++;
        if(a[i]>0){
            all_m = false;
            all_z = false;
        }
        else if(a[i]<0){
            all_p = false;
            all_z = false;
        }

        if(a[i] > max){
            max = a[i];
            max_num = i;
        }
        if(a[i] < min){
            min = a[i];
            min_num = i;
        }
    }

    if(all_z){
        cout << 0 << endl;
    }
    else if(all_p){
        cout << N-1 << endl;
        for(int i=1; i<N; i++){
            cout << i-1+1 << " " << i+1 << endl;
        }
    }
    else if(all_m){
        cout << N-1 << endl;
        for(int i=0; i+1<N; i++){
            cout << N-i-1+1 << " " << N-i-1 << endl;
        }
    }
    else{
        if(abs(max) >= abs(min)){
            cout << 2*N << endl;
            cout << max_num+1 << " " << max_num+1 << endl;
            for(int i=0; i<N; i++){
                cout << max_num+1 << " " << i+1 << endl;
            }
            for(int i=1; i<N; i++){
                cout << i-1+1 << " " << i+1 << endl;
            }
            //cout << "ue" << endl;
        }
        else{
            cout << 2*N << endl;
            cout << min_num+1 << " " << min_num+1 << endl;
            for(int i=0; i<N; i++){
                cout << min_num+1 << " " << i+1 << endl;
            }
            for(int i=0; i+1<N; i++){
                cout << N-i-1+1 << " " << N-i-1 << endl;
            }
            //cout << "sita" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
    public static void main(String[] args) {
	   Scanner sc = new Scanner(System.in);
	   int a,b,c;
	   int sa[]= new int[7];
	   for(c=0;c<=6;c++){
	   a=sc.nextInt();
	   b=sc.nextInt();
	   sa[c]=a-b;
	   
	   }
		for(c=0;c<=6;c++){
			System.out.println(sa[c]);			
			
		}


	    }
	}

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

int main(){
    int n;
    long long a[100010];
    cin >> n;
    for (int i=1; i<n+1; i++){
        cin >> a[i];
    }
    int ans = 1;
    bool up = true;
    bool down = true;
    for (int i=1; i<n;){
        if (a[i+1]==a[i]){
            i++;
        }
        else if (up && a[i+1]>a[i]){
            down = false;
            i++;
        }
        else if (down && a[i+1]<a[i]){
            up = false;
            i++;
        }
        else if (!down && a[i+1]<a[i]){
            down = true;
            ans++;
            i++;
        }
        else if (!up && a[i+1]>a[i]){
            up = true;
            ans++;
            i++; 
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

  // ここにプログラムを追記
for(int i=0; i<N; i++) {
string cl;
cin >> cl;
if(cl=="Y")  {
cout << "Four" <<endl; break;}
else if(cl=="P"&&i!=N-1) {
continue; }
else if(cl=="W"&&i!=N-1) {
continue; }
else if(cl=="G"&&i!=N-1) {
continue; }
cout << "Three" << endl;
}
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include <stdlib.h>

int fact(int n){
    if(n == 0){
        return 1;
    }else{
        int ans=1;
        for(int i = 1 ; i <= n ;i++){
            ans *= i;
        }
        return ans;
    }
}

int main(){
    int N;
    int P[8],Q[8];
    int a = 0;
    int b = 0;
    scanf("%d",&N);
    for(int i = 0 ; i < N ;i++){
        scanf("%d",&P[i]);
    }
    for(int i = 0 ; i < N ;i++){
        scanf("%d",&Q[i]);
    }
    for(int i = 0 ; i < N-1 ;i++){
        int s=P[i] - 1;
        for(int j = 0 ; j <= i ; j++){
            if(P[j] < P[i]){
                s--;
            }
        }
        a += s*fact(N-1-i);

    }
    for(int i = 0 ; i < N-1 ;i++){
        int s = Q[i] - 1;
        for(int j = 0 ; j <= i ; j++){
            if(Q[j] < Q[i]){
                s--;
            }
        }
        b += s*fact(N-1-i);
    }
    printf("%d",abs(a-b));
    
    return 0;
}

Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn g_dfs(g: &Vec<Vec<usize>>, v: &mut Vec<usize>,
         path: (usize, usize), exclude: (usize, usize)) -> bool {
    if path.0 == path.1 {
        return true;
    }
    for x in &g[path.0] {
        if path.0 == exclude.0 && *x == exclude.1 {
            continue;
        }
        if v[*x] == 1 {
            continue;
        }
        v[*x] = 1;
        if g_dfs(g, v, (*x, path.1), exclude) {
            return true;
        }
    }
    return false;
}

fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(usize1,usize1);m]
    }
    let mut g = vec![Vec::new();n];
    for &(a,b) in &ab {
        g[a].push(b);
        g[b].push(a);
    }
    let mut res = 0;
    for &exclude in &ab {
        let mut reachable = true;
        for a in 0..n {
            for b in 0..n {
                let mut v = vec![0;n];
                if !g_dfs(&g, &mut v, (a,b), exclude) {
                    reachable = false;
                    break;
                }
            }
        }
        if reachable {
            res += 1;
        }
    }
    println!("{}", m - res);
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
int main()
{
	int n,x,y,a,b,qq;
	while(scanf("%d",&x)!=EOF){
		scanf("%d%d%d",&y,&a,&b);
		qq=x*y-a*y-b*x+a*b;
		printf("%d\n",qq);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
void solve(){
	int n; cin >> n;
	int a, b, c; cin >> a >> b >> c;
	int a1, b1, c1;
	for(int i = 1; i < n; i++){
		cin >> a1 >> b1 >> c1;
		a1 += max(b, c);
		b1 += max(a, c);
		c1 += max(a, b);
		a = a1; b = b1; c = c1;
		//cout << i << ": "<<a << " " <<b<< " " <<c<<endl;
	}
	//cout << endl;
	cout << max({a, b, c}) << endl;
}
int main(){
	//int t; cin >> t;
	 int t = 1;
	while(t--){
		solve();
	}
}


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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int h, w, x, y;
void in(){
    cin >> w >> h >> x >> y;
}

void solve(){

    if(w / 2.0 == x && h / 2.0 == y){
        cout << w * h / 2.0 << ' ' << 1 << endl;
    }else{
        cout << w * h / 2.0 << ' ' << 0 << endl;
    }
}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using cd = complex<double>;
#define speed                                                                  \
    ios_base::sync_with_stdio(false);                                          \
    cin.tie(0);                                                                \
    cout.tie(0);
#define ll long long
#define ull unsigned long long
#define db double
#define vi vector<ll>
#define vvi vector<vector<int> >
#define vvii vector<vector<pii> >
#define rep2(i, begin, end)                                                    \
    for (__typeof(end) i = (begin) - ((begin) > (end));                        \
         i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define rep(i, a, b) for (int i = a; i < b; i++)
#define endl "\n"
#define pii pair<ll, ll>
#define piii pair<ll, pair<ll, ll> >
#define mem(a, b) memset(a, b, sizeof a);
#define pb push_back
#define pf push_front
#define F first
#define S second
#define mp make_pair
#define all(v) v.begin(), v.end()
#define range(i, s) for (auto i : s)
#define sor(v) sort(v.begin(), v.end());
#define rev(v) reverse(v.begin(), v.end());
#define inf INFINITY
#define mc(a, b) memcpy(a, b, sizeof(b));
#define per(i, a, b) for (ll i = a - 1; i >= b; i--)
#define PI 3.14159265359

#define error(args...)                                                         \
    {                                                                          \
        string _s = #args;                                                     \
        replace(_s.begin(), _s.end(), ',', ' ');                               \
        stringstream _ss(_s);                                                  \
        istream_iterator<string> _it(_ss);                                     \
        err(_it, args);                                                        \
    }

void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

#define deb1(a) cout << #a << "=*" << a << endl;
#define deb2(a) cout << #a << "=@" << a << endl;
#define deb3(a) cout << #a << "=#" << a << endl;
#define deb4(a, b) cout << #a << "=" << a << " and " << #b << "=" << b << endl;
#define deb5(a, b) cout << #a << "=" << a << " and " << #b << "=" << b << endl;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
// find_by_order -> value at index
// order_of_key -> index of value

ll mod = 1000000007;
ll vis[212345] = {0};
vvi v(212345);
ll d[212345] = {0};

ll pow(ll a, ll b, ll m)
{
    ll ans = 1;
    while (b)
    {
        if (b & 1)
            ans = (ans * a) % m;
        b /= 2;
        a = (a * a) % m;
    }
    return ans;
}

int main()
{
    speed ll m;
    cin >> m;
    ll c = 1 + (1999 - m) / 200;
    cout << c << endl;
}

Measured memory_bytes: 8120
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, m;
    string s;
    cin >> n >> m >> s;
    vector<int> dp(n+1, inf);
    dp[n] = 0;
    queue<int> q;
    q.push(0);
    for(int i=n-1; i>=0; i--)
    {
        while(1)
        {
            if(q.size() == 0)
            {
                cout << "-1" << endl;
                return 0;
            }
            if(q.front()!=inf && q.size()<=m) break;
            q.pop();
        }
        if(s[i]=='0') dp[i] = q.front()+1;
        q.push(dp[i]);
    }
    vector<int> ans;
    int x = 0;
    int rest = dp[0];
    while(x<n)
    {
        rest--;
        int i=1;
        while(dp[x+i] != rest) i++;
        ans.push_back(i);
        x += i;
    }
    for(int i=0; i<ans.size(); i++) printf("%d%c", ans[i], i==int(ans.size())-1?'\n':' ');
    return 0;
}


Measured memory_bytes: 1528
n,m = map(int,input().split())

x = []
y = []
ans = [10]*n 

for i in range(m):
    s = input().split()
    x.append(int(s[0]))
    y.append(int(s[1]))

cnt = 0

q = 0

for i in x:
    if i == 1 and y[cnt] == 0 and n!=1:
        print(-1)
        q = 1
        break
    else:
        if ans[i-1] !=10:
            if ans[i-1]==y[cnt]:
                cnt += 1
            else:
                print(-1)
                q = 1
                break
        else:
            ans[i-1] = y[cnt]
            cnt += 1
            
cnt2 = 0

if q ==0:
    for i in ans:
        if i == 10:
            if cnt2 == 0:
                if n == 1:
                    ans[cnt] = 0
                else:
                    ans[cnt2] = 1
            else:
                ans[cnt2] = 0
        cnt2 += 1
    for i in ans:
        print(i,end = "")

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int h1,h2,m1,m2;
    ll k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int x = h1*60 + m1;
    int y = h2*60 + m2;
    int l = y-x;

    if(l-k>=0){
        cout << l-k << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3588
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y) { return x / gcd(x, y) * y; }

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

  map<string, int> m;
  m["SUN"] = 7;
  m["MON"] = 6;
  m["TUE"] = 5;
  m["WED"] = 4;
  m["THU"] = 3;
  m["FRI"] = 2;
  m["SAT"] = 1;

  string s;
  cin >> s;

  cout << m[s] << endl;

  return 0;
}


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

public class Main {
  public static void main(String[] args) {
    Scanner sn = new Scanner(System.in);
    int N = sn.nextInt();
    int M = sn.nextInt();
    int[] sc = new int[N];
    Arrays.fill(sc, -1);

    // Check inconsistency.
    for (int i = 0; i < M; i++) {
      int s = sn.nextInt();
      int c = sn.nextInt();
      if (sc[s - 1] == -1) {
        sc[s - 1] = c;
      } else if (sc[s - 1] != c) {
        System.out.println(-1);
        return;
      }
    }
    // starting with 0.
    if (sc[0] == 0 && N == 3 || sc[0] == 0 && N == 2) {
      System.out.println(-1);
      return;
    }
    if (sc[0] == -1 && N == 1) {
      System.out.println(0);
      return;
    }
    int ans = sc[0] == -1 ? 1 : sc[0];
    for (int i = 1; i < N; i++) {
      ans *= 10;
      int d = sc[i];
      if (d == -1) {
        d = 0;
      }
      ans += d;
    }
    System.out.println(ans);
  }
}


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

using namespace std;

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

    vector<int> rate_count(9, 0);
    for (int i = 0; i < N; i++) {
        int ai_rate;
        cin >> ai_rate;
        rate_count[min(ai_rate / 400, 8)]++;
    }

    int exist_rate_count = 0;
    for (int i = 0; i < 8; i++) {
        if (rate_count[i] > 0) {
            exist_rate_count++;
        }
    }

    cout << max(exist_rate_count, 1) << " " << exist_rate_count + rate_count[8] << endl;
    return 0;
};


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))

ll calc(ll a,ll b,ll p){//a^(b) mod p   
	if(b==0)return 1;
	ll y = calc(a,b/2,p);y=(y*y)%p;
	if(b & 1) y = (y * a) % p;
	return y;
}


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

	ll dp[13]={};
	dp[0] = 1;
	REV(s);
	ll ten = 0;
	for(char x:s){
		vector<ll> dp2(13,0);
		if(x=='?'){
			FOR(j,0,10){
				ll add = calc(10,ten,13)*j%13;
				FOR(i,0,13)(dp2[(add+i)%13] += dp[i])%=MOD;
			}
		}else{
			ll add = calc(10,ten,13)*(x-'0')%13;
			FOR(i,0,13)(dp2[(add+i)%13] += dp[i])%=MOD;
		}
		FOR(i,0,13) dp[i] = dp2[i];
		ten++;
		//FOR(i,0,13)cout<<dp[i]<<" ";
		//cout << endl;
	}
	cout << dp[5] << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
constexpr int MX = 2000005, MOD = 1e9+7;
int r1, r2, c1, c2;
ll ans;
ll exp(ll b, ll n){
	ll res = 1;
	for(; n; n/=2,(b*=b)%=MOD) if(n%2) (res *= b) %= MOD;
	return res;
}
ll fact[MX] = {1}, invf[MX];
void setcomb(int n){
	for(int i = 1; i <= n; i++) fact[i] = (fact[i-1] * i) % MOD;
	invf[n] =  exp(fact[n] ,MOD-2);
	for(int i = n; i > 0; i--) invf[i-1] = (invf[i] * i) % MOD;
}
inline ll comb(int a, int b){return fact[a] * invf[a-b] % MOD * invf[b] % MOD;}
int main(){
	scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
	r2++; c2++;
	setcomb(r2+c2);
	ans = (comb(r2+c2,r2) - comb(r2+c1,r2) - comb(r1+c2,r1) + comb(r1+c1,r1)) % MOD;
	if(ans < 0) ans += MOD;
	printf("%lld\n", ans);
}

Measured memory_bytes: 31488
// Problem : A - Repeat ACL
// Contest : AtCoder - ACL Beginner Contest
// URL : https://atcoder.jp/contests/abl/tasks/abl_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define INF 1000000000000000000
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};
//const int N=2e5;

template<class T>
T abst(T a)
{return a<0?-a:a;}

void solve()
{	
	int n;
	cin>>n;
	while(n--)
	cout<<"ACL";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#define MAX_N 110
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int cost[MAX_N][MAX_N], mincost[MAX_N];
bool used[MAX_N];
int prim(int n)
{
    int res = 0;
    mincost[0] = 0;
    while(true)
    {
        int v = -1;
        for(int u = 0; u < n; u++)
        {
            if(!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
        }
        if(v == -1) break;
        used[v] = true;
        res += mincost[v];
        for(int u = 0; u < n; u++) mincost[u] = min(mincost[u], cost[v][u]);
    }
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    for(int i = 0; i < MAX_N; i++) used[i] = false;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            cin >> cost[i][j];
            if(cost[i][j] == -1) cost[i][j] = INF;
        }
        mincost[i] = INF;
    }
    int ans = prim(n);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3168
def main():
    MOD = 998244353

    N, S = map(int, input().split())
    A = tuple(map(int, input().split()))

    DP0 = [[0] * (S + 1) for _ in range(N + 1)]
    DP1 = [[0] * (S + 1) for _ in range(N + 1)]
    DP2 = [[0] * (S + 1) for _ in range(N + 1)]

    DP0[0][0] = 1

    for i in range(N):
        DP0[i + 1][0] = DP0[i][0] 
        DP1[i + 1][0] = DP0[i][0] + DP1[i][0]
        a = A[i]
        if a > S:
            for j in range(1, S + 1):
                DP1[i + 1][j] = DP1[i][j] #以前から合計jになっている場合のみOK
        else:
            for j in range(1, a):
                DP1[i + 1][j] = DP1[i][j] #以前から合計jになっている場合のみOK
            for j in range(a, S + 1):
                DP1[i + 1][j] = (DP1[i][j] + DP0[i][j - a] + DP1[i][j - a]) % MOD
                # DP[i + 1][j][1] = (DP[i][j][0] + DP[i][j][1] + DP[i + 1][j - a][1]) % MOD

        DP2[i + 1][S] = (DP1[i][S] + DP2[i][S])
        if a <= S:
            DP2[i + 1][S] += DP0[i][S - a] + DP1[i][S - a]
        DP2[i + 1][S] %= MOD

    print (DP2[N][S])

    # for i in range(N + 1):
    #     print (DP[i])

if __name__ == '__main__':
    main()

Measured memory_bytes: 247944
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

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



Measured memory_bytes: 3644
/*"You can do anything you set your mind to,man" - Eminem*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define llpow(a,b) (ll)(pow(a,b)+0.5)
#define l_b(a,val) min((int)a.size()-1, (int)(lower_bound(a.begin(),a.end(),val)-a.begin()))
#define f first
#define up(a,b) max(a,b)
#define s second
#define INF 9223372036854775807
const  int mod = 1000000007;
template <typename T> T add(T& a, T b){a+=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
template <typename T> T mul(T& a, T b){ a = a*b%mod;}
template <typename T> T up_self(T& a, T b){a = up(a,b);}
template <typename T> T min_self(T& a, T b){a = min(a,b);}
string find_largest_pref_palindrome(const string& a){string s = a;reverse(s.begin(),s.end());s = a+"%"+s;int c = 0;vector<int> pref(2*((int)a.size()) +2);for(int i = 1; i< s.size() ; i++ ){while(c!=0&&s[i]!=s[c])c = pref[c-1];if(s[i]==s[c])c++;pref[i] = c;}return s.substr(0,c);}
ll binexpomodulo(ll x, ll y){ll res =1;x%=mod;if(!x)return 0;while(y){if(y&1){mul(res, x);}mul(x,x);y>>=1;}return res;}
ll nCrInOr(ll n, ll r){ll res = 1;if(r>n-r)r = n-r;ll rin = 1;for(ll i = 1; i <=r ; i++)rin = (rin*i)%mod;rin = binexpomodulo(rin,mod-2);for(ll i = 1; i <= r; i++)res = (res*(n-i+1))%mod;res = (res*rin)%mod;return res;}
int msb(ll n){int ans;for(int i = 0 ; i < 64;  i++)if(n&(1LL<<i))ans = i+1;return ans;}
/*All the macros below are copied from nik_y(OG)*/
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define all(c) c.begin(),c.end()
#define endl "\n"
#define get(a,n) fl(i,0,n)  cin>>a[i];
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
int main()
{
	Shazam;
	int a,b; cin>>a>>b;
	if(b>=a)
		cout<<"unsafe"<<endl;
	else
		cout<<"safe"<<endl;
  	return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
#include<math.h>
int main(void)
{
	int i,a,b,n,s;

	while (scanf("%d %d %d", &a, &b, &n) != EOF) {
		for(i=0,s=0; i<n; i++){
			a %= b;
			a *= 10;
			s += a / b;
		}
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
int a[110][110];
int n;
bool check(int x)
{
    for(int i=1;i<=n;i++)
        if(x&(1<<(i-1)))
            for(int j=1;j<=n;j++)
                if(a[i][j]>=0 && (a[i][j]^((x>>(j-1))&1)))
                {
                    //printf("%d %d %d %d\n",i,j,a[i][j],(x>>(j-1)));
                    return 0;
                }
    return 1;
}
int pt(int x)
{
    int ans=0;
    while(x)
        ans+=(x&1),x>>=1;
    return ans;
}
int main()
{
    cin>>n;
    memset(a,-1,sizeof(a));
    for(int i=1;i<=n;i++)
    {
        int m;
        cin>>m;
        for(int j=0;j<m;j++)
        {
            int x,y;
            cin>>x>>y;
            a[i][x]=y;
        }
    }
   // for(int i=1;i<=n;i++)
   //     for(int j=1;j<=n;j++)
   //         printf("%d%c",a[i][j],j==n?'\n':' ');
    int m=(1<<n)-1,ans=0;
    while(m)
    {
        if(check(m))
            ans=max(ans,pt(m));
        //printf("%d %d\n",m,check(m));
        m--;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10;
int pre[maxn],sizes[maxn],ranks[maxn];
int m,n;
void inint()
{
    for(int i=1;i<=n;i++)
    {
        pre[i]=i;
        sizes[i]=1;
      //  ranks[i]=0;

    }
}
int finds(int x)
{
    if(x==pre[x])
    {
        return x;
    }
  else
    return pre[x]=finds(pre[x]);
}
bool same(int a,int b)
{
  return finds(a)==finds(b);

}
void unint(int a,int b)
{
       int x=finds(a);
       int y=finds(b);
       if(x==y)
        return ;
       if(sizes[x]<sizes[y])
       {
           pre[x]=y;
           sizes[y]+=sizes[x];
       }
       else
       {
           pre[y]=x;
           sizes[x]+=sizes[y];
           /*if(ranks[x]==ranks[y])
               ranks[x]++;*/
       }

       return ;

}
int main()
{
     scanf("%d%d",&n,&m);
     vector<int>a(m),b(m);
     inint();
     vector<ll>ans(m);
     for(int i=0;i<m;i++)
      cin>>a[i]>>b[i];
    ans[m-1]=(long long)n*(n-1)/2;
    for(int i=m-1;i>=1;i--)
    {
        ans[i-1]=ans[i];
        if(!same(a[i],b[i]))
        {
            ans[i-1]-=(ll)sizes[finds(a[i])]*sizes[finds(b[i])];
            unint(a[i],b[i]);
        }
    }
    for(int i=0;i<m;i++)
      cout<<ans[i]<<endl;

    return 0;
}


Measured memory_bytes: 3712
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String[] nyu=sc.nextLine().split(" ");

  //   String nyu=sc.nextLine();
int A=Integer.parseInt(nyu[0]);
int B=Integer.parseInt(nyu[1]);
int C=Integer.parseInt(nyu[2]);
//int D=Integer.parseInt(nyu[3]);


//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/
if(A+B>=C && A<=C){
System.out.println("YES");
}else{
System.out.println("NO");

}





	}
}

Measured memory_bytes: 21844
#!/usr/bin/env python

def main():
    h, w, k = map(int, input().split())
    c = [input() for _ in range(h)]

    b_init = 0
    for i in range(h):
        for j in range(w):
            if c[i][j] == '#':
                b_init += 1

    cnt = 0
    for bit_h in range(2**h):
        for bit_w in range(2**w):
            b_cnt = b_init

            for i in range(h):
                for j in range(w):
                    if ((bit_h >> i) & 1) or ((bit_w >> j) & 1):
                        if c[i][j] == '#':
                            b_cnt -= 1

            if b_cnt == k:
                cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, m, t, a[100005];
vector< ll > adj[100005];
#define ari for( int i = 0 ; i < n ; i++ ) cin >> a[i];
#define ginp for( int i = 0 ; i < m ; i++ ){ int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u);}
#define pb push_back
#define ss second
#define ff first
#define fs first.second
#define fff first.first
#define sss second.second
#define sf second.first
#define mp make_pair
void printar(vector< ll > ar, ll l, ll r){
	for(int i = l ; i < r ; i++)
		cout << ar[i] << " ";
	cout << endl;
}
	
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    ari;
    sort(a, a + n);
    ll ctr = 0;
    for(int i = 0 ; i < n ; i++)
    	for(int j = i + 1; j < n ; j++)
    		if( a[i] != a[j] )
	    		for(int k = j + 1 ; k < n ; k++)
    				if( a[k] != a[j] and a[i] + a[j] > a[k] )
    					ctr++;
    cout << ctr << endl;
	return(0);
}

Measured memory_bytes: 6044
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> P;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

const int MaxN=220000;
int bit[MaxN];
void add(int a, int w) {
for (int x = a; x <= MaxN; x += (x & -x)) bit[x] += w;
}
int sum(int a) {
 int ret = 0;
for (int x = a; x > 0; x -= (x & -x)) ret += bit[x];
 return ret;
}

int main(){
    ll N,K; cin>>N>>K;
    vec d(N+1,0);
    rep(i,N){
        ll x; cin>>x;
        x-=K;
        d.at(i+1)=d.at(i)+x;
    }

    vector<P> So;
    rep(i,N+1) So.pb(mp(d.at(i),i));
    
    sort(ALL(So));
    //rep(i,N+1) cout<<So.at(i).first<<' '<<So.at(i).second<<endl;

    vec A(N+1);
    rep(i,N+1) A.at(So.at(i).second)=i;
    //rep(i,N+1) cout<<A.at(i)<<endl;
    ll ans=0;
    rep(i,N+1) {
        ans+=sum(A.at(i)+50);
        add(A.at(i)+50,1);
    }
    cout<<ans<<endl;



    

}

Measured memory_bytes: 8172
N = int(input())
a = list(map(int, input().split()))
dp = []

def mins(minval, val):
	if minval < val:
			return minval
	else:
			return val

for i in range(N):
	dp.append(1000000000000)

for i in range(len(a)):
	if i == 0:
		dp[0] = 0
	if i == 2:
		dp[1]= abs(a[1] - a[0])
	
	
	dp[i] = min(dp[i], dp[i-1] + abs(a[i-1] - a[i]))
	dp[i] = min(dp[i], dp[i-2] + abs(a[i-2] - a[i]))
#print(dp)
print(dp[N-1])

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

#define NOT_FOUND -1

using namespace std;

int N;
long long K;
vector<long long> zero_pos;
vector<long long> neg;
vector<long long> zero_pos_r;
vector<long long> neg_r;

long long solve(long long parent_mid) {
    long long ret = 0;
    // leftの位置=iに掛けるとparent_mid以上になる相方
    // 負 * 負
    for (int i = 0; i < neg_r.size(); ++i) {
        long long left = i, right = neg_r.size();
        while (right - left > 1) {
            long long mid = (right - left) / 2 + left;
            if (mid <= i) {
                left = mid;
            }
            else {
                if (neg_r[mid] * neg_r[i] < parent_mid) left = mid;
                else right = mid;
            }
        }

        ret += left - i;
    }

    // 負 * 正
    for (int i = 0; i < neg.size(); ++i) {
        long long left = -1, right = zero_pos_r.size();
        while (right - left > 1) {
            long long mid = (right - left) / 2 + left;
            if (mid < 0) {
                left = mid;
            }
            else {
                if (zero_pos_r[mid] * neg[i] < parent_mid) left = mid;
                else right = mid;
            }
        }
        ret += right;
    }

    // 正 * 正
    for (int i = 0; i < zero_pos.size(); ++i) {
        long long left = i, right = zero_pos.size();
        while (right - left > 1) {
            long long mid = (right - left) / 2 + left;
            if (zero_pos[mid] * zero_pos[i] < parent_mid) left = mid;
            else right = mid;
        }

        ret += left - i;
    }

    return ret;
}

int main(void) {
    cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        long long a;
        cin >> a;
        if (a >= 0) {
            zero_pos.push_back(a);
            zero_pos_r.push_back(a);
        }
        else {
            neg.push_back(a);
            neg_r.push_back(a);
        }
    }

    sort(zero_pos.begin(), zero_pos.end());
    sort(neg.begin(), neg.end());

    sort(zero_pos_r.begin(), zero_pos_r.end());
    reverse(zero_pos_r.begin(), zero_pos_r.end());

    sort(neg_r.begin(), neg_r.end());
    reverse(neg_r.begin(), neg_r.end());

    long long right = 2000000000000000005LL;
    long long left = -2000000000000000005LL;
    while (right - left > 1) {
        long long mid = (right - left) / 2 + left;

        long long k = solve(mid); // mid 未満の積になる組み合わせがいくつ？
        // 少ない ＝ まだ mid をあげられる
        if (k < K) {
            left = mid;
        }
        // 同じか多い = midを下げて調整する
        else {
            right = mid;
        }
    }

    cout << left << endl;

    return 0;
}

Measured memory_bytes: 3720