akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(auto &it : (v))
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define sz(x) (int)(x).size()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

bitset<400> mustDie[405];
int xs[100005], ys[100005];

int main(){
	ios::sync_with_stdio(0);
	int N, M;
	cin >> N >> M;
	rep(i,0,M){
		int x, y;
		cin >> x >> y;
		--x;--y;
		xs[i] = x;
		ys[i] = y;
		/*auto tmp =  mustDie[x] | mustDie[y];
		if((mustDie[x]&mustDie[y]).any() || mustDie[x].test(x) || mustDie[y].test(y) || mustDie[x].test(y) || mustDie[y].test(x)){
			mustDie[x].set(x);
			mustDie[y].set(y);
			continue;
		}
		mustDie[x] = tmp;
		mustDie[x].set(y);
		mustDie[y] = tmp;
		mustDie[y].set(x);*/
	}
	int ans = 0;
	rep(i,0,N){
		rep(j,0,N){
			mustDie[j].reset();
		}
		bool failed = false;
		rep(j,0,M){
			int x = xs[j];
			int y = ys[j];
			if(x == i){
				if(mustDie[y].test(y)){
					failed = true;
				}
				mustDie[y].set(y);
				if((mustDie[y]&mustDie[x]).any())
					failed = true;
				mustDie[x] |= mustDie[y];
				continue;
			}
			if(y == i){
				if(mustDie[x].test(x)){
					failed = true;
				}
				mustDie[x].set(x);
				if((mustDie[x]&mustDie[y]).any())
					failed = true;
				mustDie[y] |= mustDie[x];
				continue;
			}
			auto tmp =  mustDie[x] | mustDie[y];
			if((mustDie[x]&mustDie[y]).any() || mustDie[x].test(x) || mustDie[y].test(y) || mustDie[x].test(y) || mustDie[y].test(x)){
				mustDie[x].set(x);
				mustDie[y].set(y);
				continue;
			}
			mustDie[x] = tmp;
			mustDie[x].set(y);
			mustDie[y] = tmp;
			mustDie[y].set(x);
		}
		if(failed || mustDie[i].test(i))
			continue;
		rep(j,i+1,N){
			if(mustDie[i].test(i))
				continue;
			if(mustDie[i].test(j))
				continue;
			if(mustDie[j].test(i))
				continue;
			if(mustDie[j].test(j))
				continue;
			if((mustDie[i]&mustDie[j]).any())
				continue;
			++ans;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define l_ength size
using ll = long long;
const int mod = 1000000007;
const ll infll = (1ll<<60);
using namespace std;

const int bound = 3210;
int n;

// dp(p, q) := 半開区間 [p, q) において X-Y の最大値
ll d[bound][bound];
ll a[bound];
bool bscht[bound][bound];

ll dp( int p, int q ){
	if( p == q ) return 0;
	if( bscht[p][q] ) return d[p][q];
	else bscht[p][q] = true;
	// first
	if( (n+q-p)%2 == 0 ){
		return d[p][q] = max( dp(p+1, q)+a[p], dp(p, q-1)+a[q-1] );
	}
	// second
	else {
		return d[p][q] = min( dp(p+1, q)-a[p], dp(p, q-1)-a[q-1] );
	}
}

int main(){
	cin >> n;
	for( int i = 0; i < n; ++i ) cin >> a[i];
	cout << dp(0, n) << endl;
	/*
	for( int p = 0; p <= n; ++p ){
		for( int q = p+1; q <= n; ++q ){
			cout << "[" << p << ", " << q << "): " << dp(p, q) << endl;
		}
	}
	*/
}

Measured memory_bytes: 86400
N,M=map(int, input().split())
A=list(map(int, input().split()))
s=sum(A)
d=s/(4*M)
count=0
i=0
while(i<N):
    if(A[i]>=d):
        count=count+1
    i=i+1

if(count>=M):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <stdio.h>
const int sheve = 1000 * 1000 * 1000 + 7;

long spower(long m, long n)
{
    while (n >= 1) {
        int p = n / 2;
        int q = 1;

        if (n & 0x01)
            q = m;

        if (p >= 1)
            return (spower((m * m) % sheve, p) * q) % sheve;
        else
            return q;

        n = p;
    }
    return 1;
}


int main(void)
{
    long m, n;

    scanf("%ld %ld", &m, &n);
    printf("%ld\n", spower(m, n));

    return 0;
}



Measured memory_bytes: 2140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
vector<vector<int>> vec(100010);
int main() {
	int h[100010];
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (int j = 0; j < m; j++) {
		int a, b;
		cin >> a >> b;
		vec[a-1].emplace_back(b-1);
		vec[b-1].emplace_back(a-1);
	}
	int co = 0;
	for (int k = 0; k < n; k++) {
		bool co1 = false;
		for (int l = 0; l < vec[k].size(); l++) {
			if (h[k] <= h[vec[k][l]]) {
				co1 = true;
			}
		}
		if (co1 == false) {
			co++;
		}
	}
	cout << co << endl;
	return 0;
}

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


struct nodeElement{
	long val;
	nodeElement *prev;
	nodeElement *next;
};


nodeElement *nilS;
nodeElement *nilE;

void insertNode(long x){
	//cout << "insertNode(" << x << ")" << endl;
	nodeElement *elem = new nodeElement;
	elem->val = x;
	elem->next = nilS->next;
	elem->next->prev = elem;
	nilS->next = elem;
	elem->prev = nilS;
}

void deleteNode(long x){
	//cout << "delete(" << x << ")" << endl;
	nodeElement *ep = nilS->next;
	nodeElement *epdelete;
	while(ep != NULL){
		if(ep->val == x){
			epdelete = ep;
			ep->next->prev = ep->prev;
			ep->prev->next = ep->next;
			delete epdelete;
			return;
		}
		ep = ep->next;
	}
}

void deleteFirst(){
	nodeElement *ep = nilS;
	//cout << "deleteFirst()" << endl;
		ep = nilS->next;
		//cout << "delete[" << ep->val << endl;
		ep->next->prev = nilS;
		nilS->next = ep->next;
		delete ep;
}

void deleteLast(){
	nodeElement *ep = nilE->prev;
	//cout << "deleteLast()" << endl;
	nilE->prev = ep->prev;
	ep->prev->next = nilE;
			
	delete ep;
}

void printList(){
	nodeElement *ep = nilS->next;
	while(ep->next != NULL){
		cout << ep->val;
		if(ep->next->next != NULL){
			cout << ' ';
		}
		ep = ep->next;
	}
	cout << endl;
}

int main(){
	long n;
	long num;
	string str;
	nilS = new nodeElement;
	nilE = new nodeElement;
	
	nilS->next = nilE;
	nilS->prev = NULL;
	nilS->val = NULL;
	nilE->next = NULL;
	nilE->prev = nilS;
	nilE->val = NULL;

	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> str;
		//cout << "[" << str << "]" << endl;

		if(str == "insert"){
			cin >> num;
			insertNode(num);
		}else if(str == "delete"){
			cin >> num;
			deleteNode(num);
		}else if(str == "deleteFirst"){
			deleteFirst();
		}else if(str == "deleteLast" ){
			deleteLast();
		}
		//printList();
	}

	printList();

	return 0;
}


Measured memory_bytes: 34428
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,i;
    cin>>n;
    ll arr[n+1]={0};
    for(i=1;i<=n;i++)
        cin>>arr[i];
    ll dp[n+1]={0};
    dp[1]=0;
    if(n>1)
        dp[2]=abs(arr[2]-arr[1]);
    for(i=3;i<=n;i++)
        dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i]),dp[i-2]+abs(arr[i-2]-arr[i]));
    cout<<dp[n]<<endl;
}


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

int INF=1000000001;

typedef struct edge{
  int to;
  int cost;
}edge;

int N,E;
vector< edge > G[100000];
long long mincost[100000];

void dijkstra(){
  typedef pair<int,int> P;
  priority_queue<P,vector<P>,greater<P> > Q;
  for(int i=0;i<N;i++){
    mincost[i]=INF;
  }
  mincost[0]=0;
  Q.push(P(0,0));
  while(!Q.empty()){
    int pos=Q.top().second;
    int pos_cost=Q.top().first;
    Q.pop();
    if( mincost[pos] < pos_cost )continue;
    
    for(int i=0;i<(int)G[pos].size();i++){
      edge e=G[pos][i];
      if(mincost[e.to]>pos_cost+e.cost){
	mincost[e.to]=pos_cost+e.cost;
	Q.push(P(mincost[e.to],e.to));
      }
    }
  }
  for(int i=0;i<N;i++){
    cout<<i<<" "<<mincost[i]<<endl;
  }
}

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    int id,k;
    cin>>id>>k;
    for(int j=0;j<k;j++){
      edge e;
      cin>>e.to>>e.cost;
      G[id].push_back(e);
    }
  }

  dijkstra();
  
  return 0;
}

Measured memory_bytes: 10148
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) *min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) *max_element(v.begin(), v.end())
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
  int ans = 0;
  string str;
  cin>>str;
  int l = str.size();

  REP(i,l-1) {
    if (str[i] != str[i+1])
      ans++;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 512
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [l,r,d] = nextIntArray()
    let ans = 0
    for(let i = l; i<=r;i++){
        if(i % d ==0) ans++
    }
    console.log(ans)
}
Main()



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

#define MOD_1000000007 (1000000007LL)
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i, n) for (long long i = 1; i < (long long)(n); i++)
#define rep0c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)

using std::vector;
using std::set;
using std::map;
typedef long long ll;

int N;
bool as[200020], bs[200020];

void solve() {
  repc1(N, i) {
    bool c = false;
    for(int j=2*i; j<=N; j+=i) {
      if(bs[j]) c = !c;
    }
    if(as[i]!=c) bs[i] = true;
  }
  int M = 0;
  rep1c(i, N) if(bs[i]) M++;
  printf("%d\n", M);
  if(M>0) {
    bool first = true;
    rep1c(i, N) if(bs[i]) {
      if(first) {
        first = false;
      } else {
        printf(" ");
      }
      printf("%d", i);
    }
    printf("\n");
  }
}

int main() {
  scanf("%d", &N);
  rep1c(i, N) {
    int a;
    scanf("%d", &a);
    if(a) as[i] = true;
  }
  solve();
  return 0;
}

Measured memory_bytes: 1408
#include<cstdio>

using namespace std;

int abs(int x){
    if (x > 0) return x;
    else return -x;
}

int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    int mn = a[0], mx = a[0];
    for(int i = 1; i < n; i++){
        if (mn > a[i]) mn = a[i];
        if (mx < a[i]) mx = a[i];
    }
    printf("%d\n", abs(mx - mn));
    
}

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

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

//--global--//

int n;
vector<pair<int, int> > vv[16];
int cnt = 0;
//----------//

void solve(vector<int> v){
    int res = 0;
    rep(i, v.size()){
        //if(i)cout << " ";
        //cout << v[i];
        if(v[i]){
            int u = i;
            rep(j, vv[u].size()){
                pair<int, int> f = vv[u][j];
                int neU = f.first;
                int neT = f.second;
                //cout << "->" << neU << ", " << neT;
                if(v[neU] != neT){
                    return;
                }
            }
            res++;
        }
    }
    //cout << endl;
    cnt = max(res, cnt);
}

void cir(vector<int> v){
    if(v.size() == n){
        solve(v);
        return;
    }
    v.push_back(0);
    cir(v);
    v.erase(v.end()-1);
    v.push_back(1);
    cir(v);
    return;
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    cin >> n;
    rep(i, n){
        int a;
        cin >> a;
        rep(j, a){
            int x, y;
            cin >> x >> y;
            x--;
            vv[i].push_back(make_pair(x, y));
        }
    }

    vector<int> v;
    cir(v);

    cout << cnt << endl;


    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long ans=0;
  string s;
  cin >> s;
  map<char, int> mp;
  for(int i=0;i<s.size();i++){
    mp[s[i]]++;
    if(mp['0']>0 and mp['1']>0){
      ans+=2;
      mp['0']--;mp['1']--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() {
	int n, l; cin >> n >> l;
	vector<string> s(n);
	rep(i, n) cin >> s[i];
	sort(all(s));
	for (auto a : s) {
		cout << a;
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b)puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>;
using namespace std;
int main() {
	int n; cin >> n;
	string s; cin >> s;
  	bool w = !(n % 2);
    for (int i = 0; i < n / 2; i++) w &= s[i] == s[i + n / 2];
  	cout << (w ? "Yes" : "No") << endl;
  	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define U [1<<17]={}
#define G(a)((c=A[a]+A[P[a]]+C[a])%k?c:0)
typedef long long L;using namespace std;
map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)
	d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}
L M(L i){return i?B[i]+M(i^i&-i):0;}
L S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;}
L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));}
main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
	for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;
               // n++)if(!n|H[P[a=n]]-n)
	for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}

Measured memory_bytes: 33380
#include <bits/stdc++.h>
using namespace std;
// int N が既に与えられているとする.

int main() {
  unsigned int N, M;
  cin >> N >> M;
  bool tenbou[N];
  for (unsigned int i = 0; i < N; i++) tenbou[i] = true;

  unsigned long long hyoukou[N];
  for (unsigned int i = 0; i < N; ++i) {
    cin >> hyoukou[i];
  }
  for (unsigned int i = 0; i < M; i++) {
    unsigned int A, B;
    cin >> A >> B;
    A -= 1;
    B -= 1;
    if (hyoukou[A] > hyoukou[B]) {
      tenbou[B] = false;
    } else if (hyoukou[A] < hyoukou[B]) {
      tenbou[A] = false;
    } else {
      tenbou[A] = false;
      tenbou[B] = false;
    }
  }
  unsigned int cnt = 0;

  for (unsigned int i = 0; i < N; ++i) {
    if (tenbou[i]) ++cnt;
  }
  cout << cnt;
}

Measured memory_bytes: 4484
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

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

    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];

    ll res = 0;
    for(int i = 0; i < n-1; ++i){
        if(a[i] >= x){
            res += a[i] - x;
            res += a[i+1];
            a[i] = x;
            a[i+1] = 0;
        }
        else{
            if(a[i] + a[i+1] > x){
                res += a[i+1] - (x-a[i]);
                a[i+1] = x - a[i];
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3920
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main(){
    char field[65];
    char a[7][26]={
        "1100000011",
        "1000000010000000100000001",
        "1111",
        "1000000110000001",
        "11000000011",
        "100000001100000001",
        "110000011"
    };
    while(cin>>field){
        for(int i=1;i<8;i++)scanf("%s",field+i*8);
        char *pnt;
        pnt=strchr(field,'1');
        for(int i=0;i<7;i++){
            if(!strncmp(pnt,a[i],strlen(a[i]))){
                char x='A'+i;
                cout<<x<<endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1168
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 * 
 * https://atcoder.jp/contests/abc097/submissions/14902578 にも参考
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			int[] q = new int[n];
			IntStream.range(0, n).forEach(i -> q[scanner.nextInt() - 1] = i);
			UnionFindTree uft = new UnionFindTree(n);
			IntStream.range(0, m).forEach(i -> uft.union(scanner.nextInt() - 1, scanner.nextInt() - 1));
			System.out.println(IntStream.range(0, n).filter(i -> uft.same(q[i], i)).count());
		}
	}

	/**
	 * Union Find Treeの実装<br/>
	 * https://atcoder.jp/contests/abc040/submissions/4708654 を参考に作成
	 */
	private static class UnionFindTree {
		int[] parent;
		int[] count;

		UnionFindTree(int size) {
			parent = new int[size];
			IntStream.range(0, size).forEach(i -> parent[i] = i);
			count = new int[size];
			Arrays.fill(count, 1);
		}

		int find(int x) {
			if (parent[x] == x) {
				return x;
			} else {
				int v = find(parent[x]);
				parent[x] = v;
				return v;
			}
		}

		/**
		 * @param x
		 * @param y
		 * @return xとyがつながっているかどうか
		 */
		boolean same(int x, int y) {
			return find(x) == find(y);
		}

		/**
		 * xとyを結合する
		 * 
		 * @param x
		 * @param y
		 */
		void union(int x, int y) {
			int rootX = find(x);
			int rootY = find(y);
			if (rootX == rootY) {
				return;
			}
			parent[rootX] = rootY;
			parent[x] = rootY;
			count[rootY] += count[rootX];
		}

		/**
		 * @param x
		 * @return xと結ぶ都市の数
		 */
		@SuppressWarnings("unused")
		public int count(int x) {
			return count[find(x)];
		}
	}
}


Measured memory_bytes: 59760
#include<iostream>

int main(){
    int a = 0;
    int b = 0;
    int c = 0;
    int k = 0;

    std::cin >> a >> b >> c >> k;

    int sum = 0;
    if(k <= a){
        std::cout << k;
    }
    else if(k <= a + b){
        std::cout << a;
    }
    else
    {
        std::cout << a * 2 - k + b;
    }
}

Measured memory_bytes: 3636
#include<stdio.h>

int NOTE[1010];


int main() {
	int N;
	int buff;
	for (int i = 1; i < 500; i++) {
		for (int j = 1; j < 45; j++) {
			buff = (j + 1)*i + j * (j + 1) / 2;
			if (buff <= 1000)NOTE[buff]++;
		}
	}

	while (1) {
		scanf("%d", &N);
		if (!N)break;
		printf("%d\n", NOTE[N]);

	}





	return 0;
}


Measured memory_bytes: 2036
class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))
        self.rank = [0] * n

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.parents[x] = y
        else:
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

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

uf = UnionFind(n)

for _ in range(m):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    uf.union(x, y)

for i in range(n):
    uf.find(i)

print(len(set(uf.parents))-1)

Measured memory_bytes: 18996
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) {
        int ai;
        cin >> ai;
        a[i] = ai;
        b[i] = ai;
    }
    sort(a.begin(), a.end());
    int ans1 = a[n / 2 - 1];
    int ans2 = a[n / 2];
    rep(i, n) {
        int num = b[i];
        if (num < ans2) cout << ans2 << endl;
        else cout << ans1 << endl;
    }
}



Measured memory_bytes: 3712
t = int(input())

def gcd(x, y):
    if x > y:
        x, y = y, x
    while x > 0:
        x, y = y%x, x
    return y

for _ in range(t):
    a,b,c,d = map(int, input().split())

    if b > a or b > d:
        print("No")
        continue
    if c >= b:
        print("Yes")
        continue

    a %= b
    g = gcd(b, d)
    if b-g+(a % g) > c:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 3064
//"BISMILLAHIR RAHMANIR RAHIM"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const long long M = 1e8 ;
int main()
{
    ll k,d,x,ans,a,b;
    cin>>x>>k>>d;
    x= fabs(x);
  //  cout<<x<<endl;
    ll p= x/d;
    if(p>=k){
        x = x- d*k;
        ans  = x;
       // cout<<"why"<<endl;
    }
    else{
        x = x-p*d;
        k = k-p;
        if(k%2==1){
            a = fabs(x+d);
            b= fabs(x-d);
           // cout<<a<<" "<<b;
            if(a<=b)
                ans= a;
            else
                ans= b;
        }
        else
            ans = fabs(x);
    }
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

struct BIT {
private:
	vector<ll> node; int n;
public:
	BIT(int n_) {
		n = n_; node.resize(n + 1, 0);
	}
	void add(int i, ll x) {
		while(i <= n) {
			node[i] += x;
			i += i & -i;
		}
	}
	ll sum(int i) {
		ll ret = 0;
		while(i > 0) {
			ret += node[i];
			i -= i & -i;
		}
		return ret;
	}
	ll sum(int a, int b) {
        return sum(b) - sum(a - 1);
    }
};

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int N; cin >> N;
  ll K; cin >> K;
  vector<ll> a(N), x(N + 1), y(N + 1);
  x[0] = 0; y[0] = 0;
  rep(i, N) {
	  cin >> a[i];
	  a[i] -= K;
	  x[i + 1] = x[i] + a[i];
	  y[i + 1] = x[i + 1];
  }
  sort(all(y));
  y.erase(unique(all(y)), y.end());
  map<ll, int> mp;
  rep(i, N + 1) mp[y[i]] = i + 1;

  rep(i, N + 1) x[i] = mp[x[i]];

  BIT b(N + 1);
  ll ans = 0;
  rep(i, N + 1) {
	  ans += b.sum(x[i]);
	  b.add(x[i], 1);
  }

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

Measured memory_bytes: 19072
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
void Swap(int *a,int *b,int *c)
{
     swap(*a,*b);
     swap (*a,*c);
}
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    Swap(&a,&b,&c);
    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  while(1){
    int a,b;
    int n,x,y,z;
    scanf("%d %d",&a,&b);
    if(a==0&&b==0)
      break;
    n=b-a;
    z=n/1000;
    n%=1000;
    y=n/500;
    n%=500;
    x=n/100;
    printf("%d %d %d\n",x,y,z);
  }

  return 0;
}

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

int main()
{
	int n;
	scanf("%d", &n);
	std::vector<long long> a(n + 1);
	for (int i{1}; i <= n; i++)
	{
		scanf("%lld", &a[i]);
		a[i] += a[i - 1];
	}
	std::sort(a.begin(), a.end());
	a.push_back((long long)1 << 60);
	long long count{}, pre{};
	for (int i{1}; i <= n + 1; i++)
	{
		if (a[i] == a[pre]) continue;
		count += (i - pre) * (i - pre - 1) / 2;
		pre = i;
	}
	printf("%lld\n", count);

	return 0;
}

Measured memory_bytes: 4736
#include<iostream>
using namespace std;
int f(int a,int b,int c){return(a+c)*4+b*9;}
int I[1000],a[1000],b[1000],c[1000];
int P,Q,R,C;
main()
{
    int n;
    while(cin>>n,n)
    {
        for(int i=0;i<n;i++)cin>>I[i]>>a[i]>>b[i]>>c[i];
        cin>>P>>Q>>R>>C;
        int cnt=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]>P)continue;
            if(b[i]>Q)continue;
            if(c[i]>R)continue;
            if(f(a[i],b[i],c[i])>C)continue;
            cnt++;
            cout<<I[i]<<endl;
        }
        if(!cnt)cout<<"NA"<<endl;
    }
}


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

int main()
{
	string word,target,EOT="END_OF_TEXT";
	int i=0,j;

cin >>target;

while(1){
	cin>>word;
	if(word == EOT) break;
	
for(j=0;j<word.size();j++)
		if(isupper(word[j])) word[j]=tolower(word[j]);

	if(word == target) i++;
	}
cout <<i <<"\n";
return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define pb(a) push_back(a)
#define mp make_pair
#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
	set<char> s;

	string buf = "";
	cin >> buf;
	REP(i, buf.size())
	{
		s.insert(buf[i]);
	}
	if (s.size() == 2)
	{
		COUT("Yes");
	}
	else
	{
		COUT("No");
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M,K,a;
    cin>>N>>M;
    map<int,bool>m;
    int sub=M;
    for(int i=0;i<N;i++){
        set<int>s={};
        cin>>K;
        for(int i=0;i<K;i++){
            cin>>a;
            s.insert(a);
        }
        for(int i=0;i<M;i++){
            if(s.find(i+1)==s.end()){
                if(m[i+1]!=true){sub--;m[i+1]=true;}
            }
        }
    }
    cout<<sub<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	for(;;){
		int n;
		cin >>n;
		if(!n){break;}
		double pin[100][2] = {0},min_x =  10000;
		int rubber[2] = {0};
		bool done[100] = {false};
		for(int i=0; i<n; i++){
			scanf("%lf,%lf",&pin[i][0],&pin[i][1]);
			if(min_x>pin[i][0]){min_x = pin[i][0];rubber[0] = i;}
		}
		rubber[1] = rubber[0];
		for(;;){
			int now,j;
			for(int i=0; i<n; i++){
				if(!done[i] && i!=rubber[1]){
					double ax = pin[i][0]-pin[rubber[1]][0];
					double ay = pin[i][1]-pin[rubber[1]][1];
					for(j=0; j<n; j++){
						if(!done[j]){
							double bx = pin[j][0]-pin[rubber[1]][0];
							double by = pin[j][1]-pin[rubber[1]][1];
							if(ax*by-ay*bx<0){break;}
						}
					}
					if(j == n){now = i;break;}
				}
			}
			done[now] = true;
			rubber[1] = now;
			if(rubber[1] == rubber[0]){break;}
		}
		int sum = 0;
		for(int i=0; i<n; i++){if(!done[i]){sum++;}}
		cout <<sum<<endl;
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

// const long long INF = 1LL << 60;

template <typename T>
struct Edge {
  int to;
  T cost;
};

// Dijkstra
template <typename T>
class Dijkstra {
 private:
  vector<vector<Edge<T>>> G;
  int num_v;

 public:
  Dijkstra(int num_v) : G(num_v), num_v(num_v) {
  }

  void add_edge(int from, int to, T cost) {
    G[from].push_back((Edge<T>){to, cost});
  }

  // start: Start point
  // result: result
  void solve(int start, vector<T>& result) {
    vector<int> tmp;
    solve(start, result, tmp);
  }

  void solve(int start, vector<T>& result, vector<int>& prev) {
    result.resize(num_v, INF);
    prev.resize(num_v, -1);

    // get<0>(T): cost
    // get<1>(T): index
    // get<2>(T): ... ( for extent)
    using Tup = tuple<T, int>;
    priority_queue<Tup, vector<Tup>, greater<Tup>> que;

    que.emplace(0, start);

    while (!que.empty()) {
      Tup p = que.top();
      que.pop();

      T t = get<0>(p);
      int v = get<1>(p);

      result[v] = t;

      // vの各辺に対しよりコストの低い経路があるかを確認
      for (auto& e : G[v]) {
        // prevを見ないときはこの条件式はなくても良い
        if (result[e.to] > result[v] + e.cost) {
          prev[e.to] = v;
          result[e.to] = result[v] + e.cost;
          que.emplace(result[v] + e.cost, e.to);
        }
      }
    }
  }

  // t: 目的地
  vector<int> get_path(const vector<int>& prev, int t) {
    vector<int> path;

    for (int v = t; v != -1; v = prev[v]) {
      path.push_back(v);
    }

    reverse(path.begin(), path.end());
    return path;
  }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, m;
  cin >> n >> m;

  Dijkstra<ll> g(n + 1);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    g.add_edge(a, b, 1);
    g.add_edge(b, a, 1);
  }

  vll result;
  vi prev;
  g.solve(1, result, prev);

  cout << "Yes" << endl;

  FOR(i, 2, n + 1) {
    cout << prev[i] << endl;
  }

  return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, pow(2LL, N)) {
        cout << i << ":";
        REP(j, N) {
            if ((i >> j) & 1)
                cout << " " << j;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3356
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        char[] array = sc.nextLine().toCharArray();
        int count = 0;
        for (int i = 0; i < array.length - 1; i++) {
            if (array[i] != array[i + 1]) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 25292
import sys
import queue
bbn=1000000007
	
#+++++

def can_finish(time, a_c_qq, a_k):
	kc=a_k
	
	#if time==12:
	#	print(*a_c_qq)
		
	for (st,a,f) in (a_c_qq):
		if st <= time:
			return True
		
		#time => f*a' を目指す。
		#a' <= time / f が必要。
		#コストは a - (time // f)
		kc -= a - (time//f)
		#if time==12:
		#	pa((st,a,f, time,(time//f),a- (time//f),kc))
		
		if kc < 0:
			return False
		
	return True
	
		
def main():
	n, k = map(int, input().split())
	al=list(map(int, input().split()))
	fl=list(map(int, input().split()))
	
	qq=queue.PriorityQueue()
	
	al.sort(reverse=True)
	fl.sort()
	qq=[(a*f,a,f) for a,f in zip(al,fl)]
	qq.sort(reverse=True)

	#while not qq.empty():
	#	a=qq.get()
	#	pa(a)
	
	ok_max,_,_=qq[0]
	if sum(al) <= k:
		return 0
	ng_min=0
	
	while ok_max - ng_min > 1:
		mid = (ok_max + ng_min)// 2
		can_do = can_finish(mid, qq, k)
		#pa((ok_max,ng_min,mid,can_do))
		if can_do:
			ok_max = mid
		else:
			ng_min = mid

	print(ok_max)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}

using namespace std;

const int maxn = 2e5 + 50;

int ans[maxn] , anslen;

namespace Splay{
	int ch[maxn][2] , s[maxn] , root , fa[maxn];
	int lzy[maxn];
	stack < int > allocate , stk;
	int key[maxn];

	void Add( int x ){
		lzy[x] ^= 1;
	}

	inline void up(int x){
		s[x] = s[ch[x][0]] + s[ch[x][1]] + 1;
    }

    void ReleaseLabel( int x ){
        if( !lzy[x] )
            return;
    	if( ch[x][0] )
    		Add( ch[x][0] );
    	if( ch[x][1] )
    		Add( ch[x][1] );
    	lzy[x] = 0;
    	swap( ch[x][0] , ch[x][1] );
    }

    void rotate( int x, int d ){
        int y = fa[x];
        ch[y][d ^ 1] = ch[x][d];
        if ( ch[x][d] ) fa[ch[x][d]] = y;  
        fa[x] = fa[y];
        if (fa[y]){
            if (y == ch[fa[y]][d])  ch[fa[y]][d] = x;
            else  ch[fa[y]][d ^ 1] = x;
        }
        ch[x][d] = y , fa[y] = x;
        up( y ) , up( x );
    }

    void Splay( int x , int target ){
        int y = x;
        while( y ^ target )
            stk.push( y ),
            y = fa[y];
        while( !stk.empty() )
            ReleaseLabel( stk.top() ),
            stk.pop();
    	while( fa[x] != target ){
    		int y = fa[x];
    		if( x == ch[y][0] ){
    			if( fa[y] != target && y == ch[fa[y]][0])
    				rotate( y , 1 );
    			rotate( x , 1 );
    		}else{
    			if( fa[y] != target && y == ch[fa[y]][1])
    				rotate( y , 0 );
    			rotate( x , 0 );
    		}
    	}
    	if( !target ) root = x;
    }

    void Insert( int & x , int val , int par = 0 ){
    	if( x == 0 ){
    		x = allocate.top(); allocate.pop();
    		ch[x][0] = ch[x][1] = 0 , s[x] = 1 , key[x] = val , lzy[x] = 0 , fa[x] = par;
    		Splay( x , 0 );
    	}else{
    		int cur = x;
    		ReleaseLabel( cur );
    		Insert( ch[x][1] , val , x );
    	}
    }

    void dfs( int u ){
    	if(!u) return;
    	ReleaseLabel( u );
    	dfs( ch[u][0] );
    	ans[anslen++] = key[u];
    	dfs( ch[u][1] );
    }

};

int n ;

int main(int argc,char *argv[]){
	n = read();
	for(int i = 1 ; i <= n ; ++ i)
		Splay::allocate.push( i );
	for(int i = 1 ; i <= n ; ++ i){
		int x = read();
		Splay::Insert( Splay::root , x );
		Splay::Add( Splay::root );
	}
	Splay::dfs( Splay::root );
	for(int i = 0 ; i < anslen ; ++ i)
		printf( "%d " , ans[i] );
	puts( "" );
	return 0;
}

Measured memory_bytes: 9756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int N;
	cin >> N;
	int A[1000];
	rep(i, N) cin >> A[i];

	ll dp[1001][4];
	rep(i, 1001) rep(j, 4) dp[i][j] = -1e18;
	dp[0][0] = 0;
	rep(i, N) {
		if (dp[i][0] != -1e18) {
			dp[i + 1][0] = max(dp[i + 1][0], dp[i][0]);
			dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + A[i]);
		}
		if (dp[i][1] != -1e18) {
			dp[i + 1][2] = max(dp[i + 1][2], dp[i][1]);
			dp[i + 1][3] = max(dp[i + 1][3], dp[i][1]);
		}
		if (dp[i][2] != -1e18) {
			dp[i + 1][1] = max(dp[i + 1][1], dp[i][2] + A[i]);
			dp[i + 1][1] = max(dp[i + 1][1], dp[i][2]);
		}
		if (dp[i][3] != -1e18) {
			dp[i + 1][3] = max(dp[i + 1][3], dp[i][3]);
		}
	}

	ll mae = *max_element(dp[N], dp[N] + 4);
	if (mae == 0) {
		int saidai = -2e9;
		int kazu = 0;
		rep(i, N) if (saidai < A[i]) {
			saidai = A[i];
			kazu = i;
		}
		co(saidai);
		co(N - 1);
		int flag = 0;
		rep(i, N) {
			if (N - 1 - i == kazu) flag = 1;
			else if (flag == 0) co(N - i);
			else co(1);
		}
	}
	else {
		co(mae);
		int maeichi = N + 1;
		int flag = -1;
		vector<int> kotae, kotae3;
		vector<pair<int, int>> kotae2;
		int kotae2kazu = 0;
		for (int i = N - 1; i >= 0; i--) {
			if (flag == 1) kotae3.pb(0);
			else if (dp[i][2] + A[i] == mae && maeichi - 1 > i) {
				if (maeichi != N + 1) {
					int kari = (maeichi - i) / 2;
					kotae2.pb(mp(i + kari, kari));
					kotae2kazu += kari;
				}
				mae -= A[i];
				maeichi = i;
				flag = 0;
			}
			else if (dp[i][0] + A[i] == mae && maeichi - 1 > i) {
				if (maeichi != N + 1) {
					int kari = (maeichi - i) / 2;
					kotae2.pb(mp(i + kari, kari));
					kotae2kazu += kari;
				}
				mae -= A[i];
				maeichi = i;
				flag = 1;
			}
			else if (flag == -1) kotae.pb(i);
		}
		int size = kotae.size();
		size += kotae2kazu;
		size += kotae3.size();
		co(size);
		for (int i : kotae) co(i + 1);
		for (auto p : kotae2) {
			rep(i, p.second) co(p.first + 1 - i);
		}
		for (int i : kotae3) co(i + 1);
	}

	Would you please return 0;
}

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

int main(){
	string N;
	bool f=false;
	cin >> N;
	for(int i=0; i<(int)N.size(); i++){
		if(N[i]=='7'){ f = true; ;}
	}

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

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

ul gcd(ul a, ul b) {
  if (a<b) swap(a, b);
  while (a%b>0) {
    a%=b;
    swap(a, b);
  }
  return b;
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul a, b;
  cin >> a >> b;
  ul g=gcd(a, b);
  vector< ul > l;
  if (g==1) {
    cout << 1 << endl;
    return 0;
  }
  l.push_back(g);
  for (ul i=2; i*i<=g; ++i) {
    if (g%i==0) {
      l.push_back(i);
      if (g/i!=i) l.push_back(g/i);
    }
  }
  sort(l.begin(), l.end());
  ul ans = 1;
  for (auto i : l) {
    if (g%i==0) {
      ans++;
      while (g%i==0) {
	g/=i;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222





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


  map<ll, pll> mp;
  vpll v;
  cin >> n;
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    v.pb(make_pair(a + b, i));
    mp[i] = pll(a, b);
  }
  sort(rall(v));
  ll F = 0, S = 0;
  rep(i, n) {
    if (i % 2) S += mp[v[i].second].second;
    else F += mp[v[i].second].first;
  }
  cout << F - S << endl;



  return 0;
}

Measured memory_bytes: 8048
x = int(input())

if 400 <= x <=599:
    print('8')
elif 600 <= x <=799:
    print('7')
elif 800 <= x <=999:
    print('6')
elif 1000 <= x <=1199:
    print('5')
elif 1200 <= x <=1399:
    print('4')
elif 1400 <= x <=1599:
    print('3')
elif 1600 <= x <=1799:
    print('2')
elif 1800 <= x <=1999:
    print('1')


Measured memory_bytes: 9176
package main

import "fmt"

func main() {
	var n, k, d, m int
	treated := []int{}
	fmt.Scan(&n, &k)
	for i := 0; i < k; i++ {
		fmt.Scan(&d)
		for j := 0; j < d; j++ {
			fmt.Scan(&m)
			exist := false
			for _, val := range treated {
				if m == val {
					exist = true
				}
			}
			if !exist {
				treated = append(treated, m)
			}
		}
	}
	fmt.Println(n - len(treated))
}


Measured memory_bytes: 2348
#include<stdio.h>
#include <math.h>
#define N 10000

int main(){
  int i, j, k;
  int n;
  int p=0; // the number of prime numbers
  int A[N];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);

  for( i = 0 ; i < n ; i++ ){
    if(A[i]==2){
      p++;
    }else if( A[i] < 2 || A[i] % 2 == 0 ) {
      continue;
    }else{
      for( j = 3 ; j <= sqrt((double)A[i]) ; j+=2 ){
	if( A[i] % j == 0 ) {
	  break;
	}
      }
      if( j > sqrt((double)A[i]) ){
	  p++;
	}
    }

  }


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

  return 0;
}

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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
const int INF = 1e9;
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");
#define FOR(i, l, r) for (int i = int(l); i < int(r); ++i)
#define print(a)       for(auto x : a) cout << x << " "; cout << "\n"
#define print1(a)      for(auto x : a) cout << x.ff << " " << x.ss << "\n"
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << "\n"


ll fast_exp(ll base, ll exp) {ll res=1;while(exp>0) {if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return res%MOD;}
int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
int val(char c){if (c >= '0' && c <= '9')return (int)c - '0';else return (int)c - 'A' + 10;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll divisibles(ll a, ll b, ll m){if(a%m==0)return (b/m)-(a/m)+1;else return (b/m)-(a/m);}// in [a,b]
string bitstring(int n, int size){string s;while(n){s+=(n%2)+'0';n/=2;}while(s.size()<size){s+='0';}reverse(all(s));return s;}
// dsu start

vi root(200001,0);
vi size(200001,1);
int find(int x){while(x!=root[x])x = root[x];return x;}
bool same(int a,int b){return find(a)==find(b);}
void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}

// dsu end
vi vis(200001,0);
vi adj[200001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //string bitstring = std::bitset< 3 >( 7 ).to_string(); <bits> (num)
    //srand(time(0));
    //cin.tie(NULL);
    //cout.tie(NULL);
 	int n;
 	cin>>n;
 	vi vec;
 	mapii mps;
 	mapii prime;
 	for(int i=n; i>=1; --i) vec.pb(i);

 	for(int i=2; i<=1000; ++i)
 	{
 		int flag = 0;
 		for(int j = 2; j<=sqrt(i); ++j)
 		{
 			if(i%j==0)
 				++flag;
 		}
 		if(!flag)
 			prime[i] = 1;
 	}
 	ll num = 1;
 	for(int i=0; i<vec.size(); ++i)
 	{
 		if(prime[vec[i]])
 			++mps[vec[i]];
 		else
 		{
 			int x = vec[i];
 			int k = 2;
 			while(x)
 			{
 				if(x==1)
 					break;
 				if(x%k==0)
 				{
 					x/=k;
 					++mps[k];
 				}
 				else
 					++k;
 			}
 		}
 	}
 	for(auto x : mps)
 	{
 		int y = (x.ss+1);
 		num = (num*y)%MOD;
 	}
 	cout<<num<<"\n";

}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int solve(){
  string s;
  cin>>s;
  string t;
  for(char c : s) if(c != 'x') t.pb(c);

  int m=t.size();
  bool ok = true;
  rep(i,m/2) if(t[i] != t[m-i-1]) ok = false;
  if(!ok) return -1;

  vector<int> v;
  int p = 0;
  int n = s.size();
  rep(i,m+1){
    int d=0;
    while(p+d<n && s[p+d]=='x') d++;
    v.pb(d);
    p += d+1;
  }

  int ans = 0;
  rep(i,v.size()/2) ans += abs(v[i] - v[v.size()-i-1]);

  return ans;
}

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

  return 0;
}


Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
long long n,a,b,c,x,t = 1;
int main()
{
	cin >> a >> b;
	x = a - b;
	if (x < 0) cout << "0\n";
		else cout << x << endl;
 	return 0;
 } 

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int count(string *S,int Hi,int Wj,int H,int W) {
	int cnt = 0;
	for (int i = -1;i <= 1;i++) {
		if((i+Hi)>=0&& (i + Hi)<H&&(Wj-1)>=0&&(Wj-1)<W)
			if (S[i + Hi][Wj - 1] == '#')
				cnt++;
		if ((i + Hi) >= 0 && (i + Hi)<H && Wj >= 0 && Wj<W)
			if (S[i + Hi][Wj] == '#')
				cnt++;
		if ((i + Hi) >= 0 && (i + Hi)<H && (Wj + 1) >= 0 && (Wj + 1)<W)
			if (S[i + Hi][Wj + 1] == '#')
				cnt++;
	}

	return cnt;
}

int main() {
	int H, W;
	string S[50];

	cin >> H >> W;

	for (int i = 0;i < H;i++) {
		cin >> S[i];
	}

	for (int i = 0;i < H;i++) {
		for (int j = 0;j < W;j++) {
			if (S[i][j] == '#') {
				cout << "#";
			}
			else {
				cout << count(S, i, j, H, W);
			}
		}
		cout << endl;
	}

	return 0;
}

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

typedef long long lli;

struct Data {
  lli size, id;
};

int main() {
  int N;
  while(cin >> N && N) {
    vector<Data> v;
    while(N--) {
      char op;
      cin >> op;
      if(op == 'W') {
        lli l, S;
        cin >> l >> S;
        for(int i = 0; S && i < v.size(); ++i) {
          if(v[i].id == -2) {
            v[i].id = l;
            if(v[i].size > S) {
              lli r = v[i].size - S;
              v[i].size = S;
              v.insert(v.begin()+i+1, (Data){r, -2});
            }
            S -= v[i].size;
          }
        }
        if(S) {
          v.push_back((Data){S, l});
        }
      } else if(op == 'D') {
        lli l;
        cin >> l;
        for(int i = 0; i < v.size(); ++i) {        
          if(v[i].id == l) v[i].id = -2;
        }
      } else if(op == 'R') {
        lli P;
        cin >> P;
        lli output = -1;
        for(lli i = 0, sum = 0; i < v.size(); sum += v[i++].size) {
          if(P < sum+v[i].size) {
            if(v[i].id >= 0) output = v[i].id;
            break;
          }
        }
        cout << output << endl;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1352