akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int h,w;
    cin>>h>>w;
    int cnt = 0;
    rep(i, h)
    {
        string s;
        cin>>s;
        rep(j,s.size()){
            if(s[j]=='#'){
                cnt++;
            }
        }
    }
    if(cnt==h+w-1){
        cout << "Possible" << endl;
    }
    else {
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value


void solve() {

	bool ans;
	string S;
	cin >> S;
	char f, c;
	f = S[0];
	for (int i = 0; i < S.length(); i++) {
		if (S[i] != f) {
			c = S[i];
		}
	}
	int cntf = 0, cntc = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == f) cntf++;
		if (S[i] == c) cntc++;
	}
	cout << ((cntf == 2 && cntc == 2) ? "Yes" : "No") << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

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

using namespace std;

int N;
long long A[500];
long long K;

long long getCost(int target) {
    long long up[500];
    long long down[500];
    vector<int> up_idx;
    for (int i=0; i<N; i++) {
        down[i] = A[i] % target;
    }
    sort(down, down+N);
    long long upcost = 0;
    for (int i=0; i<N; i++) {
        up[i] = target - down[i];
        upcost += up[i];
    }
    long long downcost = 0;
    for (int i=0; i<N; i++) {
        downcost += down[i];
        upcost -= up[i];
        if (downcost == upcost) {
            return downcost;
        }
    }
    cerr << "err" << endl;
    return -1;
}
int main() {
    cin >> N >> K;
    for (int i=0; i<N; i++) cin >> A[i];
    long long allsum = 0;
    for (int i=0; i<N; i++) allsum += A[i];
    
    vector<long long> gs;
    for (long long g=1; g*g<=allsum; g++) {
        if (allsum % g == 0) {
            long long h = allsum / g;
            gs.push_back(g);
            if (h != g) gs.push_back(h);
        }
    }
    sort(gs.begin(), gs.end(), greater<long long>());

    for (const auto g: gs) {
        long long cost = getCost(g);
        //cerr << g << ":" << cost << endl;
        if (cost != -1 && cost <= K) {
            cout << g << endl;
            return 0;
        }
    }

    

    
}



Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

//#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

#define NMAX 500010

struct QUARR{
    int l;
    int r;
    int index;
    int type;
    int ans;
    bool operator<(QUARR q) const{
        if(type==1){
            if(q.r==r) return q.l>l;
            return q.r>r;
        }
        else{
            return q.index>index;
        }
    }
};

int ft_bit[NMAX];
void ft_add(int a,int w,int N){
    for(int x=a;x<=N;x+=x&-x){
        ft_bit[x]+=w;
    }
}

int ft_sum(int a){
    int ret=0;
    for(int x=a;x>0;x-=x&-x){
        ret+=ft_bit[x];
    }
    return ret;
}

signed main(){
    //ios::sync_with_stdio(false);
    cin.tie(nullptr);
    QUARR qu[NMAX];
    int last[NMAX];
    int c[NMAX];
    int N,Q;

    cin>>N>>Q;
    for(int i=1;i<=N;i++){
        cin>>c[i];
        last[i]=-1;
    }

    for(int i=1;i<=Q;i++){
        int l,r;
        cin>>l>>r;
        qu[i].l=l;
        qu[i].r=r;
        qu[i].index=i;
        qu[i].type=1;
        qu[i].ans=0;
    }

    sort(qu+1,qu+Q+1);

    for(int i=1;i<=qu[1].r;i++){
        if(last[c[i]]==-1){
            ft_add(i,1,N);
            last[c[i]]=i;
        }
        else{
            ft_add(last[c[i]],-1,N);
            ft_add(i,1,N);
            last[c[i]]=i;
        }
    }

    qu[1].ans=ft_sum(qu[1].r)-ft_sum(qu[1].l-1);
    qu[1].type=2;
    for(int i=2;i<=Q;i++){
        for(int j=qu[i-1].r+1;j<=qu[i].r;j++){
            if(last[c[j]]==-1){
                ft_add(j,1,N);
                last[c[j]]=j;
            }
            else{
                ft_add(last[c[j]],-1,N);
                ft_add(j,1,N);
                last[c[j]]=j;
            }
        }
        qu[i].ans=ft_sum(qu[i].r)-ft_sum(qu[i].l-1);
        qu[i].type=2;
    }

    sort(qu+1,qu+Q+1);

    for(int i=1;i<=Q;i++){
        cout<<qu[i].ans<<"\n";
    }
}


Measured memory_bytes: 19364
#include <iostream>
#include <algorithm>
 
using namespace std;
using ll = long long;
 
ll vmax = 5e7;
 
int main() {
  ll n;
  cin >> n;
 
  if (n % 2 == 0) {
    cout << -1 << endl;
    return EXIT_SUCCESS;
  }
 
 
  ll cnt = 1;
  ll value = 7;
  for (cnt = 0; cnt < vmax; ++cnt) {
    value = value % n;
    if (value == 0)
      break;
    value = value * 10 + 7;
  }
  if (vmax <= cnt)
    cout << -1 << endl;
  else
    cout << cnt + 1 << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int N;
vector<int> G[100000];
int color[100000];

void dfs(int s, int c){
	stack<int> S;
	S.push(s);
	color[s] = c;
	while(!S.empty()){
		int u = S.top();
		S.pop();
		rep(i, G[u].size()){
			int p = G[u][i];
			if(color[p] == 0){
				color[p] = c;
				S.push(p);
			}
		}
	}
}

void colorAssign(){
	rep(i, N){
		color[i] = 0;
	}
	int id = 1;
	rep(i, N){
		if(color[i] == 0){
			dfs(i, id);
			id++;
		}
	}

}

int main(){
	int m, s, t;
	cin >> N >> m;
	rep(i, m){
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	colorAssign();
	int q;
	cin >> q;
	rep(i, q){
		cin >> s >> t;
		if(color[s] == color[t]) cout << "yes" << endl;
		else cout << "no" << endl;
	}
}



Measured memory_bytes: 8984
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 1e6+1;

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(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;

  if(n < 0){// n < 0 にも対応
    n *= -1;
    x = inv[x];
  }

  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n /= 2;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }

  return ret;
}

int main(){
  COMinit();
  int n; cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  vi lcm(1e6+1,0);
  ll LCM = 1;
  rep(i,n) {
    int num = a[i];
    for(int j = 2; j*j <= a[i]+1; j++) {
      int cnt = 0;
      while(num%j == 0){
        num /= j;
        cnt++;
      }
      chmax(lcm[j],cnt);
    }
    if(num != 1){
      chmax(lcm[num],1);
    }
  }
  for(int i = 2; i < 1e6+1; i++) {
    LCM *= POW(i, lcm[i]);
    LCM %= MOD;
  }

  ll ans = 0;

  rep(i,n) {
    ll tmp = LCM;
    int num = a[i];
    for(int j = 2; j*j <= a[i]+1; j++) {
      int cnt = 0;
      while(num%j == 0){
        num /= j;
        cnt++;
      }
      tmp *= POW(j, -cnt);
      tmp %= MOD;
    }
    if(num != 1){
      tmp *= POW(num, -1);
      tmp %= MOD;
    }
    ans += tmp;
    ans %= MOD;
  }

  cout << ans << endl;
}


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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  if (x == w / 2 and y == h / 2) {
    cout << w * h / 2 << ' ' << 1 << endl;
    //   } else if (x == w / 2 or y == w / 2 or x == w or y == h or x == 0 or y
    //   == 0) {
    //     cout << w * h / 2 << ' ' << 0 << endl;
  } else {
    cout << w * h / 2 << ' ' << 0 << endl;
  }
}

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

  solve();
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);

  for (int i = 0; i < N; i++){
    cin >> d.at(i);
  }

  sort(d.begin(), d.end());

  int count = N;

  for (int i = 0; i < N-1; i++){
    if (d.at(i) == d.at(i+1)){
      count--;
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static class SegmentTree {
		int N;
		int[] b;
		
		public SegmentTree(int n) {
			N = 1;
			while(N<n)
				N*=2;
			
			b = new int[N*2];
		}
		
		public int rangeSum(int l, int r) {
			return rangeSum(1, 0, N, l, r);
		}
		
		public int rangeSum(int index, int l, int r, int x, int y) {
			if(y<=l || r<=x) {
				return 0;
			} else if(x<=l && r<=y) {
				return b[index];
			} else {
				int mid = (l+r)/2;
				int g1=0,g2=0;
				if(x<mid)
					g1 = rangeSum(index*2, l, mid, x, Math.min(y, mid));
				if(mid<y)
					g2 = rangeSum(index*2+1, mid, r, Math.max(x, mid), y);
				return g1+g2;
			}
		}
		
		public void add(int index, int value) {
			b[index+N]+=value;
			int i = (index+N)/2;
			while(i>0) {
				b[i] = b[i*2]+b[i*2+1];
				i/=2;
			}
		}
	}


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] a = new int[N];
		for(int i=0; i<N; i++)
			a[i] = sc.nextInt()-K;
		
		long[] s = new long[N+1];
		HashSet<Long> hash = new HashSet<>();
		hash.add(0l);
		for(int i=0; i<N; i++) {
			s[i+1] = s[i] + a[i];
			hash.add(s[i+1]);
		}
		
		Long[] index = hash.toArray(new Long[0]);
		Arrays.sort(index);
		
		long ans = 0;
		SegmentTree st = new SegmentTree(index.length);
		st.add(Arrays.binarySearch(index, 0l), 1);
		for(int i=0; i<N; i++) {
			int j = Arrays.binarySearch(index, s[i+1]);
			ans += st.rangeSum(0, j+1);
			st.add(j, 1);
		}
		
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 97884
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string s;
    while(n){
    	s.push_back('a' + ((n-1)%26));
    	n--;
    	n /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s << '\n';
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long uLL;
typedef long double ldb;
typedef pair<int,int> pii;

int A[200001];

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, k;
    cin>>n>>k;
    for(int i = 0; i < n; ++i)
    {
        int inp;
        cin>>inp;
        ++A[inp];
    }
    sort(A, A+n+1);
    int ans = 0;
    for(int i = 0; i <= n-k; ++i)
        ans += A[i];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

struct UnionFind{
    vector<int> data;
    UnionFind(int size){
        data=vector<int>(size,-1);
    }
    bool union_set(int x,int y){
        x=root(x);
        y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];
            data[y]=x;
        }
        return x!=y;
    }
    bool find(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    string S=get_str();
    string token="";
    for(int i=S.size()-1;i>=0;--i){
        token=S[i]+token;
        if(token=="dream"||token=="dreamer"||token=="erase"||token=="eraser"){
            token="";
        }
    }
    print(token==""?"YES":"NO");
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
    string S, T;
    cin >> S >> T;
 
    cout << T << S << endl;
    return 0;
}

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

int main(){
  string s;
  char c = 'a';
  cin >> s;
  for(;c<='z';c++){
    auto itr = find(s.begin(),s.end(),c);
    if(itr==s.end()){
      cout << c << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}


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

s = list(input())
ans = []

for j in range(len(s)):
    # print("j=%d word=%s length=%d ans=%s" % (j, s[j], len(ans), "".join(ans)))
    if (s[j]) == "B":
        l = len(ans)
        if l == 0:
            continue
        else:
            del ans[-1]
    else:
        ans.append(s[j])

print("".join(ans))

Measured memory_bytes: 3060
var x = require('fs').readFileSync('/dev/stdin', 'utf8');

var array = (x.split(" ")).map(Number);

var W = array[0];
var H = array[1];
var x = array[2];
var y = array[3];
var r = array[4];

if (0 < x && x <= W - r && 0 < y && y <= H - r ) {
    console.log("Yes");
}

else {
    console.log("No");
}


Measured memory_bytes: 15112
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	a, b, c := nextInt(), nextInt(), nextInt()

	if a%2 == 1 && b%2 == 1 && c%2 == 1 {
		if a < c && b < c {
			fmt.Println(a * b)
		} else if a < b && c < b {
			fmt.Println(c * a)
		} else {
			fmt.Println(b * c)
		}
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(void){
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int x[N], y[M];
  int war_flag = 0; //1で起こる．0で起こらない．
  int i;
  for(i=0; i<N; i++)
    cin >> x[i];
  for(i=0; i<M; i++)
    cin >> y[i];

  int Z;
  for(Z=X+1; Z<=Y; Z++){
    //cout << "Z=" << Z << endl;
   
    for(i=0; i<N; i++){
      if(x[i]>=Z){
	war_flag = 1;
	break;
      }
      else
	war_flag = 0;
    }

    if(war_flag == 0){
      //cout << "  flag = 0" << endl;
      for(i=0; i<M; i++){
	if(y[i]<Z){
	  //cout << y[i] << "<" << Z << endl;
	  war_flag = 1;
	  break;
	}
	else
	  war_flag = 0;
      }
    }
    if(war_flag == 0)
      break;
  }
  
  if(war_flag == 0)
    cout << "No War" << endl;
  else
    cout << "War" << endl;
  
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)


def dfs(idx):
    for x in arr[idx]:
        if not vis[x]:
            vis[x] = True
            dfs(x)


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

arr = [[] * (n + 1) for _ in range(n + 1)]
vis = [False] * (n + 1)

for _ in range(m):
    a, b = map(int, sys.stdin.readline().split())
    arr[a].append(b)
    arr[b].append(a)

ans = 0

if m == 0:
    print(n-1)
    sys.exit()

dfs(1)
for i in range(2, n + 1):
    if not vis[i]:
        vis[i] = True
        dfs(i)
        ans += 1

print(ans)


Measured memory_bytes: 841584
#include <stdio.h>
#include <string.h>
int main()
{
    char s1[10], s2[10], s3[10], S1, S2, S3;
    scanf("%s %s %s", s1, s2, s3);
    if(s1[0]>='a' && s1[0]<='z')
    {
        S1 = s1[0]-32;
    }
    else
    {
        S1 = s1[0];
    }
    if(s2[0]>='a' && s2[0]<='z')
    {
        S2 = s2[0]-32;
    }
    else
    {
        S2 = s2[0];
    }
    if(s3[0]>='a' && s3[0]<='z')
    {
        S3 = s3[0]-32;
    }
    else
    {
        S3 = s3[0];
    }

    printf("%c%c%c\n", S1, S2, S3);

    return 0;
}



Measured memory_bytes: 128
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int len = S.length();
    long ans = 0;
    for(int i = 0; i < len; i++) {
      long d = Long.parseLong(String.valueOf(S.charAt(i)));
      for(int j = 0; j <= len - i - 1; j++) {
        if(j < len - i - 1) ans += (d * (long)Math.pow(10, j)) * (long)Math.pow(2, i) * (long)Math.pow(2, len - i - 2 - j);
        if(j == len - i - 1) ans += (d * (long)Math.pow(10, j)) * (long)Math.pow(2, i);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22228
/* 
	BURN OUT IS BETTER THAN FADE AWAY 
*/	  
	#include <bits/stdc++.h>
	using namespace std;
		     
	#define ll long long int
	#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
		     
	#define mp make_pair
	#define pb push_back
	#define ld long double
	#define F first
	#define S second
	const ll N =(1e6);  
	const ll mod = (1e9+7);
	
	int main(){
	fast;
	ll n ;
	cin>> n ;
	vector<string> v;

	 for(ll i = 0 ;i < n ; i ++){
	 	string s;
	 	cin >> s;
	 	sort(s.begin() , s.end());
	 	v.pb(s);
	 }
	
	sort(v.begin() , v.end());
	map<string , ll>m;

	for(ll i = 0; i <v.size() ;i++)
		m[v[i]]++;

	ll ans  = 0;
		//map<string , ll> :: iterator it;
	for(auto it : m)
	{
		ll x = it.S;
		ans+=((x-1)*x)/2;
	}
	cout<<ans;
}


Measured memory_bytes: 12020
def get_vacation(vacation_data):
    A, B, C = range(3)
    dp = [[-1 for i in range(3)] for j in range(len(vacation_data))]
    dp[0] = vacation_data[0]
    for i in range(1, len(vacation_data)):
        a, b, c = vacation_data[i]
        dp[i][A] = max(dp[i - 1][B], dp[i - 1][C]) + a
        dp[i][B] = max(dp[i - 1][A], dp[i - 1][C]) + b
        dp[i][C] = max(dp[i - 1][A], dp[i - 1][B]) + c
    return max(dp[-1])


def get_input():
    n = int(input())
    data = []
    for i in range(n):
        el = list(map(int, input().split()))
        data.append(el)
    return data
 
data = get_input()
print(get_vacation(data))

Measured memory_bytes: 76248
#include<bits/stdc++.h>
using namespace std;
struct point{
	string s;
	int t;
}a;
int n,t;
int main(){
//	freopen("a.txt","r",stdin);
	cin>>n>>t;
	queue<point> q;
	for(int i=0;i<n;i++){
		cin>>a.s>>a.t;
		q.push(a);
	}
	int k=0;
	while(!q.empty()){
		a=q.front();q.pop();
		if(a.t<=t){
			k+=a.t;
			cout<<a.s<<' '<<k<<"\n";
		}else{
			k+=t;
			a.t-=t;
			q.push(a);
		}
	}
	return 0;
}



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


int main(){
    
    int A, B;
    cin >> A >> B;
    
    rep(i,1001) {
        int za = i * 8 / 100;
        int zb = i * 10 / 100;

        if(za == A && zb == B) {
            cout << i << endl;
            exit(0);
        }
    }
    cout << -1 << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vr vector
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define loop(i,n) for(i=0;i<n;i++)
ll power(ll x,ll y,ll md)
{
    ll res = 1;     // Initialize result

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = ((res%md)*(x%md))%md;

        // y must be even now
        y = y>>1; // y = y/2
        x = ((x%md)*(x%md))%md;  // Change x to x^2
    }
    return res%md;
}

  /*vr <ll> v;
  ll arr[200009];
 ll maxn=200007;
  void sieve()
 {
     arr[0]=0,arr[1]=0;
     for(ll i=2;i<=maxn;i++)
        arr[i]=1;
   for(ll i=2;i*i<=maxn;i++)
   {
       if(arr[i]==1)
       {
           for(ll j=i*i;j<=maxn;j+=i)
              arr[j]=0;
       }
   }
   for(ll i=1;i<=maxn;i++)
   {
       if(arr[i]==1)
        v.pb(i);
   }
 }*/
/*bool sortinrev(const pair<ll,ll> &a,
               const pair<ll,ll> &b)
{
       return (a.first > b.first);
}*/

int main()
{
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     //ll t; scanf("%lld",&t);
     //sieve();
     //while(t--)
     {
       ll n,i;
       cin>>n;
       string s;
       map <string,ll> mp;

       loop(i,n)
       {cin>>s;mp[s]++;}

       cout<<"AC x "<<mp["AC"]<<endl;
       cout<<"WA x "<<mp["WA"]<<endl;
       cout<<"TLE x "<<mp["TLE"]<<endl;
       cout<<"RE x "<<mp["RE"]<<endl;

     }


    return 0;

}


Measured memory_bytes: 3684
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    int x=0;
    
    for (int i=0;i<N;i++){
      if(sc.nextInt() >= K){
        x++;
      }
    }
    
    System.out.println(x);
  }
}
  

Measured memory_bytes: 47580
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
a,b,c = LI()
print(min(b//a,c))
"""

#B

a,b,k = LI()
i = 1
ans = [1]
while i <= min(a,b):
    i += 1
    if a%i == 0 and b%i == 0:
        ans.append(i)
print(ans[-k])
#C
"""
s = S()
n = len(s)
while len(s)>1:
    i = 0
    f = True
    while s[i] == s[i+1]:
        if i+1 == len(s)-1:
            f = False
            break
        i += 1
    if not f:break
    s.pop(i)
    s.pop(i)
print(n-len(s))
"""

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


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

int main()
{
  int n, k;
  cin >> n >> k;
  int m = n*(n-1)/2-k;
  int i;
  if(m >= n-1 && m <= n*(n-1)/2)
  {
    cout << m << endl;
    for(i = 0; i < n-1; i++)
    {
      cout << 1 << ' ' << i+2 << endl;
    }
    int count = m-(n-1);
    int space = 1;
    i = 2;
    while(count > 0)
    {
      if(i+space <= n)
      {
        cout << i << ' ' << i+space << endl;
        i++;
        count--;
      }
      else
      {
        i = 2;
        space++;
      }
    }
  }
  else
  {
    cout << "-1" << endl;
  }
}


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

int main(){
  int n;
  cin>>n;
  int a=0,l,r;
  for(int i=0;i<n;++i){
    cin>>l>>r;
    a+=r-l+1;
  }
  cout<<a<<endl;
  return 0;
}

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

queue<int> q[1000];
int n, a, i, j;
int d[1000];
int c=0, t=0, now, l;
bool f;

int main() {
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        for(j=0; j<n-1; j++) {
            scanf("%d", &a);
            q[i].push(a-1);
        }
        d[i]=-1;
    }
    l=n*(n-1)/2;

    while(true) {
        f = false;
        for(i=0; i<n-1; i++) {
            if(!q[i].empty()) {
                now = q[i].front();
                if(!q[now].empty() && q[now].front()==i) {
                    if(d[i]==c || d[now]==c) continue;
                    q[i].pop(), q[now].pop();
                    d[i]=c, d[now]=c;
                    f = true;
                    t++;
                }
            }
        }
        c++;
        if(!f) {
            cout << "-1" << endl;
            return 0;
        }
        if(t==l) {
            cout << c << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 6796
// 2017/07/03 Tazoe

#include <iostream>
using namespace std;

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

	if(H > -R){
		cout << 1 << endl;
	}
	else if(H == -R){
		cout << 0 << endl;
	}
	else{
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define sorted(a) sort(a.begin(), a.end());
typedef long long unsigned int ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int N;
  string S;
  cin >> N;
  cin >> S;

  map<char, int> cnt{};
  for (int i = 0; i < N; i++) {
    cnt[S[i]] += 1;
  }

  long ans = 1;
  for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
    ans *= itr->second + 1;
    ans %= 1000000007;
  }

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


Measured memory_bytes: 512
/**
 *      purpose : ABC 114 B
 *      author  : kyomukyomupurin
 *      created : 2018-12-02 21:01:30
**/

#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second
#define print(x) cout << (x) << '\n'

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(__null);
    
    string s; cin >> s;

    int m = 10000;

    for (int i = 0; i < (int) s.size() - 2; ++i) {
        int temp = (int) stoi(s.substr(i, 3));
        int tt = abs(temp - 753);
        m = min(m, tt);
    }
    print(m);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = sc.nextInt();
        if (n >= 10) {
            System.out.println(r);
        } else {
            r += 100 * (10 - n);
            System.out.println(r);
        }
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int x, y; cin >> x >> y;
  int retval = abs(abs(x)-abs(y));
  if ((x>0&&y<0) || (x<0&&y>0)) retval++;
  else if ((x==0 || y==0) && y<x) retval++;
  else if (y<x) retval+=2;

  cout << retval << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 3524
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

vector <int> g[MAXN];


struct Query {
	int v, d, c;
} Q[MAXN];

int ans[MAXN][12];
const int K = 11;

void dfs(int v, int d, int c) {
	ans[v][d] = c;
	if (d == 0) return;
	for (int i : g[v]) {
		if (!ans[i][d - 1]) {
			dfs(i, d - 1, c);
		}
	}	
}

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt(), m = readInt();
    for (int i = 1; i <= m; i++) {
    	int u = readInt(), v = readInt();
    	g[u].pb(v);
    	g[v].pb(u);
    }
    int q = readInt();
    for (int i = 1; i <= q; i++) {
		Q[i].v = readInt();
		Q[i].d = readInt();
		Q[i].c = readInt();    	
    }
//    for (int i = 1; i <= n; i++)
//        for (int j = 0; j < K; j++)
//            a[i][j] = -1;
	for (int i = q; i >= 1; i--) {
		if (!ans[Q[i].v][Q[i].d]) {
			dfs(Q[i].v, Q[i].d, i);
		} 
	}
	for (int i = 1; i <= n; i++) {
		int kek = 0;
		for (int k = 0; k < K; k++) {
			kek = max(kek, ans[i][k]);
		}
		cout << Q[kek].c << endl;
	}
    return 0;
}

Measured memory_bytes: 39032
#include<iostream>
#include<string>
#include<algorithm>
#include<map>

#define REP(i, N) for(int i = 0; i < N; ++i)
#define FOR(i, M, N) for(int i = M; i < N; ++i)

using namespace std;

int main() {
	map<int, int> road;
	int a[3];
	int b[3];
	REP(i, 3) {
		cin >> a[i] >> b[i];
		if (road[a[i]] == 0)road[a[i]] = 1;
		else ++road[a[i]];
		if (road[b[i]] == 0)road[b[i]] = 1;
		else ++road[b[i]];
	}
	string output = "YES";
	REP(i, 4) {
		if (road[i + 1] == 0 || road[i + 1] == 3) output = "NO";
	}

	cout << output << endl;


	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <iostream>
using namespace std;
 
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { 
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
 
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int total = 0;
  for (int i = 1; i <= N; ++i) {
    int sum = findSumOfDigits(i); 
    if (sum >= A && sum <= B) { 
      total += i;
    }
  }
  cout << total << endl;
}

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

int main(void){
    double l = 0, ans = 0; 

    scanf("%lf", &l);
//    printf("%lf", l);

    ans = (l / 3) * (l / 3) * (l / 3);

    printf("%lf\n", ans);

    return 0;

} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
using namespace std;
typedef long long ll;
int main()
{
  int a, b;
  cin >> a >> b;

  int c = 0;
  while((a - 1) * (c - 1) + a < b) c++;

  cout << c << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    int n , m;
    cin>>n>>m;
    int a[n] , sum =0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum += a[i];
    }
    int tmp = ceil((float)sum / (4 * m));
    int cnt = 0;
    for(int i=0;i<n;i++)
    {
        if(a[i] >= tmp)
            cnt++;
    }
    if(cnt >= m)
        cout<<"Yes";
    else
        cout<<"No";
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <cinttypes>

#define fi first
#define se second

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const int INF = 1e9;
const double EPS = 1e-9;

typedef pair<int, int> P;
inline P operator+(const P& p1, const P& p2) {
  return P(p1.first + p2.first, p1.second + p2.second);
}

int main(){
  int K;
  cin >> K;
  
  const int K_MAX = 100001;
  static int dist[K_MAX];
  fill(dist, dist + K_MAX, INF);

  deque<P> q;
  q.push_front(P(1, 0));
  while (!q.empty()) {
    P p = q.front();
    q.pop_front();
    if (dist[p.first] <= p.second) {
      continue;
    }
    dist[p.first] = p.second;
    // + 1
    q.push_back(P((p.first + 1) % K, p.second + 1));
    // * 10
    q.push_front(P((p.first * 10) % K, p.second));
  }

  cout << (dist[0] + 1) << endl;

  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()

using namespace std;

int main()
{
    ll t,n,m,i,j,k,x,y,u,v,l,r,ta,tb,count1=0,count2=0;
    ll N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    string s;
    cin >> s;
    ll E_cont=0,T_cont=0;

    for(i=min(A,B);i<max(C,D)-1;i++)
    {
        if(s[i] == '#' && s[i+1] == '#')
        {
            T_cont = 1;
            break;
        }
    }
    for(i=max(A,B)-2;i<min(C,D)-1;i++)
    {
        if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.')
        {
            E_cont = 1;
            break;
        }
    }
    if(max(A,B)>min(C,D))
        E_cont = 1;

    ll flag=1;
    if(T_cont==1)
    {
        flag=0;
    }
    else
    {
        if((A < B && C < D) || ( A>B && C > D))
        {

        }
        else
        {
            if(E_cont==0)
            {
                flag=0;
            }
        }

    }
    if(flag==0)
        cout << "No";
    else
        cout << "Yes";


    return 0;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    int a[n];
    pair<int, int> xy[n][n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        for (int j = 0; j < a[i]; j++) {
            int x, y;
            cin >> x >> y;
            xy[i][j] = pair<int, int>(x - 1, y);
        }
    }
    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        int cnt = 0;
        bool flag = true;
        for (int i = 0; i < n; i++) {
            if (!(bit & (1 << i))) continue;
            for (int j = 0; j < a[i]; j++) {
                if (bit & (1 << xy[i][j].first)) {
                    if (xy[i][j].second == 0) flag = false;
                } else {
                    if (xy[i][j].second == 1) flag = false;
                }
                if (!flag) break;
            }
            if (!flag) break;
        }
        if (flag) cnt = __builtin_popcount(bit);
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
using vi=vector<int>;
using pi=pair<int,int>;
using vpi=vector<pi>;
using ll=long long int;
int main() {
  int N,M;
  cin>>N>>M;
  vpi AB=vpi(N);
  REP(i,N){
    int A,B;
    cin>>A>>B;
    AB[i]={A,B};
  }
  sort(AB.begin(),AB.end());
  ll ans=0;
  REP(i,N){
    ll price=AB[i].first;
    ll cnt=AB[i].second;
    if(M<=cnt){
      ans+=price*M;
      break;
    }
    ans+=price*cnt;
    M-=cnt;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
   int s=0,ans=0;
   for(int i=0;i<5;++i){
      cin>>s;
      if(s==0)
      ans=i+1;
   }
   cout<<ans;
}

Measured memory_bytes: 3584
# include "cstdio"
# include "iostream"
# include "algorithm"
# define LC (x<<1)
# define RC (x<<1|1)

using namespace std;

const int maxm=2e5+10;
const int Inf=0x3f3f3f3f;

int N,Q,B[maxm],Delta[maxm];

struct Segment_Tree{
    int Left;
    int Right;
    int Lazy;
    int Max;
    # define Left(x) Tree[x][Kind].Left
    # define Right(x) Tree[x][Kind].Right
	# define Max(x) Tree[x][Kind].Max
}Tree[maxm<<2][2];

struct segment{
	int Left;
	int Right;
	# define L(x) Segment[x].Left
	# define R(x) Segment[x].Right
}Segment[maxm];

inline void Update(int x,int Kind){
	Max(x)=max(Max(LC),Max(RC));
	return;
}

void Build(int x,int l,int r,int Kind){
    Left(x)=l,Right(x)=r;
    if(l==r){
    	if(l!=0) Max(x)=-Inf;
		return;
	}
	int Mid=(l+r)>>1;
	Build(LC,l,Mid,Kind);
	Build(RC,Mid+1,r,Kind);
    Update(x,Kind);
	return;
}

void Change(int x,int y,int Val,int Kind){
	if(Left(x)==Right(x)){
        Max(x)=Val;
        return;
	}
	int Mid=(Left(x)+Right(x))>>1;
	if(y<=Mid) Change(LC,y,Val,Kind);
	else Change(RC,y,Val,Kind);
	Update(x,Kind);
	return;
}

int Ask(int x,int l,int r,int Kind){
	if(l<=Left(x) && r>=Right(x)){
		return Max(x);
	}
	int Mid=(Left(x)+Right(x))>>1;
	int Result=-Inf;
	if(l<=Mid) Result=Ask(LC,l,r,Kind);
	if(r>Mid) Result=max(Result,Ask(RC,l,r,Kind));
	return Result;
}

inline bool Comp(segment a,segment b){return a.Left==b.Left?a.Right<b.Right:a.Left<b.Left;}

int main(){
	register int i,Ans=0,Add=0,Result=0;
	scanf("%d",&N);
	for(i=1;i<=N;i++){
		scanf("%d",B+i);
		Delta[i]=Delta[i-1]+(B[i]==1?1:-1);
		Ans+=(B[i]==0);
	}
	Build(1,0,N,0);
	Build(1,0,N,1);
	scanf("%d",&Q);
	for(i=1;i<=Q;i++) scanf("%d%d",&L(i),&R(i));
	sort(Segment+1,Segment+1+Q,Comp);
	for(i=1;i<=Q;i++){
		Add=Delta[R(i)]-Delta[L(i)-1]+Ask(1,0,L(i)-1,0);
		Add=max(Add,Delta[R(i)]+Ask(1,L(i),R(i),1));
		Change(1,R(i),Add,0);
		Change(1,R(i),Add-Delta[R(i)],1);
		Result=max(Result,Add);
  	}
	cout<<N-(Ans+Result);
	return 0;
}

Measured memory_bytes: 22272
# C - Rally
def main():
    N, *X = map(int, open(0).read().split())
    calc = lambda x, p: (x - p) ** 2
    P = sum(X) // N
    ans = min(sum(calc(x, p) for x in X) for p in range(P - 2, P + 2))
    print(ans)


if __name__ == "__main__":
    main()


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

int main()
{
    char X, Y;
    cin >> X >> Y;
    if (X < Y)
    {
        cout << "<" << endl;
    }
    if (X > Y)
    {
        cout << ">" << endl;
    }
    if (X == Y)
    {
        cout << "=" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,i,j,le,ri;
char c,s[7],r[222];
int main() {
  scanf("%d",&n);
  printf("?");
  for (j=1; j<=n; j++) printf(" %d",j);
  puts("");
  fflush(stdout);
  scanf("%s",s);
  c=s[0];
  le=2; ri=n+1;
  while (le<ri) {
    i=(le+ri)/2;
    printf("?");
    for (j=0; j<n; j++) printf(" %d",i+j);
    puts("");
    fflush(stdout);
    scanf("%s",s);
    if (s[0]==c) le=i+1; else ri=i;
  }
  r[ri-1]=c;
  r[ri+n-1]='R'+'B'-c;
  for (i=1; i<=2*n; i++) if (i<ri-1 || i>=ri+n) {
    printf("? %d",i);
    for (j=0; j<n-1; j++) printf(" %d",ri+j);
    puts("");
    fflush(stdout);
    scanf("%s",s);
    r[i]=s[0];
  } else if (i>=ri && i<ri+n-1) {
    printf("? %d",i);
    for (j=1; j<=2*n; j++) if (j<ri-1 || j>=ri+n) printf(" %d",j);
    puts("");
    fflush(stdout);
    scanf("%s",s);
    r[i]=s[0];
  }
  printf("! %s\n",r+1);
  fflush(stdout);
  return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int q;
	cin >> q;
	REP(k, q) {
		string X, Y;
		cin >> X >> Y;
		int x = X.size(), y = Y.size();
		vector<vector<int>> dp(x + 1, vector<int>(y + 1));
		REP(i, x) {
			REP(j, y) {
				if (X[i] != Y[j]) {
					dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
				} else {
					dp[i + 1][j + 1] = dp[i][j] + 1;
				}
			}
		}
		cout << dp[x][y] << endl;
	}

	return 0;
}


Measured memory_bytes: 6880
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main()
{
    string S;
    cin >> S;
    if (S[0] != S[1] || S[1] != S[2])
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
 
int main()
{
	int a;
    char str[4];
        
    cin >> str;
    cin >> a;
    if(str[0]==str[1]&&str[1]==str[2]){
   cout <<  "Yes" << endl;
    }else if(str[1]==str[2]&&str[2]==str[3]){
   cout <<  "Yes" << endl;
    }else{
      cout << "No" << endl;}
   
   
  
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;

    int i=1;
    ll ans;

    if(s1[0]==s2[0]){
        ans = 3;
    }else{
        ans = 6;
    }

    while(i<n){
        if(s1[i]==s2[i]){
            if(s1[i-1]==s2[i-1]){
                ans *= 2;
                ans %=MOD;
            }
        }else{
            if(s1[i-1]==s2[i-1]){
                ans *= 2;
                ans %=MOD;
            }else{
                if(s1[i]!=s1[i-1]){
                    ans *= 3;
                    ans %=MOD;
                }
            }
        }
        i++;
    }

    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int a,b,c,d; cin>>a>>b>>c>>d;
  bool ans = (abs(a-c) <= d) || (abs(a-b) <= d && abs(b-c) <= d);
  COUT(ans ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a/gcd(a,b)*b;}
// head
const int mxN = 1e5;
int n, m, in[mxN], dp[mxN];
VI adj[mxN];
int main() {
	ios::sync_with_stdio(0); 
	cin.tie(0); cout.tie(0);
		
	cin >> n >> m;
	rep(i, 0, m){
		int x, y;
		cin >> x >> y, --x, --y;
		adj[x].pb(y);
		++in[y];
	}
	queue<int> q;
	rep(i, 0, n) if(!in[i])	q.push(i);
	while(q.size()){
		int cur;
		cur = q.front();
		q.pop();
		rep(j, 0, adj[cur].size()){
			int nxt = adj[cur][j];
			--in[nxt];
			if(!in[nxt]){
				dp[nxt] = dp[cur] + 1;
				q.push(nxt);
			}
		}
		
	}
	cout << *max_element(dp, dp + n) << endl;
}




Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;int64_t N,P,p,i,r,v;string S;main(){cin>>N>>P>>S;if(10%P){map<int,int>m;m[0]=p=1;for(i=N;i--;)v=(v+(S[i]-48)*(p=(p*10)%P))%P,r+=m[v]++;}else{for(i=0;i<N;i++)if(!((S[i]-8)%P))r+=i+1;}cout<<r;}

Measured memory_bytes: 900