akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

void solve1() {
    int x,a,b;
    cin>>x>>a>>b;

    cout<<((abs(x-a) < abs(x-b)) ? "A" : "B") <<endl;

}

void solve2() {

}

void solve3() {

}

void solve4() {

}

int main() {
	solve1();
	//solve2();
	//solve3();
	//solve4();

	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

const yes = "Yes"
const no = "No"

func solve(a int64, b int64, c int64) bool {
	return a < b && b < c
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	a := nextInt()
	b := nextInt()
	c := nextInt()
	if solve(a, b, c) {
		fmt.Fprintln(out, yes)
	} else {
		fmt.Fprintln(out, no)
	}
}

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

func nextStringAsBytes(n int64) []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}



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

int main(void){
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i,m) cin >> b[i];
    int res = 0;
    rep(i,n){
        int sum = c;
        rep(j,m){
            int a;
            cin >> a;
            sum += a*b[j];
        }
        if (sum > 0) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
#define INF 1000000000
#define PI 3.14159265359

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

    int N;
    cin >> N ;
    set<string> s{};

    for (int i=0;i<N;i++){
        string x;
        cin >> x;
        s.insert(x);
    }

cout << s.size() << endl;

}

Measured memory_bytes: 19212
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"Sunny", "Cloudy", "Rainy"};

int main(){
    int A, B;
    cin >> A >> B;
    cout << max({A + B, A - B, A * B}) << endl;
}


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


int main()
{
    int n,a,b;long long int sum=0;
    scanf("%d %d %d",&n,&a,&b);
  long long  int c[n];
    for(int i=0;i<n;i++)
        scanf("%lld",&c[i]);
    for(int i=0;i<n-1;i++)
    {
        if((c[i+1]-c[i])*a>b)
        {
            sum+=b;
        }
        else
            sum+=(c[i+1]-c[i])*a;
    }
    printf("%lld",sum);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;

#define rep(i, a, b) for(ll i = a; i < ll(b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    ll n;
    cin>>n;

    vector<pii> a(n);

    ll smallestEnd = 1e18;
    ll biggestStart = 0;

    ll biggestInterval = 0;

    rep(i,0,n) {
        cin>>a[i].first>>a[i].second;
        a[i].second++;

        smallestEnd = min(smallestEnd,a[i].second);
        biggestStart = max(biggestStart,a[i].first);

        biggestInterval  = max(biggestInterval,a[i].second-a[i].first);
    }

    sort(all(a));
    //trav(in,a) cout<<"("<<in.first<<","<<in.second<<") ";
    //cout<<endl;
    
    vi szLeft(n);
    szLeft[0] = smallestEnd-a[0].first;
    rep(i,1,n) szLeft[i] = min(szLeft[i-1],smallestEnd-a[i].first);
    vi szRight(n);
    szRight[n-1] = a[n-1].second-biggestStart;
    for(ll i =n-2;i>=0;i--) szRight[i] = min(szRight[i+1],a[i].second-biggestStart);

    //trav(x,szLeft) cout<<x<<" ";
    //cout<<endl;
    //trav(x,szRight) cout<<x<<" ";
    //cout<<endl;

    ll ans = 0;
    rep(i,0,n-1){
        ans = max(ans,szLeft[i]+szRight[i+1]);
    }

    ans = max(ans,max(0ll,smallestEnd-biggestStart)+biggestInterval);
    
   /*
    vector<pii> intvsFromLeft(n);
    intvsFromLeft[0] = a[0];

    rep(i,1,n){
        intvsFromLeft[i].first = max(intvsFromLeft[i-1].first,a[i].first);
        intvsFromLeft[i].second = min(intvsFromLeft[i-1].second,a[i].second);
    }


    vector<pii> intvsFromRight(n);
    intvsFromRight[n-1] = a[n-1];

    for(ll i = n-1;i>=0;{
        intvsFromRight[i].first = max(intvsFromRight[i+1].first,a[i].first);
        intvsFromRight[i].second = min(intvsFromRight[i+1].second,a[i].second);
    }*/

    cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
    float d,t,s;
    cin>>d>>t>>s;
    float x;
    x=d/s;
    if(t>=x)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }

}


Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int a, b,c;
	cin >> a >> b;
	if (a == 1 || b == 1){
		if (a < b){ c = 1; }
		if (a == b){ c = 0; }
		if (a > b){ c = 2; }
	}
	else{
		if (a > b){ c = 1; }
		if (a == b){ c = 0; }
		if (a < b){ c = 2; }
	}
	if (c == 0){ cout << "Draw" << endl; }
	if (c == 1){ cout << "Alice" << endl; }
	if (c == 2){ cout << "Bob" << endl; }
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  REP(i, N) cin >> V[i];
  REP(i, N) cin >> C[i];
  int ans = 0;
  REP(i, N) {
    if (V[i] - C[i] > 0) ans += V[i] - C[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
void merge(int *, int, int, int);
void mergesort(int *, int, int);

int count=0;

int main()
{
  int i, n, S[1000000];

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &S[i]);
  }

  mergesort(S, 0, n);

  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i < n-1)
      printf(" ");
  }

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


void merge(int *A, int left, int mid, int right)
{
  int n1=mid - left , n2=right - mid;
  int L[n1], R[n2];
  int i, j, k;
  
  for(i=0; i<n1; i++){
    L[i]=A[left+i];
  }

  for(i=0; i<n2; i++){
    R[i]=A[mid+i];
  }
  
  L[n1]=1000000000;
  R[n2]=1000000000;

  i=0;
  j=0;

  for(k=left; k<right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i+=1;
    }
    else {
      A[k] = R[j];
      j+=1;
    }
    count++;
  }

}

void mergesort(int *A, int left, int right)
{
  int mid;
  if(left+1 < right){
    mid=(left+right)/2;
    mergesort(A, left, mid);
    mergesort(A, mid, right);
    merge(A, left, mid, right);
  }
}

Measured memory_bytes: 5580
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	while(b<=a && k){
		b*=2;
		k--;
	}
	while(c<=b && k){
		c*=2;
		k--;
	}
	if(a<b && b<c)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repe(i, n) for(int (i) = 0; i <= (n); (i)++)
#define repr(i, n) for(int (i) = (n); (i) > 0; --(i))
#define repre(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define elm1(pair) (pair).first
#define elm2(pair) (pair)).second
typedef long long ll;
typedef unsigned long long ull;
const ull MOD = 1000000007;
ull mpow(ull a, ull n);
ull inv_mod(ull a){return mpow(a, MOD-2);}

ull mpow(ull a, ull n)
{
    ull ans = 1;
    while(n>>=1){
        if(n & 1)(ans *= a)%= MOD;
        (a*=a)%=MOD;
    }
    return ans;
}

ull nCr(ull n, ull r)
{
    vector<ull> factorial(n+1);
    factorial[0]=1;
    rep(i, n)factorial[i+1] = factorial[i]*(i+1)%MOD;
    return factorial[n]*(inv_mod(factorial[n-r])%MOD*inv_mod(factorial[r])%MOD) % MOD;
}

struct Edge{
    int to, id;
};

vector<vector<Edge>> to;
vector<int> ans;

void dfs(int v, int c =-1, int p=-1)
{
    int k = 1;
    rep(i, to[v].size()){
        int u = to[v][i].to, ei = to[v][i].id;
        if(u == p)continue;
        if(k == c)++k;
        ans[ei] = k; ++k;
        dfs(u,ans[ei], v);
    }
}

int main()
{
    int N;
    cin >> N;
    int X = N / 1.08;
    while(1){
        int tmp = static_cast<int>(X * 1.08);
        if(tmp == N){
            cout << X << endl;
            break;
        }
        else if(tmp > N){
            cout << ":(" << endl;
            break;
        }
        else if(tmp < N){
            X+= 1;
            continue;
        }
    }
    return 0;
}



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

int main()
{
	int a,b,ans,ans2;
	double ans3;

	cin >> a >> b;

	ans = a/b;
	ans2 = a%b;
	ans3 = (double) a/b;

	cout << ans << " " << ans2 << " " ;
	printf("%f",ans3);

	return 0;
}

Measured memory_bytes: 1232
import sys

H, W = map(int, input().split())

if H%3 == 0 or W%3 == 0:
    print(0)
    sys.exit()

L = max(H, W)
S = min(H, W)

ans = 10**10

for i in range(L):
    a = (i+1) * S
    b = (L-i-1) * (S//2)
    c = (L-i-1) * (S//2 + S%2)
    diff = max(abs(a-b), abs(a-c), c-b)
    ans = min(ans, diff)

for i in range(S):
    a = (i+1) * L
    b = (S-i-1) * (L//2)
    c = (S-i-1) * (L//2 + L%2)
    diff = max(abs(a-b), abs(a-c), c-b)
    ans = min(ans, diff)

ans = min(ans, S)

print(ans)

Measured memory_bytes: 40432
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s =sc.next();
		char b = s.charAt(0);
		int c = 1;
		for(int i = 1;i < n;i++) {
			if(b != s.charAt(i)) {
				b = s.charAt(i);
				c++;
			}
		}
		System.out.println(c);
	}

}


Measured memory_bytes: 24532
#include <bits/stdc++.h>
using namespace std;
long long n,s[100005],s1[100005],maxn=2e3+50,ans;
map<long long,long long> dem,used;
int main() {
	scanf("%lld",&n);
	for(long long i=0;i<n;i++){
		scanf("%lld",&s[i]);
		long long x=s[i];
		s[i]=s1[i]=1;
		for(long long j=2;j<=maxn;j++){
			if(x%j==0){
				long long cnt=0;
				while(x%j==0){
					x/=j;
					cnt++;
				}
				if(cnt%3==1){
					s[i]*=j;
					s1[i]*=j*j;
				}else if(cnt%3==2){
					s[i]*=j*j;
					s1[i]*=j;
				}
			}
		}
		if(x!=1){
			long long y=sqrt(x);
			s[i]*=x;
			if(y*y==x) s1[i]*=y;
			else s1[i]*=x*x;
		}
		dem[s[i]]++;
	}
	for(long long i=0;i<n;i++){
		if(!used[s[i]]){
			used[s[i]]=used[s1[i]]=1;
			if(s[i]==1) ans++;
			else ans+=max(dem[s[i]],dem[s1[i]]);
		}
	}
	printf("%lld",ans);
	return 0;
}


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

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

const long long MOD = 1000000007;

int main(){
  int n,k,d,a;
  set<int> s;
  cin >> n >> k;
  rep(i,k){
      cin >> d;
      rep(j,d){
          cin >> a;
          s.insert(a);
      }
  }
  cout << n-s.size() <<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
  
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define prime 1000000007
#define all(v) v.begin(), v.end()
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define EPS (1e-8)
  
int oo = (1e9) + 7;
ll oo2 = 1ll * oo * oo;
  
#define W(x) cerr << "\033[33m" << #x << " = " << x << "\033[0m" << "\n";
#define forn(i, n) for (int i = 0; i < int(n); i++)
  
using namespace std;

int main() {
    int a, b;

    cin >> a >> b;

    cout << a * b << '\n';
    
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main()
{
  string s,t;
  cin>>s;
  cin>>t;
  int ls=s.size();
  int lt=t.size();
  int msf,meh=0;
  for(int i=0;i<=ls-lt;i++)
  {
      meh=0;
      for(int j=0;j<lt;j++)
      {
          if(s[i+j]!=t[j])
            meh+=1;
      }
      if(i==0)
        msf=meh;
      else
        msf=min(meh,msf);
  }
  if(s==t)
    cout<<"0";
  else
    cout<<msf;
  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int n, q;
vector<int> a[200000];
long long x[200000] = {0};
bool visited[200000];
long long p[200000] = {0};

void dfs(int t) {
  visited[t] = 1;
  for(auto v : a[t]) {
    if(visited[v] == 1) continue;
    p[v] += p[t] + x[v];
    dfs(v);
  }
}

int main() {
  rep(i, n) {
    visited[i] = false;
  }
  cin >> n >> q;
  for(int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    a[x-1].push_back(y-1);
    a[y-1].push_back(x-1);
  }
  for(int i = 0; i < q; i++) {
    int t1, t2;
    cin >> t1 >> t2;
    x[t1 - 1] += t2;
  }

  p[0] = x[0];

  dfs(0);
  for(int i = 0; i < n; i++) {
    cout << p[i];
    if(i != n - 1) cout << " ";
    else cout << endl;
  }

  return 0;
}

Measured memory_bytes: 22784
use std::collections::VecDeque;
use std::cmp;

fn main() {
    proconio::input! {
        mut k: usize,
    }
    let mut que = VecDeque::new();
    for i in 1..10 {
        que.push_back(i as i64);
    }
    while k > 0 {
        let t = que.pop_front();
        let last = t.unwrap() % 10;
        k -= 1;
        if k == 0 {
            println!("{:?}", t.unwrap());
        }
        for i in cmp::max(0, last - 1)..=cmp::min(9, last + 1) {
            que.push_back(10 * t.unwrap() + i);
        }
    }
}


Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

int main() {
    int N; cin >> N;
    vel A(N+2); A[0] = 0LL; rep1(i, N + 1) cin >> A[i]; A[N+1] = 0LL;

    ll sum = 0LL;
    rep(i,N+1) sum += abs(A[i] - A[i+1]);

    rep1(i,N+1) {
        cout << sum + abs( A[i + 1] - A[i - 1] )  - abs( A[i + 1] - A[i] ) - abs( A[i] - A[i-1] ) << endl;
    }
    return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int c[200000],d[200000];
int main(){
    int a,b;
    cin>>a>>b;
    for(int i=0;i<b;i++) cin>>c[i]>>d[i];
    sort(c,c+b);
    sort(d,d+b);
    if(d[0]-c[b-1]<0) cout<<0;
    else cout<<d[0]-c[b-1]+1;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fr(a,b,c) for(int a=b,__=c;a<__;a++)
using namespace std;
int main(){
	int n,m,can=1;
	cin>>n;
	map<int,int> mapa;
	fr(i,0,n){
		int a;
		cin>>a;
		mapa[a]++;
	}
	cin>>m;
	fr(i,0,m){
		int a;
		cin>>a;
		if(!mapa[a])can=0;
		mapa[a]--;
	}
	if(can)puts("YES");
	else puts("NO");
}

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

using PP = pair<int, int>;

int n, m;
int c;
PP p[100000];
int main() {
  cin >> n >> m;
  
  for (int i = 0; i < m; ++i) {
    cin >> p[i].first >> p[i].second;
  }
  
  sort(p, p + m);
  int mn = -1;
  for (int i = 0; i < m; ++i) {
    if (mn <= p[i].first) {
      ++c;
      mn = p[i].second;
    } else {
      mn = min(mn, p[i].second);
    }
  }
  cout << c << endl;
}


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

#define N 10001
#define E 100001
#define NIL -1

class DisjointSet {
    public:
        int parent[N];
        int rank[N];
        DisjointSet() {}
        DisjointSet(int n) {
            for (int i = 0; i < n; i++) {
                makeSet(i);
            }
        }
    
    void makeSet(int x) {
        parent[x] = x;
        rank[x] = 0;
    }

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

        return parent[x];
    }

    void unite(int x, int y) {
        link(findSet(x), findSet(y));
    }

    void link(int x, int y) {
        if (rank[x] < rank[y]) {
            parent[x] = y;
        } else if (rank[y] < rank[x]) {
            parent[y] = x;
        } else {
            parent[x] = y;
            rank[y] = rank[x] + 1;
        }
    }
};

class Edge {
    public:
        int v1, v2, w;
        Edge() {}
        Edge(int v1, int v2, int w): v1(v1), v2(v2), w(w) {}
        bool operator < (const Edge &e) const {
            return w < e.w;
        }
};

vector<Edge> edges;

int main() {
    int v, e;
    cin >> v >> e;
    DisjointSet G = DisjointSet(v);

    int v1, v2, w;
    for (int i = 0; i < e; i++) {
        cin >> v1 >> v2 >> w;
        edges.push_back(Edge(v1, v2, w));
    }

    sort(edges.begin(), edges.end());
    
    int totalW = 0;
    for (int i = 0; i < edges.size(); i++) {
        Edge edge = edges[i];
        v1 = edge.v1;
        v2 = edge.v2;
        if (G.findSet(v1) != G.findSet(v2)) {
            G.unite(v1, v2);
            totalW += edge.w;
        }
    }

    cout << totalW << endl;

    return 0;

}



Measured memory_bytes: 4580
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(res i=1;i<=9;++i) if(!(n%i)) {
		if(n/i<=9&&n/i>=1) return cout<<"Yes"<<'\n',0;
	}
	cout<<"No"<<'\n';
	cout<<flush;
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll sum(ll N) { return N*(N+1)/2; }
int main(){
    ll N,Ans=0;
    cin>>N;
    for(ll l=1,r;l<=N;l=r+1){
        r=N/(N/l);
        Ans+=sum(N/l)*(sum(r)-sum(l-1));
    }
    cout<<Ans;
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<string> rows(3);
  for (int i = 0; i < 3; i++)
    cin >> rows[i];
  string res;
  for (int i = 0; i < 3; i++)
    res += rows[i][i];
  cout << res << '\n';   
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string S;
    cin >> S;
    int l = S.size();

    reverse(ALL(S));
    map<int, int> mp;
    mp[0]++;
    vi dp(l+1, 0);
    int t = 1;
    rep(i, l) {
        dp[i+1] = (dp[i]+int(S[i]-'0')*t)%2019;
        mp[dp[i+1]]++;
        t = (t*10)%2019;
    }


    int res = 0;
    for(auto &p : mp) {
        //cout << p.fi << " " << p.se  << endl;
        res += p.se*(p.se-1)/2;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 5108
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

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

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int max=1<<n;
    //printf("%d\n",max);
    int k[10];
    int s[10][10];
    int p[10];
    REP(i,m){
        scanf("%d",&k[i]);
        REP(j,k[i])scanf("%d",&s[i][j]);
    }
    REP(i,m){
        scanf("%d",&p[i]);
    }
    int ans=0;
    
    REP(pp,max){
        std::bitset<10> a(pp);
        int judge=1;
        REP(i,m){
            int sum=0;
            REP(j,k[i]){
                sum+=a[s[i][j]-1];
            }
            sum%=2;
            if(p[i]!=sum){
                judge=0;
                break;
            }
        }
        if(judge==1)ans++;
    }
    printf("%d\n",ans);
    return 0;
    
}

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

int main() {
    int32_t n;
    cin >> n;
    int32_t a[n];
    int32_t b[n];

    for (int32_t i = 0; i < n; i++) {
        cin >> a[i];
    }
    int32_t s = a[0];
    for (int32_t i = 0; i < n; i++) {
        cin >> b[i];
        s += b[i];
    }

    int32_t m = s;
    for (int32_t i = 1; i < n; i++) {
        s += a[i] - b[i - 1];
        if (s > m) {
            m = s;
        }
    }
    cout << m << endl;

    return 0;
}


Measured memory_bytes: 256
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())

if N < 600:
    print(8)
elif N < 800:
    print(7)
elif N < 1000:
    print(6)
elif N < 1200:
    print(5)
elif N < 1400:
    print(4)
elif N < 1600:
    print(3)
elif N < 1800:
    print(2)
else:
    print(1)

Measured memory_bytes: 65312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod=1e9+7;
 
int main(){
  ll i,o,t,j,l,s,z;cin>>i>>o>>t>>j>>l>>s>>z;
  ll ans=0;
  ans+=o;
  ll A=i/2*2+j/2*2+l/2*2;
  ll B=0;
  if(i>0&&j>0&&l>0){
    --i;--j;--l;
    B=i/2*2+j/2*2+l/2*2+3;
  }
  cout<<ans+max(A,B)<<endl;
}

Measured memory_bytes: 256
while True:
	w=input()
	if w=='-':
		break
	else:
		list=[]
		for i in w:
			list.append(i)
		num=int(input())
		for i in range(num):
			s=int(input())
			for i in range(s):
				list.append(list.pop(0))
	print(''.join(list))
		


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
long long  a[300107],l[300109],r[300103],pos[300105];
long long ans=0,ans1=0;
stack <long long> st;
int n;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    //    pos[a[i]]=l[i]=r[i]=i;
    }
    //a[0]=a[n-1]=n-1;
    for(int i=1;i<=n;i++){
        while(!st.empty() && a[ st.top() ] >= a[i])
            st.pop();
        if(st.empty())
            l[i]=0;
        else
            l[i]=st.top();
        st.push(i);
    }
    while(!st.empty()){
        st.pop();
    }
    for(int i = n;i>=1;i--){
        while(!st.empty() && a[ st.top() ] >= a[i])
            st.pop();
        if(st.empty())
            r[i]=n+1;
        else
            r[i]=st.top();
        st.push(i);
    }
    for(int i=1;i<=n;i++)
        ans+=((r[i]-i)*(i-l[i])*a[i]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e7;  
using  p = pair<char,ll>;
int n,m;
int P[10]={0,0,0,0,0,0,1,1,1,2};
int Q[10]={1,1,1,2,2,3,2,2,3,3};
int R[10]={2,3,4,3,4,4,3,4,4,4};


int main(){
   cin >> n;
   ll mh[5]={0};
   for (int i = 0; i < n; i++)
   {
      string s;
      cin >> s;
      if(s[0]=='M') mh[0]++;
      else if(s[0]=='A') mh[1]++;
      else if(s[0]=='R') mh[2]++;
      else if(s[0]=='C') mh[3]++;
      else if(s[0]=='H') mh[4]++;
   }
   
   ll _max = 0;
   for (int i = 0; i < 10; i++)
   {
      _max += mh[P[i]]*mh[Q[i]]*mh[R[i]];
   }
   


   cout << _max;
}
  
  

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

int main(){
  int n;
  cin >> n;
  int flag = 0;
  vector<ull> a(n);
  rep(i,n) cin >> a.at(i);
  
  int ans=1;
  rep(i,n-1){
    if( flag == 0 ){
      if( a.at(i) < a.at(i+1) ){
        flag = 1;
      }else if( a.at(i) > a.at(i+1) ){
        flag = 2;
      }
    }else if( flag == 1 ){
      if( a.at(i) < a.at(i+1) ){
        continue;
      }else if( a.at(i) > a.at(i+1) ){
        flag = 0;
        ans++;
      }
    }else if( flag == 2 ){
      if( a.at(i) < a.at(i+1) ){
        flag = 0;
        ans++;
      }else if( a.at(i) > a.at(i+1) ){
		continue;
      }
    }
  }
  
  cout << ans << endl;
    
    
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(void){
    int N, M, Q; cin >> N >> M >> Q;
    vector<vector<int>> x(N+5, vector<int>(N+5, 0)), a(N+5, vector<int>(N+5, 0));

    vector<int> ans(Q);
    for(int i=0; i<M; i++){
        int l, r; cin >> l >> r;
        x[l][r]++;
    }

    for(int i=1; i<=N; i++){
        for(int j=i; j<=N; j++){
            if(i == j) a[i][j] = x[i][j];
            else a[i][j] = a[i][j-1] + x[i][j];
        }
    }

    for(int i=0; i<Q; i++){
        int p, q; cin >> p >> q;
        int sum = 0;
        for(int j=p; j<=q; j++) sum += a[j][q];
        ans[i] = sum;
    }

    for(auto e:ans) cout << e << endl;

}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
typedef long long ll;
using namespace std;
const int k_mod = ( int )1e9 + 7;
void chmin( int &a, int b ){
	if (a > b){
		a = b;
	}
}
int main( void ){
	int n, k;
	cin >> n >> k;
	int* steps = new int[ n ]();
	rep( i, 0, n ){
		cin >> steps[ i ];
	}
	vector <int> dp_cost( n, k_mod );
	dp_cost[ 0 ] = 0;
	dp_cost[ 1 ] = abs( steps[ 1 ] - steps[ 0 ] );
	rep( i, 2, n ){
		for(int j = 1; i - j > -1  && j <= k; j++){
			chmin( dp_cost[ i ], dp_cost[ i - j ] + abs( steps[ i ] - steps[ i - j ] ));
		}
	}
	printf( "%d\n", dp_cost[ n - 1 ] );
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
    int a, b, c, t;
    scanf("%d %d %d", &a, &b, &c);
    if(a > b){
        if(b > c){
            t = c;
            c = a;
            a = t;
        }else{
            t = a;
            a = b;
            b = c;
            c = t;
        }
    }else if(b > c){
        t = b;
        b = c;
        c = t;
    }
    printf("%d %d %d\n", a, b, c);
}


Measured memory_bytes: 2052
N, K = [int(i) for i in input().split()]

R = N - K
MOD = 10**9 + 7 

def mod_pow(a, n, mod):
  res = 1
  while  n > 0:
    if n & 1:
      res = (res * a ) % mod
    a = a * a  % mod
    n = n >> 1
  return res

class nCk_table:
  def __init__(self, MAX_N, mod=MOD):
    self.mod = mod
    self.MAX_N = MAX_N
    fact = [1]
    fact_inv = [0]*(MAX_N + 4)
    for i in range(MAX_N + 3):
      fact.append(fact[-1]*(i+1)%mod)

    fact_inv[-1] = mod_pow(fact[-1], mod-2, mod)
    for i in range(MAX_N+2,-1,-1):
        fact_inv[i] = fact_inv[i+1]*(i+1)%mod
    self.fact = fact
    self.fact_inv = fact_inv

  def __call__(self, n, k):
      return (((self.fact[n] * self.fact_inv[k]) % self.mod) * self.fact_inv[n-k]) % self.mod    

nCk = nCk_table(N + 1)

for k in range(K):
  I = k + 1
  if R < I - 1:
    print(0)
  else:
    print((nCk(R + 1, I) * nCk(K  - 1, I - 1)) % MOD)
  




Measured memory_bytes: 3444
IDENTIFICATION DIVISION.
PROGRAM-ID. 138B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP    PIC X(500).
01 N      PIC 9(3).
01 TBL.
   03 A   PIC 9(4) OCCURS 100. 
01 I      PIC 9(3).
01 P1     PIC 9(3).
01 P2     PIC 9(3).
01 WA     PIC 9(4)V9(10).
01 OUT    PIC Z(4).9(10).
01 OUT-R  REDEFINES OUT.
   03 ANS PIC Z(4).9(5).
   03 F1  PIC X(5).
*>  
PROCEDURE DIVISION.
  ACCEPT N.
*>
  ACCEPT INP.
  MOVE 1 TO P1.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    PERFORM VARYING P2 FROM P1 BY 1 UNTIL INP(P2:1) = ' '
    END-PERFORM
    MOVE INP(P1:P2 - P1) TO A(I)
    COMPUTE P1 = P2 + 1
  END-PERFORM.
*>
  MOVE 0 TO WA.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    COMPUTE WA = WA + 1 / A(I)
  END-PERFORM.
*>
  COMPUTE OUT = 1 / WA.
  PERFORM VARYING I FROM 10 BY -1 UNTIL OUT(I:1) <> '0'
    MOVE ' ' TO OUT(I:1)
  END-PERFORM.
  IF (I = 5) 
    MOVE ' ' TO OUT(I:1)
  END-IF.
*>
  DISPLAY FUNCTION TRIM(ANS).
*>
  STOP RUN.


Measured memory_bytes: 384
S = input()

NS = 'NS'
WE = 'WE'
answer = 'Yes'

if S.count('N') == 0 and S.count('S') != 0:
    answer = 'No'
elif S.count('N') != 0 and S.count('S') == 0:
    answer = 'No'

if S.count('W') == 0 and S.count('E') != 0:
    answer = 'No'
elif S.count('W') != 0 and S.count('E') == 0:
    answer = 'No'
        
print(answer)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
const int MAX_N=100000+10;
int forward(int left, int right){
  int a=(left-1)%3,b=(right-1)%3;
  return a<b?1:a>b?-1:0;
}

string str;
int main(){ _;
  while(cin>>str,str[0]!='#'){
    if(str.size()<2){
      cout<<0<<endl;
      continue;
    }
    int le=0,re=0,ll,lr,rl,rr;
    ll=rr=str[0]-'0';
    lr=rl=str[1]-'0';
    int lLastForward=forward(ll,lr),rLastForward=forward(rl,rr);
    int sz=str.size();
    for(int i=2;i<sz;i++){
      if(i%2==0){
	ll=rr=str[i]-'0';
      }else{
	lr=rl=str[i]-'0';
      }
      int lForward=forward(ll,lr);
      int rForward=forward(rl,rr);
      if(lLastForward*lForward==-1)le++;
      if(rLastForward*rForward==-1)re++;
      if(lForward!=0)lLastForward=lForward;
      if(rForward!=0)rLastForward=rForward;
    }
    cout<<min(le,re)<<endl;
  }
}

Measured memory_bytes: 1320
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;

int main()
{
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b,c,d;
    cin >> a >> b >> c>> d;
    int ta = a / d;
    if(a % d) ta++;
    int tb = c / b;
    if(c % b) tb++;
    if(tb <= ta)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

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

int n;
std::vector<int> a;
std::vector<int> b;
std::vector<int> c;
long long res = 0;
void input()
{
    std::cin>>n;
    a.resize(n);b.resize(n);c.resize(n);
    for(int i=0;i<n;i++){std::cin>>a[i];a[i]--;}
    for(int i=0;i<n;i++){std::cin>>b[i];res+=b[i];}
    for(int i=0;i<n-1;i++)std::cin>>c[i];

}

int main()
{
    input();
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]-1)res += c[a[i]];
    }
    std::cout<<res<<std::endl;
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

struct UnionFind {
    //各要素が属する集合の代表(根)を管理する
    //もし、要素xが根であればdata[x]は負の値を取り、-data[x]はxが属する集合の大きさに等しい
    vector<int> data;

    UnionFind(int sz) : data(sz, -1) {}

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        bool is_union = (x != y);
        if (is_union) {
            if (data[x] > data[y]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return is_union;
    }

    int find(int x) {
        if (data[x] < 0) { //要素xが根である
            return x;
        } else {
            data[x] = find(data[x]); //data[x]がxの属する集合の根でない場合、根になるよう更新される
            return data[x];
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return -data[find(x)];
    }
};

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

    int n, m;
    cin >> n >> m;

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

    return 0;
}

Measured memory_bytes: 3992
from collections import deque
def BFS(N,M,List):
    Edge = [[] for TN in range(N+1)]
    for TM in range(0,M):
        Edge[List[TM][0]].append(List[TM][1])
        Edge[List[TM][1]].append(List[TM][0])

    Distance = [-1]*(N+1)
    Distance[0] = 0
    Distance[1] = 0
    
    From = [0]*(N+1)
    From[1] = 1

    Deque = deque()
    Deque.append(1)
    while Deque:
        Now = Deque.popleft()
        for Con in Edge[Now]:
            if Distance[Con]==-1:
                Distance[Con] = Distance[Now]+1
                Deque.append(Con)
                From[Con] = Now

    return Distance[1:],From[1:]

import copy
N,M = (int(T) for T in input().split())
List = [[] for TM in range(0,M)]
for TM in range(0,M):
    List[TM] = [int(T) for T in input().split()]
Count = 0
for TM in range(0,M):
    ListCopy = copy.deepcopy(List)
    del ListCopy[TM]
    Distance,From = BFS(N,M-1,ListCopy)
    if -1 in Distance:
        Count += 1
print(Count)

Measured memory_bytes: 9580
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ld long double
#define zeros(x) x^(x-1)&x
#define pii pair<ll,ll>
#define cd complex<double>
#define dbg(x) cerr<<x<<endl;
#define Nmax 500005
using namespace std;

ll n, crt, mn = 1e9;
string s;

int get(int x){
    int ans = 0, nr = 0;
    for (int i=0;i<n;i++){
        nr++;
        if (s[i] == x) nr = 0;
        ans = max(ans, nr);
    }
    return ans;
}

int main()
{
    cin >> s;
    n = s.size();
    for (int i='a';i<='z';i++){
        crt = get(i);
        mn = min(mn, crt);
    }

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


Measured memory_bytes: 256
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
import itertools
# import math
# import networkx as nx
from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if n>=2:
    list1=factorization(n)

    list2=[x[1] for x in list1]

    m=max(list2)
    list3=list(itertools.accumulate([i for i in range(1,m+1)]))

    ans=0
    for i in list2:
        a=bisect_right(list3,i)
        ans+=a
    print(ans)
else:
    print(0)

Measured memory_bytes: 9588
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(input){
    var line = input.trim().split("\n");
    var i = 0;
    for(i=0;i<line.length;)
    {
        var N = parseInt(line[i++].trim());
        if( N === 0 ){
            break;
        }
        else{
            var found, len, k, res;
            var qualified = [], amount = [];
            for(var j=0;j<N;++j){
                var dataset = line[i++].trim().split(" ");
                res = parseInt(dataset[1]) * parseInt(dataset[2]);
                len = qualified.length;
                
                found = 0;
                len = qualified.length;
                for(k=0;k<len;++k){
                    if(qualified[k] == dataset[0]){
                        found = 1;
                        amount[k] = amount[k] + res;
                        break;
                    }
                }
                
                if( !found ){
                    qualified.push(dataset[0]);
                    amount.push(res);
                }
            }
            
            found = 0;
            len = qualified.length;
            for(k=0;k<len;++k){
                if( amount[k] >= 1000000 ){
                    console.log(qualified[k]);
                    found = 1;
                }
            }
            if( !found ){
                console.log("NA");
            }
        }
    }
});

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

int main() {
	ll l, r;
	cin >> l >> r;
	ll mod_l = l % 2019;
	ll div_l = l / 2019;
	ll mod_r = r % 2019;
	ll div_r = r / 2019;
	ll ans = 2018;
	if (div_r > div_l) {
		ans = 0;
	}
	else {
		for (int i=mod_l; i<mod_r; i++) {
			for (int j=i+1; j<=mod_r; j++) {
				ans = min(ans, i * j % (ll)2019);
			}
		}
	}


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


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

aclist={}
wclist={}

p=0
ac=wa=0

for i in [input() for i in range(m)]:
    x,y=i.split()
    if not aclist.get(x):
        if y=='AC':
            aclist[x] = aclist.get(x,0) +1
            ac+=1
        elif y=='WA':
            wclist[x] = wclist.get(x,0) +1
            wa+=1
    
for k,v in wclist.items():
    if not aclist.get(k):
        wa-=v

print(ac,wa)

Measured memory_bytes: 24208
n,k = [int(x) for x in input().split()]
a = [list(map(int, list(bin(int(x))[2:]))) for x in input().split()]
b = list(map(int, list(bin(k)[2:])))
m = len(b)
for i in a:
    m = max(m,len(i))
for j in range(m-len(b)):
    b.insert(0,0)
s = [n]*m
for i in a:
    k = m-len(i)
    for j in range(len(i)):
        if i[j]:
            s[k+j] -= 1

dp = [[0 for i in range(2)] for k in range(m+1)]
dp[0][1] = -float("inf")
f = [1<<(m-i-1) for i in range(m)]
for i in range(m):
    for j in range(2):
        x = 1 if j else b[i]
        for d in range(x+1):
            j_ = j | (d < b[i])
            k = dp[i][j]+f[i]*(s[i]*d+(n-s[i])*(1-d))
            if k > dp[i+1][j_]:
                dp[i+1][j_] = k
print(max(dp[m]))


Measured memory_bytes: 118872
#include <bits/stdc++.h>
using namespace std;
int main(){

int A,B,C,D ;
cin >> A >> B >> C >> D ;
if (A+B == C+D){
cout << "Balanced" <<endl;
}
else if(A+B > C+D){
cout << "Left" << endl;
}
else if(A+B < C+D){
cout <<"Right" <<endl;
}
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 1000000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
typedef int64_t ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

string S, T;

int main() {
	cin >> S >> T;
	int ans = INF;
	for (int i = 0; i <= S.size()-T.size(); i++)
	{
		int cnt = 0;
		rep(j, T.size()) {
			if (S.at(i + j) == T.at(j)) {
				cnt++;
			}
		}
		int tmp;
		tmp = T.size() - cnt;
		ans = min(ans,tmp);
	}
	cout << ans << endl;
}

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

long long N,P,tmp,zero=0,one=0;

long long pangkat(long long a, long long b){
	long long hasil=1;
	for(int i=0; i<b; i++){
		hasil=hasil*a;
	}
	return hasil;
}

int main(){
	cin>>N>>P;
	for(int i=0; i<N; i++){
		cin>>tmp;
		if(tmp%2==0){
			zero++;
		}else{
			one++;
		}
	}
	if(one>1){
		cout<<pangkat(2,N-1)<<'\n';
	}else{
		if(P==0){
			cout<<pangkat(2,N)<<'\n';
		}else{
			cout<<0<<'\n';
		}
	}
}

Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	ll ans=1;
	if(n==1){
		cout << k;
		return 0;
	}
	for(ll i=2;i*i<=k;i+=2){
		ll cnt=0;
		while(k%i==0){
			cnt++;
			k/=i;
		}
		if(cnt!=0){
		cnt=cnt/n;
		ans*=pow(i,cnt);
		}
		if(i==2){
			i--;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

long long int __gcd(long long int a, long long int b){
  if(a==0) return b;
  return __gcd(b%a,a);
}

int main(){
  long long int n,x; cin >> n >> x;
  vector<int> X;
  for(int i=0;i<n;i++){
 	long long int y; cin >> y;
    y-=x;
    X.push_back(abs(y));
  }
  long long int d=0;
  for(int i=0;i<n;i++){
    d = __gcd(d,X[i]);
  }
  cout << d << endl;
  
  return 0;
}


Measured memory_bytes: 892