akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

struct UF
{
    vector<int> par, sz, cnt;
    UF() {}
    UF(int n) : par(n), sz(n, 1), cnt(n, 0)
    {
        iota(par.begin(), par.end(), 0);
    }
    int find(int x)
    {
        if (x == par[x])
            return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        cnt[x]++;
        if (x == y)
            return;
        if (sz[x] < sz[y])
            swap(x, y);
        sz[x] += sz[y];
        cnt[x] += cnt[y];
        par[y] = x;
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};

int cnt_x[200000], cnt_y[200000];

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

    int n;
    cin >> n;
    UF uf(200000);
    rep(i, n)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        uf.unite(x, y + 100000);
    }
    int ans = 0;
    rep(i, 100000) cnt_x[uf.find(i)]++;
    Rep(i, 100000, 200000) cnt_y[uf.find(i)]++;
    rep(i, 200000) if (cnt_x[i]) ans += cnt_x[i] * cnt_y[i] - uf.cnt[i];
    cout << ans << endl;
}

Measured memory_bytes: 7040
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<deque>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i];

	deque<int> d;
	REP(i, N) {
		int p = LB(d, A[i]) - d.begin();
		//int p = lower_bound(d.begin(), d.end(), A[i]) - d.begin();

		if (p == 0) {
			d.push_front(A[i]);
		}
		else {
			d[p - 1] = A[i];
		}
	}
	int ans = d.size();
	cout << ans << endl;

	return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;
using tTree = __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

#define FACSIZE 200002

ll invfac[FACSIZE];
ll fac[FACSIZE];

template <class T>
bool chmax(T &, const T &);
template <class T>
bool chmin(T &, const T &);
ll gcd(ll, ll);
ll powLL(ll x, ll y);

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
ll comb(ll, ll);
void make_fact(ll);
void make_invfact(ll);
void fact_init();

int main(void)
{
  char c;
  cin >> c;
  cout << (char)(c + 1) << endl;
  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return mod_mul(t, t);
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = mod_mul(t, t);
    return (k % mod) * (x % mod);
  }
}
ll mod_add(ll a, ll b)
{
  return ((a % mod) + (b % mod)) % mod;
}

ll mod_mul(ll a, ll b)
{
  return ((a % mod) * (b % mod)) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void fact_init()
{
  make_fact(FACSIZE - 1);
  make_invfact(FACSIZE);
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

ll comb(ll n, ll r)
{

  return mod_mul(mod_mul(fac[n], invfac[r]), invfac[n - r]);
}
template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}

ll qp(ll a, ll b)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * mod_mul(ans, a) % mod;
    a = 1LL * mod_mul(a, a) % mod;
  } while (b >>= 1LL);
  return ans;
}
ll qp(ll a, ll b, ll mo)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * (ans % mo) * (a % mo);
    a = 1LL * (a % mo) * (a % mo);
  } while (b >>= 1LL);
  return ans;
}
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
ll powLL(ll x, ll y)
{
  ll ans = 1LL;
  for (ll i = 0LL; i < y; i++)
    ans *= x;
  return ans;
}

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

int main()
{
    int A,B;
    while(~scanf("%d %d",&A,&B))
    {
        if(A==1||A==3||A==5||A==7||A==8||A==10||A==12)
        {
            if(B==1||B==3||B==5||B==7||B==8||B==10||B==12)
                printf("Yes\n");
            else
                printf("No\n");
        }
        else if(A==4||A==6||A==9||A==11)
        {
            if(B==4||B==6||B==9||B==11)
                printf("Yes\n");
            else
                printf("No\n");
        }
        else if(A==2)
        {
            if(B==2)
                printf("Yes\n");
            else
                printf("No\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int H, W;
  cin >> H >> W;
  vector<string> ss(H);
  F0R(i, H) {
    cin >> ss[i];
  }

  vector<vector<int>> hs(H, vector<int>(W)), vs(H, vector<int>(W));
  F0R(i, H) {
    int l = 0, a = 0;
    F0R(j, W) {
      if (ss[i][j] == '.') {
        if (!a++) {
          l = j;
        }
        else {
          hs[i][j] = -(a-1);
        }
      }
      else {
        if (a) {
          hs[i][j - a] = a;
          a = 0;
        }
      }
    }
    if (a) {
      hs[i][W - a] = a;
    }
  }
  F0R(c, W) {
    int l = 0, a = 0;
    F0R(r, H) {
      if (ss[r][c] == '.') {
        if (!a++) {
          l = r;
        }
        else {
          vs[r][c] = -(a - 1);
        }
      }
      else {
        if (a) {
          vs[r - a][c] = a;
          a = 0;
        }
      }
    }
    if (a) {
      vs[H - a][c] = a;
    }
  }
  int result = 0;
  F0R(r, H) {
    F0R(c, W) {
      int score = -1;
      score += hs[r][c] < 0 ? hs[r][c + hs[r][c]] : hs[r][c];
      score += vs[r][c] < 0 ? vs[r + vs[r][c]][c] : vs[r][c];
      chmax(result, score);
    }
  }
  cout << result;
}
#endif


Measured memory_bytes: 38840
class sresult():
 def judge(self,n):
  list={}
  list2=[]
  for i in range(0,n):
   str=raw_input()
   array=str.split(" ")
   no=int(array[0])
   x=no
   sale=int(array[1])
   sold=int(array[2])
   
   if x in list:
    list[no]+=sale*sold
    if list[no]>=1000000 and x not in list2:
     list2.append(no)
   
   else :
    list.update({x:sale*sold})
   if list[no]>=1000000 and x not in list2:
     list2.append(no)
  for i in range(0,len(list2)):
   print list2[i]
  if len(list2)==0:
    print "NA"
  #print list
if __name__=="__main__":
 ans=sresult()
 while True:
  
  n=input()
  if n==0:
   break
  ans.judge(n)

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

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

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

int main() {
  int K;
  int A, B;
  cin >> K >> A >> B;

  for(int i = A; i <= B; i++) {
    if (i % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }

  cout << "NG" << endl;

  return 0;
}


Measured memory_bytes: 3636
import sys
from itertools import product

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N = int(input())
    S = [0 if i == 'o' else 1 for i in input()]
    
    for i, j in product(range(2), repeat=2):
        pat = [i, j] + [0]*(N - 2)
        for k in range(2, N):
            pat[k] = (S[k - 1] - (pat[k - 1] + pat[k - 2])) % 2

        if S[-1] != (pat[0] + pat[-1] + pat[-2]) % 2:
            continue
        if S[0] != (pat[1] + pat[0] + pat[-1]) % 2:
            continue

        ans = ['S' if pat[k] == 0 else 'W' for k in range(N)]
        print(''.join(ans))
        return None

    print(-1)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 6268
<?php
//Request Question
function getq($get_word=null){
	if($get_word===null){
		return str_replace("\n","",fgets(STDIN));
	}else if($get_word===1){
		return explode(" ",str_replace("\n","",fgets(STDIN)));
	}
}

/*		START		*/
$get_temp=getq(1);
$A=$get_temp[0];
$B=$get_temp[1];
$K=$get_temp[2];
$ans=array();
//あげ
for ($i=$A; $i < $K+$A; $i++) { 
	array_push($ans,$i);
}
for ($i=$B-$K+1; $i <= $B; $i++) { 
	array_push($ans,$i);
}
sort($ans);
$temp=$ans[0];
if($A<=$temp&&$temp<=$B){
	echo $temp."\n";
}
for ($i=1; $i < count($ans); $i++) { 
	if($ans[$i]!=$temp){
		if($A<=$ans[$i]&&$ans[$i]<=$B){
			echo $ans[$i]."\n";
			$temp = $ans[$i];
		}
	}
}
?>

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;string t;cin>>s>>t;
  int to=-1;
  if(s.size()<t.size())cout<<"LESS";
  else if(s.size()>t.size())cout<<"GREATER";
  else{
  	for(int i=0;i<s.size();i++){
    	if(s[i]>t[i]){to=1;break;}
      	if(s[i]<t[i]){to=0;break;}
    }
    if(to==-1)cout<<"EQUAL";
    if(to==1)cout<<"GREATER";
    if(to==0)cout<<"LESS";
  
  }
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a<b) {
            System.out.println("a < b");
        }
        else if (a>b) {
            System.out.println("a > b");
        }
        else {
            System.out.println("a == b");
        }
        sc.close();
    }
}


Measured memory_bytes: 26296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve() {
    ll N;
    cin >> N;
    vector<ll> A(N+1);
    for ( int i = 1; i <= N; i++ ) {
        cin >> A[i];
    }
    vector<ll> B, C(N+1);
    for ( int i = N; i > 0; i-- ) {
        if ( C[i] % 2 != A[i] ) {
            B.push_back(i);
            for ( int j = 1; j * j <= i ; j++ ) {
                if ( i % j == 0 ) {
                    C[j]++;
                    if ( j * j != i ) C[i/j]++;
                }
            }
        }
    }

    cout << B.size() << "\n";
    for ( int i = B.size() -1; i >= 0; i-- ) {
        cout << B[i] << "\n";
    }
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 4980
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
ll a[26];
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	long long i,ans,n;
	string s;
	cin>>s;
	n=s.size();
	ans=n*(n-1)/2;
	for(i=0;i<n;i++)
	a[s[i]-'a']++;
	for(i=0;i<26;i++){
		ans-=(a[i]*(a[i]-1))/2;
	}
	cout<<ans+1;
	//system("pause");
	return 0;
}

Measured memory_bytes: 640
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 




/*****************************************************************************/

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

	int n, k;
	cin >> n >> k;
	vi h(n);
	f_vI(h, n);
	vi dp(n + k + 1, ll_INF);
	dp[0] = 0;
	f(i, 0, n) {
		f(j, 0, k + 1) {
			if (i + j < n) {
				dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
			}
		}
	}
	cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 1792
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

//long int ar[10013];
//long int gcd(long int a, long int b)
//{
//    if(b==0)
//        return a;
//    return gcd(b,a%b);
//}
//long int sieve(long long int a)
//{
//    long long int i,j,k = 0;
//    memset(ar,0,sizeof(ar));
//    ar[1] = 1;
//    for(i=2; i<=713; i++)
//    {
//        if(ar[i]==0)
//        {
//            for(j=i+i; j<=713; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//    return ar[a];
//}

void Ok()
{
    long int a,b,c,d,e,f,g,h,t,i,j,k,l,m,n;
    long int ans_1,ans_2,ans_3,cnt_1,cnt_2,cnt_3,Max,Min,flag,temp,sum;
    double aa,bb,cc,dd,ee,ff,gg;
    char aaa[300013],bbb[300013],ccc,ddd;
    string spc,in,store[13];

    cin>>aaa;
    cin>>bbb;
    cnt_1 = 0;
    l = strlen(aaa);
    for(i=0;i<l;i++)
    {
        if(aaa[i]!=bbb[i])
            cnt_1++;
    }
    cout<<cnt_1<<endl;

    return;
}

int main()
{
    Ok();

    return 0;
}


Measured memory_bytes: 4000
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>

using namespace std;

int main(){
  int N;
  cin >> N;
  long long A[N];
  long long B[N];
  for(int i=0; i<N; i++) cin >> A[i] >> B[i];
  vector<pair<long long, int>> vec;
  for(int i=0; i<N; i++){
     vec.push_back(make_pair(A[i]+B[i], i));
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  long long ans=0;
  for(int i=0; i< N; i++){
     int ind = vec[i].second;
     if(i%2==0){
        ans += A[ind];
     }
     else{
        ans -= B[ind];
     }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3956
// O O O O O O O O O O O O O O O OO O OO O OO O O O TTCH O TTTCH O TTTCH O O O O
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
// #include <random>
#include <iomanip>
#include <bitset>
#include <cassert>
 
using namespace std;

#define int long long
#define y1 y11
#define less less228
#define left left228
#define right right228
#define list list228
#define all(v) v.begin(), v.end()
#define tm tm228
 
 
 
template<typename T> void uin(T &a, T b) {
    if (b < a) a = b;
}
template<typename T> void uax(T &a, T b) {
    if (b > a) a = b;
}

const int N = 1007;
const int INF = 1e9 + 228;

int n, m, k;
int a[N][N], sum[N][N];

int get(int x1, int y1, int x2, int y2) {
    return sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> k;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            char c;
            cin >> c;
            a[i][j] = c - '0';
            sum[i][j] = a[i][j] + sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
        }
    }
    int ans = INF;
    for (int mask = 0; mask < (1 << (n - 1)); ++mask) {
        vector<int> ps;
        ps.push_back(0);
        for (int i = 0; i < n - 1; ++i) {
            if ((mask >> i) & 1) ps.push_back(i + 1);
        }
        ps.push_back(n);
        int cnt = __builtin_popcount(mask);
        int last = 1;
        int i = 1;
        while (i <= m) {
            int j = i;
            while (j + 1 <= m) {
                bool chk = 1;
                for (int p = 0; p < (int)ps.size() - 1; ++p) {
                    if (get(ps[p] + 1, i, ps[p + 1], j + 1) > k) {
                        chk = 0;
                        break;
                    }
                }
                if (chk) ++j;
                else break;
            }
            bool chk = 1;
            for (int p = 0; p < (int)ps.size() - 1; ++p) {
                if (get(ps[p] + 1, i, ps[p + 1], j) > k) {
                    chk = 0;
                    break;
                }
            }
            if (!chk) {
                cnt += 10000000;
            }
            i = j + 1;
            ++cnt;
        }
        uin(ans, cnt - 1);
    }
    cout << ans << '\n';
    return 0;
}
// RU_023
 
/*
6 3
2 1
3 5
6 2
3 4
2 3
1
3
1
2
3
2
-----
1
 
 
 
8 4
4 1
1 3
3 6
6 7
7 2
2 5
5 8
2
4
3
1
1
2
3
4
 
 
12 4
7 9
1 3
4 6
2 4
10 12
1 2
2 10
11 1
2 8
5 3
6 7
3
1
1
2
4
3
3
2
2
3
4
4
 
 
8 3
1 2
2 3
3 4
4 5
5 6
6 7
7 8
1
3
1
1
3
2
3
2
 
 
 
 
 
*/

Measured memory_bytes: 2432
#include<stdio.h>
#include<math.h>

int main(void){
int N;
int a[10000] = {};
int cnt0 = 0;
int cnt1 = 0;
int i,k;
  
scanf("%d",&N);
for(i=0;i<N;i++)
	scanf("%d",&a[i]);

  
for(i=0;;i++){
  	cnt1 = 0;
	for(k=0;k<N;k++)
      	if(a[k] % 2 == 0 && a[k] != 0){
          	a[k] = a[k] / 2;
            cnt0++;
        }
  		else {
          a[k] = 1;
          cnt1 += 1; 
        }
 if(cnt1 == N) break ;
}
  printf("%d \n",cnt0);
return 0;
}

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

using namespace std;

set <string> st;

int main(){
	int n; cin >> n;
	
	char last = '#';
	for (int i = 1; i <= n; i++) {
		string s; cin >> s;
		
		if (st.find(s) != st.end()) return cout << "No", 0;
		if (last != '#' && last != s[0]) return cout << "No", 0;
		
		last = s[s.length() - 1];
		st.insert(s);
	}
	
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
use proconio::input;

const MOD: i64 = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let mut sum = a.iter().fold(0, |a, x| (a + x) % MOD);
    let mut ans = 0;

    for i in 0..n {
        sum -= a[i];
        if sum < 0 {
            sum += MOD;
        }
        ans += a[i] * sum;
        ans %= MOD;
    }

    println!("{}", ans);
}


Measured memory_bytes: 5604
# 吸い込んでソートして[5, 5, 7]になるものっていう昔書いたやつがクレバーだった（忘れてた）
# 今回はまっさきに浮かんだやつで....
ok = [[5, 5, 7], [5, 7, 5], [7, 5, 5]]
stdin = list(map(int, input().split()))
print("YES" if stdin in ok else "NO")


Measured memory_bytes: 38256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
   int x[3];
   char str[3][32] = { NULL };
   for( int i=0; i<3; i++ ){
      scanf( "%s", str[i] );
      x[i] = atoi( str[i] );
   }

   if( x[0] < x[1] && x[1] < x[2] )
      printf( "Yes\n" );
   else
      printf( "No\n" );

   return 0;
}


Measured memory_bytes: 2628
def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

N = int(input())
A = list(map(int, input().split()))

A.sort()
for i in range(N-1):
    if i % 2 == 0:
        if A[i] + A[i+1] < 0:
            A[i] = -A[i]
            A[i+1] = -A[i+1]
            
print(sum(A))


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

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

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



// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(200005);


//nPk
 mint f(int n, int k) {
    if (n < 0) return 0;
    // nPk = nCk * k!
    mint res = comb(n,k);
    res *= comb.fact[k];
    return res;
}




//組み合わせの数nCrを計算
   int calcNumOfCombination(int n, int r){
       int num = 1;
       for(int i = 1; i <= r; i++){
           num = num * (n - i + 1) / i;
       }
       return num;
   }


   //N^P(modM)

   using ll = long long int;
   ll RepeatSquaring(ll N, ll P, ll M){
       if(P==0) return 1;
       if(P%2==0){
           ll t = RepeatSquaring(N, P/2, M);
           return t*t % M;
       }
       return N * RepeatSquaring(N, P-1, M);
   }


int main() {
  ll n,m,k;
  cin>>n>>m>>k;
  mint ans=0;
  vector<mint> v(n,0);
  mint temp=1;

  rep(i,n){
    v[i]=temp;
    //cout<<temp<<endl;
    temp*=(m-1);
  }

    ans+=v[n-1]*m;

  for(int i=1;i<=k;i++){
    mint now=comb(n-1,i);
    //cout<<now<<endl;
    mint pl=v[n-i-1];
    //cout<<v[n-k+1]<<' '<<v[1]<<' '<<pl<<'p'<<endl;
    pl*=m;

    now*=pl;
  //  cout<<now<<'n'<<pl<<'p'<<endl;
    ans+=now;
  }
cout<<ans;


}


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

int main() {
	int w,a,b; cin >>w >> a>>b;
	int val;
	if (a<b){
		val = max(b-(a+w),0);
	} else {
		val = max(a-(b+w),0);
	}
	cout << val << endl; 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}

int main()
{
	int h, w;
	cin >> h >> w;
	vector<vector<int>> a(h, vector<int>(w));
	rep(i, h) rep(j, w) cin >> a[i][j];
	int cnt=0;
	deque<pair<int,int>>bef,aft;
	rep(i, h)
	{
		
			rep(j, w)
			{
				//cout<<i<<" "<<j<<endl;
				if (a[i][j] % 2 != 0)
				{
					if (j != w - 1)
					{
						//右端でないなら右に移す
						cnt++;
						a[i][j]--;
						a[i][j + 1]++;
						bef.pb(make_pair(i+1,j+1));
						aft.pb(make_pair(i+1,j+2));
						//cout << i+1 << " " << j+1 << " " << i+1 << " " << j + 2 << endl;
					}
					else if (i != h - 1)
					{
						//右端なら下に移す
						cnt++;
						a[i][j]--;
						a[i + 1][j]++;
						bef.pb(make_pair(i+1,j+1));
						aft.pb(make_pair(i+2,j+1));
						//cout << i+1 << " " << j +1<< " " << i + 2 << " " << j+1 << endl;
					}
				}
			}
		
	}
	cout<<cnt<<endl;
	rep(i,bef.size()){
		cout<<bef[i].F<<" "<<bef[i].S<<" "<<aft[i].F<<" "<<aft[i].S<<endl;
	}
	/*rep(i, h)
	{
		rep(j, w)
		{
			cout << a[i][j];
		}
		cout << endl;
	}*/
}

Measured memory_bytes: 5120
#include<iostream>
#include<cmath>
using namespace std;
int main(){
   int num,ans;
   for(int i=2;i>=0;i--){
       cin>>num;
       ans+=num*pow(10,i);
   }
   if(ans%4==0) cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
   return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: u64,
    }
    let mut h = 0;
    let mut tmp = n;

    while tmp > 0 {
        h += tmp % 10;
        tmp /= 10;
    }
    println!("{}", if n % h == 0 { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
n, m = map(int, input().split())
side1 = set()
side2 = set()

for i in range(m):
	a, b = map(int, input().split())

	if a == 1:
		side1.add(b)
	
	elif b == n:
		side2.add(a)

print(("" if side1 & side2 else "IM") + "POSSIBLE")

Measured memory_bytes: 19024
m = [48.00, 51.00, 54.00, 57.00, 60.00,
     64.00, 69.00, 75.00, 81.00, 91.00]
n = ["light fly", "fly", "bantam",
     "feather", "light", "light welter",
     "welter", "light middle",
     "middle", "light heavy"]

while True:
    try:
        a = float(raw_input())
    except EOFError as e:
        break
    for i, o in enumerate(m):
        if a <= o:
            s = n[i]
            break
    else:
        s = "heavy"
    print s
    

Measured memory_bytes: 4248
def main():
    mod=1000000007
    n,k=map(int,input().split())
    A=[0]*(k+1)
    A[k]=1
    for i in range(1,k)[::-1]:
        l=k//i
        A[i]=pow(l,n,mod)
        for j in range(2,l+1):
            #print(i,i*j)
            A[i]-=A[i*j]
            A[i]%=mod
    #print(A)
    ans=0
    for i in range(1,k+1):
        ans+=A[i]*i
        ans%=mod
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 68764
h, w, k = map(int, input().split())
s = [""] * h
for i in range(h):
    s[i] = input()

ans = [[0 for i in range(w)] for j in range(h)]
lcnt = [0] * h
cnt = 0

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            lcnt[i] += 1

flag = 0
mem = [0] * w

a = 1

for i in range(h):
    t = 0
    j = 0

    while t < lcnt[i]:

        if s[i][j] == "#":
            t += 1
            ans[i][j] = a
            a += 1
        else:
            ans[i][j] = a

        j += 1

    for l in range(j, w):
        ans[i][l] = a - 1

for i in range(h):
    if lcnt[i] > 0:
        for j in range(w):
            mem[j] = ans[i][j]
        break

t = 0
while lcnt[t] == 0:
    for i in range(w):
        ans[t][i] = mem[i]
    lcnt[t] = 1
    t += 1

for i in range(1, h):
    if lcnt[i] == 0:
        for j in range(w):
            ans[i][j] = ans[i - 1][j]

for i in range(h):
    for j in range(w):
        print(ans[i][j], end="")
        if j != w - 1:
            print(" ", end="")
    print()

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

int main(){
  int n,x,i,j;
  int d[30];
  bool can[1000001];

  for(;;){
    cin >> n >> x;
    if(!n && !x)break;

    for(i=0;i<n;i++)cin >> d[i];
    for(i=1;i<=x;i++)can[i] = false;
    can[0] = true;

    for(i=0;i<n;i++){
      for(j=0;j+d[i]<=x;j++){
	if(can[j])can[j+d[i]] = true;
      }
    }

    for(i=x;i>=0;i--)
      if(can[i] && i&1){
	bool f=true;
	for(j=3;j*j<=i;j+=2)
	  if(!(i%j)){
	    f = false;
	    break;
	  }
	if(f)break;
      }
    if(i<0)cout << "NA" << endl;
    else cout << i << endl;
  }
}

Measured memory_bytes: 0
#include <string.h>
#include <iostream>

using namespace std;

int main()
{
	int count = 0, i;
	string str, tmp;
	bool first = true;
	
	getline(cin, str);
	
	for (i=0; i<1025 && str[i] != '\0'; i++) {
		if (str[i] != ' ' && str[i] != ',' && str[i] != '.') {
			tmp[count++] = str[i];
		} else {
			tmp[count] = '\0';
			if (count >= 3 && count <= 6)
				if (first) {
					cout << tmp.c_str() << flush;
					first = false;
				} else
					cout << " " << tmp.c_str() << flush; 
			count = 0;
		}
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  if((b-a)%2==1){
    cout << (b-a+1)/2 + min(n-b, a-1) << endl;
  }
  else cout << (b-a)/2 << endl;
}

Measured memory_bytes: 256
K,N = map(int, input().split())
A = [int(N) for N in input().split()]
#print(A[0])
max1 = 0
max2 = 0
for i in range(0,N-1):
    max1 = A[i+1]-A[i]
    if max1>max2:
        max2=max1
if A[0]==0:
    lastlength = K-A[N-1]
    if lastlength >max2:
        max2=lastlength
else:
    lastlength = K-A[N-1]+A[0]
    if lastlength>max2:
        max2=lastlength
print(K-max2)

Measured memory_bytes: 26444
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<queue>
#include<set>
using namespace std;
typedef long long int lli;
typedef pair<int, int> pii;
class UnionFind{
public:
  UnionFind();
  UnionFind(int _n){init(_n);}
  void init(int _n){
    n = _n;
    rank.resize(n, 0);
    parent.resize(n, -1);
  }
  int find(int x){
    if(parent[x] < 0)return x;
    else return parent[x] = find(parent[x]);
  }
  void unite(int x, int y){
    x = find(x), y = find(y);
    if(x == y)return;
    if(rank[x] < rank[y]){
      parent[y] += parent[x];
      parent[x] = y;
    }else{
      parent[x] += parent[y];
      parent[y] = x;
      if(rank[x] == rank[y])rank[x]++;
    }
  }
  bool same(int x, int y){
    return find(x) == find(y);
  }
  int size(int v){
    if(parent[v] < 0)return -parent[v];
    else return size(parent[v]);
  }
private:
  int n;
  vector<int> rank, parent;
};


int main(){
  int n, m;
  std::cin >> n;
  vector<lli> salary(n, 0), c(n);;
  UnionFind uf(n);
  for (int i = 0; i < n; i++){
    std::cin >> c[i];
  }
  std::cin >> m;
  vector<vector<int> > g(n);
  vector<vector<pii> > gg(n);
  for (int i = 0; i < m; i++) {
    int to, from;
    std::cin >> to >> from;
    to--, from--;
    if(c[to] < c[from])swap(to, from);
    if(c[to] == c[from])uf.unite(to, from);
    else g[from].push_back(to);
    gg[from].push_back(pii(c[to], to));
    gg[to].push_back(pii(c[from], from));
  }
  for (int i = 0; i < n; i++) {
    sort(gg[i].begin(), gg[i].end());
    for (int j = 1; j < gg[i].size(); j++) {
      auto &prev = gg[i][j - 1], cur = gg[i][j];
      if(prev.first == cur.first)uf.unite(prev.second, cur.second);
      else g[prev.second].push_back(cur.second);
    }
  }
  vector<int> id;
  for (int i = 0; i < n; i++) {
    if(uf.find(i) == i){
      id.push_back(i);
      salary[i] = 1;
    }else{
      copy(g[i].begin(), g[i].end(), back_inserter(g[uf.find(i)]));
      g[i].clear();
    }
  }
  sort(id.begin(), id.end(), [&](int a, int b){return c[a] < c[b];});
  lli ans = 0;
  for (int i: id) {
    for (int to: g[i]) salary[uf.find(to)] = max(salary[uf.find(to)], salary[i] + 1);
    ans += salary[i]*uf.size(i);
    }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 20528
#include <iostream>

using namespace std;

int main()
{
  int n,nn,n3,n4;
  cin >> n >> nn >> n3 >> n4;
  int a[15] = {0};
  a[n] = 1,a[nn] = 1,a[n3] = 1,a[n4] = 1;
  if(a[1] == 1 && a[9] == 1 && a[7] == 1 && a[4] == 1){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

}


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

int main() {
  long long N,A,B;
  cin >> N >> A >> B;
  
  
  if ((A - B) % 2 == 0){
    cout << (B - A)/2 << endl;
  }
  else {
    if (B-1 >= N-A){
      cout << (2*N-(A+B)+1)/2 << endl;
    }
    else {
      cout << (A+B-1)/2 << endl;
    }
  }
}



Measured memory_bytes: 3632
n, k = map(int, input().split())
A = list(map(int, input().split()))

tentosu_f = 0
tentosu_l = 0
mod = 10**9 + 7
ans = 0

for i in range(n):
    for j in range(i, n):
        if A[i] > A[j]:
            tentosu_f += 1
          
for i in range(n):
    for j in range(n):
        if A[i] > A[j]:
            tentosu_l += 1
            
ans = (tentosu_f * k) + ((k * (k-1) // 2) * tentosu_l)
print(int(ans % mod))


Measured memory_bytes: 3188
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

S = sum(A)
S %= MOD
ans = 0
for a in A:
    S += MOD
    S -= a
    S %= MOD
    ans += a * S
    ans %= MOD

print(ans)


Measured memory_bytes: 31760
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    long long x;
    cin >> x;
    double sql;
    int ans=0;
    for(int i=x;i>=0;i--){
        sql = sqrt(i) - floor(sqrt(i));
        if(sql == 0){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  sort(ALL(a));
  int A=0;
  int B=0;
  bool c=0;
  for(int i=n-1;i>=0;i--){
    if(!(c)){
      A+=a[i];
      c=1;
    }else{
      B+=a[i];
      c=0;
    }
  }
  A=abs(A-B);
  cout<<A<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

const int N=200005;

int a[N];

int main(void) {
	int n; scanf("%d",&n); n*=2;
	rep(i,1,n) scanf("%d",&a[i]);
	std:: sort(a+1,a+n+1);
	int ans=0;
	for (int i=1;i<=n;i+=2) ans+=a[i];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
typedef long double ld;
const ld eps = 1e-9;

vector<ld> quadraticEquation(ld a, ld b, ld c){
    ld d = b*b - 4*a*c;
    if(abs(a) < eps) return { -c/b };
    if(abs(d) < eps) return { (-b + sqrt(d)) / (2*a) };
    if(0 < d){
        int sign = (b >= 0) ? 1 : -1;
        ld x1 = (-b - sign * sqrt(d))/(2.0 * a), x2 = c / (a * x1);
        return { x1, x2 };
    }
    return {};
}

ld simpson(ld x0, ld x1, function<ld(ld)> f){
    const int n = 1e5;
    const ld dx = (x1 - x0) / n;
    ld a = f(x0) + f(x0 + dx * n);
    for(int i = 1; i < n; i += 2) a += 4.0 * f(x0 + dx * i);
    for(int i = 2; i < n; i += 2) a += 2.0 * f(x0 + dx * i);
    return a*dx/3.0;
}

ld W,H,N;
ld a[55], p[55], q[55];

ld f(int i, ld x){
    return a[i]*(x-p[i])*(x-p[i]) + q[i];
}

bool inside(ld x, ld y){
    if (x < -eps || W < x-eps) return false;
    if (y < -eps || H < y-eps) return false;
    return true;
}

ld solve(){
    vector<ld> es = { 0, W };
    rep(i,N){
        auto xs = quadraticEquation(a[i], -a[i]*2*p[i], q[i] + a[i]*p[i]*p[i]); // on x axis
        for(ld x : xs) if(inside(x,f(i,x))) es.push_back(x);
        rep(j,i){
            ld aa = a[i] - a[j];
            ld bb = -a[i]*2*p[i] - (-a[j]*2*p[j]);
            ld cc = (q[i] + a[i]*p[i]*p[i]) - (q[j] + a[j]*p[j]*p[j]);
            auto cs = quadraticEquation(aa, bb, cc);
            for(ld x : cs) {
                if(inside(x,f(i,x))){
                    es.push_back(x);
                }
            }
        }
    }
    sort(es.begin(), es.end());
    ld ans = 0;
    rep(i,es.size()-1){
        ld x1 = es[i], x2 = es[i+1];
        ld m = (x1+x2) / 2;
        int idx = -1;
        ld maxy = -1e9;
        rep(j,N){
            if(maxy < f(j,m)){
                maxy = f(j,m);
                idx = j;
            }
        }
        if(maxy > -eps){
            ans += simpson(x1, x2, [&](ld x){
                    ld dy = a[idx] * 2 * (x - p[idx]);
                    return sqrt(1 + dy*dy);
                });
        }
    }
    return ans;
}

int main(){
    while(cin >> W >> H >> N){
        rep(i,N) cin >> a[i] >> p[i] >> q[i];
        printf("%.10lf\n", (double)solve());
    }
}

Measured memory_bytes: 3408
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

int main() {
    vector<int> v;
    int n;
    while(cin >> n) {
        v.push_back(n);
    }
    sort(v.begin(), v.end(), greater<int>());
    cout << v[0] << endl;
    cout << v[1] << endl;
    cout << v[2] << endl;
}

Measured memory_bytes: 1216
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;

int main(){
   int n,m;
   cin >> n >> m;
   int sei=0,pe=0;
   int problem[n] = {};
   int penalty[n] = {};
   int p;
   string s;
   REP(i,m){
       cin >> p >> s;
       if(s=="AC"){
           problem[p-1] = 1;
       }else{
           if(problem[p-1]==0) penalty[p-1] += 1;
       }
   }
   
   REP(i,n){
       if(problem[i] == 1){
           sei++;
           pe += penalty[i];
       }
   }
   
   cout << sei  << " "<< pe <<  endl;
   
   return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<vector<char> > S(N,vector<char>(N));
  rep(i,N)rep(j,N)cin >> S[i][j];
  int count = 0;
  rep(A,N){
    bool sat = true;
    rep(i,N) rep(j,N) if(S[(i+A)%N][j] != S[(j+A)%N][i])sat = false;
    if(sat) ++count;
  }
  cout << count * N << endl;
  return 0;
}


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

int main() {
  int N,K;
  string S;
  cin >> N >> S >> K;
  for(int i=0; i<S.size(); i++){
    if(S[i] != S[K-1]){
      cout << "*";
    }
    else{
      cout << S[K-1];
    }
  }
}


Measured memory_bytes: 3456
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<string>
#include<cmath>
using namespace std;
int main(){
	int n;
	cin >> n;
	int t[n+1]={0},x[n+1]={0},y[n+1]={0};
	for(int i=1;i<=n;i++){
		cin >> t[i] >> x[i] >> y[i];
	}
	for(int i=0;i<=n-1;i++){
		int a=x[i]-x[i+1];a=abs(a);
		int b=y[i]-y[i+1];b=abs(b);
		int x=a+b;
//		cout << a << ' ' << b << ' ' << x << ' ' << t[i+1]-t[i] << endl;
//		int x=fabs(x[i]-x[i+1])+fabs(y[i]-y[i+1]);
		x=t[i+1]-t[i]-x;
		if(x<0||x%2){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 1408