akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int n,k;
    cin >> n >> k;
    if(k == 1){
        cout << 0 << endl;
    }
    else{
        cout << n - k << endl;
    }

}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,K;
	int d,a;
	int cnt=0;
	cin>>N>>K;
	static vector<bool> okashi_have(N);
	for(int i=0;i<K;i++){
		cin>>d;
		for(int j=0;j<d;j++){
			cin>>a;
			okashi_have[a]=true;
		}
	}
	for(int i=1;i<=N;i++)
		if(!okashi_have[i]) cnt++;
	cout<<cnt<<endl;
}


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

using namespace std;

int N, a[2017];
bool ap[2017][2017], col[2017];

int gcd (int a, int b)
{
    int r;
    while (b)
        r = a % b, a = b, b = r;
    return a;
}

void print (vector < int > x, string s)
{
    bool ndSpace = 0;
    printf ("[");
    for (auto it : x)
    {
        if (ndSpace) printf (" ");
        printf ("%d", it), ndSpace = 1;
    }
    printf ("]%s", s.c_str ());
}

vector < int > combine (vector < int > a, vector < int > b)
{
    auto itA = a.begin (), itB = b.begin ();
    vector < int > c;
    while (itA != a.end () || itB != b.end ())
    {
        if (itA == a.end () || (itB != b.end () && *itA < *itB)) c.push_back (*itB), itB ++;
        else c.push_back (*itA), itA ++;
    }
    return c;
}

vector < int > currComp;
set < int > currP;
void dfs (int nod)
{
    col[nod] = 0, currComp.push_back (nod), currP.erase (nod);
    vector < int > neig;
    for (auto i : currP)
        if (ap[nod][i] && col[i])
            neig.push_back (i);
    for (auto i : neig)
        currP.erase (i);
    for (auto i : neig)
        dfs (i);
}

vector < int > solve (int frbd, vector < int > P)
{
    int mini = 1e9, how = -1;
    currP.clear ();
    for (auto it : P)
        if (a[it] < mini && (frbd == -1 || ap[frbd][it]))
            mini = a[it], how = it;
    for (auto it : P)
        if (it != how)
            currP.insert (it), col[it] = 1;
    vector < vector < int > > splt;
    while (!currP.empty ())
    {
        for (auto i : currP)
            if (ap[how][i] && col[i])
            {
                currComp.clear (), currP.erase (i);
                dfs (i), splt.push_back (currComp);
                break;
            }
    }
    vector < int > ans;
    for (auto v : splt)
        ans = combine (ans, solve (how, v));
    if (frbd != -1)
        ans.insert (ans.begin (), a[how]);
    return ans;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=1; i<=N; i++)
    scanf ("%d", &a[i]);
for (int i=0; i<=N; i++)
    for (int j=i + 1; j<=N; j++)
        ap[i][j] = ap[j][i] = (i == 0 || gcd (a[i], a[j]) != 1);
vector < int > elems;
for (int i=0; i<=N; i++)
    elems.push_back (i);
vector < int > ans = solve (-1, elems);
for (auto it : ans)
    printf ("%d ", it);
printf ("\n");
return 0;
}


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

using namespace std;

const int N = 1e6 + 7;

int n;

int main()
{

        ios_base::sync_with_stdio(0);
        cin.tie(0);
        //freopen("in.in", "r", stdin);
        cin >> n;
        long long x = 0;
        for (int i = 0; i < 2000000; i++)
        {
                x = x * 10 + 7;
                x %= n;
                if (!x)
                {
                        cout << i + 1;
                        return 0;
                }
        }
        cout << -1;
        return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  auto chk = [&](long long x) {
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
      sum += x;
      x /= 2;
      if (x == 0) {
        break;
      }
    }
    return sum <= k;
  };
  long long ok = 0, ng = k + 1;
  while (ng - ok > 1) {
    long long mid = (ok + ng) / 2;
    (chk(mid) ? ok : ng) = mid;
  }
  cout << ok << '\n';
}



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

int linearSearch();

int main(){
  int i,n,A[N], a,b,c = 0;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  scanf("%d", &a);
  for(i = 0; i < a; i++){
    scanf("%d", &b);
    if( linearSearch(A,b,n) == 1 ) c++;
  }
  printf("%d\n",c);
  return 0;
}

int linearSearch(int A[], int b, int n){
  int i;
  for(i = 0 ; i < n-1; i++){
    if(A[i] == b) return 1;
  }
  return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <cmath>
using namespace std;
typedef long long int LLI;

int main()
{
	int n;
	LLI snuke = 0, racoon = 0, min;
	cin >> n;
	
	LLI arr[n];
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
		racoon += arr[i];
	}
	
	snuke += arr[0];
	racoon -= arr[0];
	min = abs( snuke - racoon );
	
	for(int i = 1; i < n-1; i++)
	{
		snuke += arr[i];
		racoon -= arr[i];
		if( min > abs( snuke - racoon ) )
			min = abs( snuke - racoon );
	}
	
	cout << min;
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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; }


int main()
{
    ll X,t;
    cin >> X >> t;

    cout << max((ll)0, X-t) << endl;
}


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

const int mxN = 1e5+1;
int cnt[mxN];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, q, tmp, b, c;
    ll sum = 0;
    memset(cnt, 0, sizeof(cnt));
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> tmp;
        cnt[tmp]++;
        sum += tmp;
    }

    cin >> q;
    while(q--) {
        cin >> b >> c;
        sum += cnt[b]*(c-b);
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << '\n';
    }
    return 0;
}


Measured memory_bytes: 4016
#include<iostream>
#include<stdio.h>
#include<set>
#include<map>
#include<utility>
#include<math.h>
#include<iomanip>
#include<string>
#include<vector>
using namespace std ;
using ll = long long ;
using vll = vector<ll> ;
using vi = vector<int> ;
using vii = vector<vi> ;
using ld = long double ;
using pii = pair<int,int> ;

int main(){
	vii bingo(3,vi(3)) ;
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin >> bingo.at(i).at(j) ;
		}
	}
	int n ; cin >> n ;
	vi num(n) ;
	for(int i=0;i<n;i++) cin >> num.at(i) ;
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<n;k++){
				if(bingo.at(i).at(j)==num.at(k)) bingo.at(i).at(j) = 0 ;
			}
		}
	}
	bool ok = false ;
	if(bingo.at(0).at(0)==0&&bingo.at(0).at(1)==0&&bingo.at(0).at(2)==0) ok = true ;
	if(bingo.at(1).at(0)==0&&bingo.at(1).at(1)==0&&bingo.at(1).at(2)==0) ok = true ;
	if(bingo.at(2).at(0)==0&&bingo.at(2).at(1)==0&&bingo.at(2).at(2)==0) ok = true ;
	if(bingo.at(0).at(0)==0&&bingo.at(1).at(0)==0&&bingo.at(2).at(0)==0) ok = true ;
	if(bingo.at(0).at(1)==0&&bingo.at(1).at(1)==0&&bingo.at(2).at(1)==0) ok = true ;
	if(bingo.at(0).at(2)==0&&bingo.at(1).at(2)==0&&bingo.at(2).at(2)==0) ok = true ;
	if(bingo.at(0).at(0)==0&&bingo.at(1).at(1)==0&&bingo.at(2).at(2)==0) ok = true ;
	if(bingo.at(0).at(2)==0&&bingo.at(1).at(1)==0&&bingo.at(2).at(0)==0) ok = true ;
	if(ok) cout << "Yes" << endl ;
	else cout << "No" << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=105;
//i_am_noob
int a[5],ans=4e18,noob;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	rep(5) cin >> a[i];
	sort(a,a+5);
	do{
		noob=0;
		rep(4) noob+=10*ceiling(a[i],10);
		noob+=a[4];
		ans=min(ans,noob);
	}while(next_permutation(a,a+5));
	print1(ans);
	return 0;
}


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

#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

int main()
{
    int n,m;
    cin >> n >> m;
    int k;
    vector<vector<int>> s(m,vector<int>(n));
    vector<int> p(m);
    rep(i,m){
        cin >> k;
        s[i].resize(k);
        rep(j,k){
            cin >> s[i][j];
        }
    }

    rep(i,m)cin >> p[i];
    vector<int> bin(n);

    ll ans=0;
    ll count=0;
    ll count_p;
    repl(i,1<<n){
        ll b=i;
        rep(j,n){
            bin[j]=b%2;
            b/=2;
        }
        count_p=0;
        rep(j,m){
            count=0;
            rep(k,s[j].size()){
                if(bin[s[j][k]-1]==1){
                    count++;
                }
            }
            if(count%2==p[j]){
                count_p++;
            }
        }
        if(count_p==m){
            ans++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3556
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    double r;
    cin >> r;

    static const double PI = 3.14159265358979;
    double s = r * r * PI;
    double c = r * 2 * PI;

    cout << fixed << setprecision(6) << s << ' ' << c << ' ' << endl;

    return 0;
}

Measured memory_bytes: 3272
def resolve():
    N = int(input())
    AB = [list(map(int, input().split())) for _ in range(N-1)]
    adjlist = {}
    for a, b in AB:
        adjlist.setdefault(a-1, [])
        adjlist.setdefault(b-1, [])
        adjlist[a-1].append(b-1)
        adjlist[b-1].append(a-1)
    import collections
    q = collections.deque([0])
    sources = [None for _ in range(N)]
    sources[0] = -1
    while q:
        v = q.popleft()
        for nxt in adjlist[v]:
            if sources[nxt] is None:
                sources[nxt] = v
                q.append(nxt)
    
    # print(adjlist)
    # print(sources)
    shortest = [N-1]
    cur = N-1
    while True:
        shortest.append(sources[cur])
        if sources[cur] == 0:
            break
        cur = sources[cur]
    shortest.reverse()
    # print(shortest)
    shortest = collections.deque(shortest[1:-1])

    b_nexts = set(adjlist[0])
    b_nexts.discard(N-1)
    w_nexts = set(adjlist[N-1])
    w_nexts.discard(0)

    colored = [False for _ in range(N)]
    colored[0] = True
    colored[N-1] = True
    b_turn = True
    while True:
        # print(colored)
        # print(b_nexts)
        # print(w_nexts)
        # print(shortest)
        if b_turn:
            if len(b_nexts) == 0:
                print("Snuke")
                return
            if len(shortest) > 0:
                nxt = shortest.popleft()
                b_nexts.remove(nxt)
            else:
                nxt = b_nexts.pop()
            if nxt in w_nexts:
                w_nexts.remove(nxt)
        else:
            if len(w_nexts) == 0:
                print("Fennec")
                return
            if len(shortest) > 0:
                nxt = shortest.pop()
                w_nexts.remove(nxt)
            else:
                nxt = w_nexts.pop()
            if nxt in b_nexts:
                b_nexts.remove(nxt)
        # print(nxt)
        colored[nxt] = True
        for v in adjlist[nxt]:
            if colored[v] is False:
                if b_turn:
                    b_nexts.add(v)
                else:
                    w_nexts.add(v)
        
        b_turn = not b_turn
    #print("Snuke" if b_turn else "Fennec")


if '__main__' == __name__:
    resolve()

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(void){

    string s, t;
    cin >> s >> t;

    int sum = 0, ans=t.size();
    for(int i=0; i<s.size()-t.size()+1; i++){
        for(int j=0; j<t.size(); j++){
            if(s.at(i+j) != t.at(j)) sum++;
        }
        if(ans > sum) ans=sum;
        sum=0;
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int q=1;
  for (int i=0;i<3;++i) {
    if (s[i] == s[i+1]) {
      q*=0;
    }
  }
  if (q==0) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  const Int MAX = 2e5;
  vector<Int> ok(MAX,0);
  for(Int i=2;i<MAX;i++){
    Int res=1;
    for(Int j=2;j*j<=i;j++){
      if(i%j) continue;
      res*=j;
      if(j*j!=i) res*=i/j;
      if(res>=i*2) break;
    }
    ok[i]=res>=i*2;
  }

  vector<Int> ans(MAX,0);
  for(Int i=1;i<MAX;i++) ans[i]=ans[i-1]+ok[i];

  Int q;
  cin>>q;
  for(Int i=0;i<q;i++){
    Int x;
    cin>>x;
    cout<<ans[x]<<"\n";
  }
  cout<<flush;
  return 0;
}



Measured memory_bytes: 5876
#include <iostream>

using namespace std;
void InitFalse(bool cards[14])
{
	for(int i = 1; i < 14; i++)
	{
		cards[i] = false;
	}
}
void WriteSol(bool cards[14], char letter)
{
    for (int i = 1; i < 14; i++)
        if (cards[i] == false)
            cout << letter << " " << i << endl;
}
int main()
{
    bool cardS [14];
    bool cardH [14];
    bool cardC [14];
    bool cardD [14];
    InitFalse(cardS);
    InitFalse(cardH);
    InitFalse(cardC);
    InitFalse(cardD);
    int n;
    char rank_card;
    int num_card;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> rank_card >> num_card;
        switch(rank_card)
        {
            case 'S':
            {
                cardS[num_card] = true;
                break;
            }
            case 'H':
            {
                cardH[num_card] = true;
                break;
            }
            case 'D':
            {
                cardD[num_card] = true;
                break;
            }
            case 'C':
            {
                cardC[num_card] = true;
                break;
            }
        }
    }
    WriteSol(cardS,'S');
    WriteSol(cardH, 'H');
    WriteSol(cardC, 'C');
    WriteSol(cardD, 'D');
    return 0;
}



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

int main(){
	int N, n, M, m, r, q, s, t;
	while(cin >> N >> M){
		if(N == 0 && M == 0) break;
		vector<vector<int>> lgin(M+1,vector<int>(1262,0)); 
		cin >> r;
		for(int i = 0;i<r;i++){
			cin >> t >> n >> m >> s;
			if(s == 1){
				lgin[m][t+1] += 1;
			}
			else{
				lgin[m][t+1] -= 1;
			}
		}
		cin >> q;
		for(int i = 0;i<q;i++){
			cin >> n >> r >> m;
			if(lgin[m][0]==0) {
				for(int j = 540;j<1261;j++){
					lgin[m][j] = lgin[m][j-1]+lgin[m][j];
				}
				for(int j = 540;j<1261;j++){
					if(lgin[m][j]>0){
						lgin[m][j] = lgin[m][j-1] + 1;
					}
					else{
						lgin[m][j] = lgin[m][j-1];
					}
				}
				lgin[m][0] = 1;
			}
			cout << lgin[m][r] - lgin[m][n] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 50988
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

int main(){
    int A, B, C, X;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;

    int c=0;
    for(int i=0; i<=A; i++){
        for(int j=0; j<=B; j++){
            for(int k=0; k<=C; k++){
                if(500*i+100*j+50*k == X){
                    c++;
                }
            }
        }
    }
    
    cout << c << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ll long long int
#define Pi atan(1)*4
using namespace std;
int main(){
	io; 
	int n;
	int a;
	cin >> n;
	bool f = 1;
	while(n--){
		cin >> a;
		if(a % 2 == 0){
			if(a % 3 != 0 && a % 5 != 0){
				f = 0;
			}
		}
	} 
	if(f)
		cout << "APPROVED";
	else{
		cout << "DENIED";
	}
	return 0;
} 

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

int main()
{
    int m, n, o, i;
    o = 0;
    cin >> m;
    cin >> n;
    if (m+n >= 2*m){
        if(m+n >= 2*n){
            cout << m+n;
        }
        else{
            cout << 2*n-1;
        }
    }
    else {
        if (2*m >= 2*n){
            cout << 2*m-1;
        }
        else{
            cout << 2*n-1;
        }
    }
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

pairs = []
for _ in range(M):
    pairs.append(list(map(int, input().split())))
pairs = pairs[::-1]

# rank保持のためにunionでrankを足し合わせる
# 島を数えるためにデフォルトのrank=1とする
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [1 for i in range(n)]

    def root(self, x):
        if (self.par[x]==x):
            return x
        else:
            # path compression
            self.par[x] = self.root(self.par[x])
            return self.par[x]

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

        if (x==y):
            return

        if (self.rank[x] < self.rank[y]):
            self.par[x] = y
            self.rank[y] += self.rank[x]
            self.rank[x] = 0
        else:
            self.par[y] = x
            self.rank[x] += self.rank[y]
            self.rank[y] = 0

    def find(self, x, y):
        return self.root(x)==self.root(y)
    
    def get_inconvenience(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x==y:
            return 0
        else:
            return self.rank[x] * self.rank[y]

uf = UnionFind(N)
inconvenience = [int(N*(N-1)/2)]
for m in range(M-1):
    inconvenience.append(inconvenience[-1] - uf.get_inconvenience(pairs[m][0]-1, pairs[m][1]-1))
    uf.union(pairs[m][0]-1, pairs[m][1]-1)

print(*inconvenience[::-1], sep='\n')


Measured memory_bytes: 38352
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

x1, y1, x2, y2 = gets_i_list

dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx

x4 = x3 - dx
y4 = y3 - dy


puts [x3,y3,x4,y4].join(" ")

Measured memory_bytes: 2300
#include<stdio.h>
int main(void){
	int a[101][101],b[101],c[101],n,m,i,j,sum;
	scanf("%d %d",&n,&m);
	for(i = 0;i < n;i++){
		for(j = 0;j < m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(i = 0;i < m;i++){
		scanf("%d",&b[i]);
	}
	for(i = 0;i < n;i++){
		sum = 0;
		for(j = 0;j < m;j++){
			sum += (a[i][j]*b[j]);
		}
		c[i] = sum;
	}
	for(i = 0;i < n;i++){
		printf("%d\n",c[i]);
	}
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <array>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


int main() {
	int n, k; CI n >> k;
	CO n - k + 1 EN;
}

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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<Edge>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}



bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int dfs(int x,int y,int H,int W,vector<vector<char>> &masu){
  if(masu[x][y] == '#'){

  }
}
bool palin(string S){
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
int main(){
  ll N,K;
  cin >> N >> K;
  ll ans = 0;
  if(K == 0){
    ans = N*N;
    cout << ans << endl;
    return 0;
  }
  for(int b = 1;b <=N;b++){
    if(b-1 >= K){
      ans += b-K;
      if(b >= K) ans += (N-b+1)/b * (b-K);
      int r = (N-b+1)%b;
      if(r -1 >= K) ans += r-K;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// F

#include <bits/stdc++.h>

using namespace std;

#define ge getchar()
#define Re read()

inline int read() {
	int x = 0, ch;
	while(!isdigit(ch = ge)) ;
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = ge;
	return x;
}

template<typename T>
inline void chkmax(T&a, T b) { a = a > b ? a : b; }
template<typename T>
inline void chkmin(T&a, T b) { a = a < b ? a : b; }

int res[3001];
int A[3001];
int B[3001];
int C[3001];
int len;
int p;

inline int ksm(int x, int k) {
	int s = 1;
	while(k) {
		if(k & 1) s = 1LL * s * x % p;
		x = 1LL * x * x % p; k >>= 1;
	} return s;
}

inline void Add(int a[], int b[], int m) {
	for(int i = 0; i < p; i++)
		a[i] = (a[i] + b[i] * m) % p;
}

inline void Div(int a[], int b[], int v) {
	int rt = 0;
	for(int i = len - 1; i; i--) {
		int ml = rt + a[i]; b[i - 1] = ml;
		a[i - 1] = (a[i - 1] + v * ml) % p;
	}
}

int main() {
	p = Re; A[1] = 1, len = 2;
	for(int i = 1; i < p; i++) {
		for(int j = len; j >= 1; j--) {
			A[j] = (-A[j] * i % p + p + A[j - 1]) % p;
		} ++len;
	}
	for(int i = 0; i < p; i++) {
		int a = Re, mul = 1;
		if(!a) continue;
		for(int j = 0; j < p; j++)
			if(i != j) mul = mul * (i - j + p) % p;
		mul = ksm(mul, p - 2);
		memcpy(C, A, sizeof(A));
		// for(int j = 0; j <= p; j++) cout << C[j] << ' '; cout << endl;
		Div(C, B, i);
		// for(int j = 0; j < p; j++) cout << B[j] << ' '; cout << endl;
		Add(res, B, mul);
	}
	for(int i = 0; i < p; i++) printf("%d ", res[i]); puts("");
	return 0;
}

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

int main() {
  int n,m;
  cin >> n>>m;
  vector<int>a(m),b(m),c(n,1);
  vector<bool>d(n);
  d[0]=true;
  rep(i,m){
    cin>>a.at(i)>>b.at(i);
    a.at(i)--;
    b.at(i)--;
    c[a.at(i)]--;
    c[b.at(i)]++;
    if(d[a.at(i)]){
      d[b.at(i)]=true;
      if(c[a.at(i)]==0){
        d[a.at(i)]=false;
      }
    }
  }
  int ans=0;
  rep(i,n){
    if(d.at(i)){
      ans++;
    }
  }
  cout<<ans<<endl;  
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b;
    cin >> a >> b ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;

    sort(vec.begin(), vec.end());
    //*/
    
    //Sunny, Cloudy, Rainy
    /*
    if( a < 10 && b < 10 ){
        cout << a * b << endl;
    } else {
        cout << -1 << endl;
    }
    //*/
    
    cout << a * (a - 1) / 2 + b * (b - 1) / 2 << endl;
    
    //printf("%lf\n", ((a / 2 + a % 2) / a));

    return 0; 
}


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

using namespace std;

int main(void) {
	string str,temp,ope;
	cin >> str;
	int noq,a,b; 
	cin >> noq;
	for (int q = 0; q < noq; ++q) {
		cin >> ope;
		cin >> a >> b;
		int noc = b-a+1;
		if (ope == "print") {
			for (int i = a; i < b+1; ++i) {
				cout << str[i];
			}
			cout << endl;
		}
		else if (ope == "reverse") {
			for (int i = 0; i < noc/2; ++i) {
				swap(str[a+i],str[b-i]);
			}
		}
		else {
			cin >> temp;
			for (int i = 0; i < noc; ++i) {
				str[a+i] = temp[i];
			}
		}
	}
	return 0;
}



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

int n, m;
string s[200], t[200];
int res = 0;

int main(){
  cin >> n;
  rep(i, n) cin >> s[i];
  cin >> m;
  rep(i, m) cin >> t[i];
  for(string x : s){
    int sn = 0, tn = 0;
    rep(i, n){
      if(s[i] == x){
        sn++;
      }
    }
    rep(i, m){
      if(t[i] == x){
        tn++;
      }
    }
    int tmp = max(0, sn - tn);
    res = max(tmp, res);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  string s,t;cin>>s>>t;
  vector<vector<int>> dp(s.size()+1,vector<int>(t.size()+1,0));
  rep(i,s.size()){
    rep(j,t.size()){
      if(s[i] == t[j])dp[i+1][j+1] = dp[i][j]+1;
      else dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
    }
  }

  int len = dp[s.size()][t.size()];
  int i = s.size()-1;
  int j = t.size()-1;
  string ans(len,' ');

  while(len>0){
    if(s[i] == t[j]){
      ans[--len] = (i>=0)?s[i]:t[j];
      i--;
      j--;
    }else if(dp[i+1][j+1] == dp[i][j+1]){
      i--;
    }else{
      j--;
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 38584
#include<stdio.h>
#include<string.h>




#define M 1000000
#define L 14

char H[M][L];

int getC(char c){

  if ( c == 'A') return 1;
  else if ( c == 'C') return 2;
  else if ( c == 'G') return 3;
  else if ( c == 'T') return 4;

  return 0;

}

long long getK(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getC(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){
  int key, i, h;
  key = getK(str);
  for(i = 0 ; ; i++){
    h = (h1(key) + i * h2(key))%M;
    if(strcmp(H[h], str) == 0 ) return 1;
    else if(strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[]){
  int key, i, h;
  key = getK(str);
  for(i = 0 ; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0 ) return 1;
    else if(strlen(H[h]) == 0 ){
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

  int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';

    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
      scanf("%s %s", com, str);

      if ( com[0] == 'i' ){
        insert(str);
      } else {
        if (find(str)){
          printf("yes\n");
        } else {
          printf("no\n");
        }
      }
    }

    return 0;
  }



Measured memory_bytes: 15384
#include <iostream>
using namespace std;
int main(){
 int h,m,s,S,a,b,c,d;
 h=m=s=S=a=b=c=d=0;
 cin>>S;
 if(3600<=S){
  a=S/3600;
  b=S%3600;
  S=b;
  h=a;
 }
 if(60<=S){
  c=S/60;
  d=S%60;
  m=c;
  s=d;
 }else{
  s=S;
 }
 
 cout<<h<<":"<<m<<":"<<s<<endl;
 return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int hmax, num = 0;
  int tmp;
  
  for(int i=0; i<N; i++) {
    cin >> tmp;
    if (hmax<=tmp) {
      hmax = tmp;
      num++;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
N,K,Q = gets.split(' ').map(&:to_i)
A = Q.times.map{gets.to_i}

points = Array.new(N,K-Q)

Q.times do |i|
	points[A[i] - 1] += 1	
end

N.times do |ans|
	if points[ans] > 0
		puts 'Yes'
	else
		puts 'No'
	end
end



Measured memory_bytes: 15996
#include <stdio.h>

int main(void){

  int n,x;
  scanf("%d %d", &n, &x);
  int m[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &m[i]);
  }
  int sum = 0;
  int min = 1000;
  for (int i = 0; i < n; i++) {
    sum += m[i];
    if (m[i] < min) {
      min = m[i];
    }
  }
  int answer = n+(x-sum)/min;
  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 128
import bisect
MOD = 10**9+7
n, m = map(int, input().split())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
setA = set(A)
setB = set(B)
if n != len(setA) or m != len(setB):
  print(0)
else:
  ans = 1
  for i in range(n*m, 0, -1):
    if i in setA and i in setB:
      continue
    if i in setA:
      count = m - bisect.bisect_left(B, i)
    elif i in setB:
      count = n - bisect.bisect_left(A, i)
    else:
      count = (n - bisect.bisect_left(A, i)) * (m - bisect.bisect_left(B, i))
      count -= n*m-i
    ans *= count
    ans %= MOD
  print(ans)

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

const int mod = 1e9+7;
const int N = 10000003;
int prime[N];
unordered_map <ll, ll> max_map;

ll power(ll x, ll y){
	x %= mod;
	if(y == 0) return 1;
	if(y == 1) return x;
	ll num = power(x,y/2) % mod;
	if(y%2 ==  0) return (num*num)%mod;
	else return (((num*num)%mod)*x)%mod;
}

void solve(){
 	
 	int a,b;
 	cin >> a >> b;
 	cout << 6-a-b;

	return;
}


int main(){

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

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		solve();
		// cout << "\n";
	}

	// cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 256
function main()
  
  A = zeros(Int,3,3)
  check = zeros(Int,3,3)
  
  for i in 1:3
    (A[i,:]) = map(x -> parse(Int,x), split(readline()))
  end
  
  N = parse(Int,readline())
  
  for i in 1:N
    
    b = parse(Int,readline())
    
    for i in 1:3, j in 1:3
      if A[i,j] == b
        check[i,j] += 1
      end
    end
    
  end
  
  if check[1,1] == check[1,2] == check[1,3] == 1 || check[2,1] == check[2,2] == check[2,3] == 1 || check[3,1] == check[3,2] == check[3,3] == 1
    println("Yes")
  elseif check[1,1] == check[2,1] == check[3,1] == 1 || check[1,2] == check[2,2] == check[3,2] == 1 || check[1,3] == check[2,3] == check[3,3] == 1
    println("Yes")
  elseif check[1,1] == check[2,2] == check[3,3] == 1 || check[1,3] == check[2,2] == check[3,1] == 1
    println("Yes")
  else
    println("No")
  end
  
end

main()

Measured memory_bytes: 115668
// In The Namw Of Allah
#include <bits/stdc++.h>
using namespace std;

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

const int N = 1e6 + 10, mod = 1e9 + 7;

int x[N], y[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		ll t;
		cin >> t;
		--t;
		x[t] = 1;
	}
	for (int i = 0; i < m; i++) {
		ll t;
		cin >> t;
		--t;
		y[t] = 1;
	}
	ll ans = 1, nx = 0, ny = 0;
	for (int i = n * m - 1; ~i; i--) {
		if(!x[i] && !y[i])	{
			if(nx * ny - (n * m - i - 1) <= 0)	return cout << "0\n", 0;
			ans *= ((nx * ny - (n * m - i - 1)) % mod);
			ans %= mod;
		}
		else if(!x[i]) {
			if(ny == 0)	return cout << "0\n", 0;
			ans *= ny;
			nx++;
			ans %= mod;
		}
		else if(!y[i]) {
			if(nx == 0)	return cout << "0\n", 0;
			ans *= nx;
			ny++;
			ans %= mod;
		}
		else	nx++, ny++;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define int long long
signed main(signed argc, char* argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	int before=1e9+7,ans=0;
	rep(i,n){
	    int a;
	    cin>>a;
	    if(before<a)ans++;
	    before=a;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 3184
read
while read t1 x1 y1; do
    (( d = (t1 - t2) - (x1 > x2 ? x1 - x2 : x2 - x1) - (y1 > y2 ? y1 - y2 : y2 - y1),
       d < 0 || d % 2 )) && echo No && exit
    read t2 x2 y2 || break
    (( d = (t2 - t1) - (x1 > x2 ? x1 - x2 : x2 - x1) - (y1 > y2 ? y1 - y2 : y2 - y1),
       d < 0 || d % 2 )) && echo No && exit
done < <(tail -n 50000)
echo Yes


Measured memory_bytes: 692
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#include<bits/stdc++.h>

using namespace std;
int main() {
 int a,b,ans=0,tmp;
 cin>>a>>b;
 ans+=max(a,b);
 tmp=max(a,b)-1;
 if(tmp>min(a,b))
    ans+=tmp;
 else
    ans+=min(a,b);
 cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {     
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    vector<int> dup;
    for (int i = 1; i < n; i++) {
        if (v[i] == v[i - 1]) {
            dup.push_back(v[i]);
        }
    }
    if (dup.size() % 2 == 0) {
        cout << n - dup.size() << endl;
    } else {
        cout << n - dup.size() - 1 << endl;
    }
}




Measured memory_bytes: 4320
open Batteries
open BatPrintf

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> String.split_on_char ' '
  |> List.map cnv

let scan_listn n cnv =
  (0 --^ n) |> Enum.map (fun _ -> (cnv % read_line) ())

let bsearch_ge arr a =
  let l = Array.length arr in
  match Array.bsearch Int.ord arr a with
  | `All_lower -> l
  | `All_bigger -> 0
  | `Just_after n -> l - n -1
  | `At n -> l - n
  | `Empty -> 0

let rec zip xs ys =
  match xs, ys with
  | [], _ -> []
  | _, [] -> []
  | x::xs, y::ys ->
    (x, y) :: zip xs ys

let n = scan "%d" identity
let xs = scan_list Int.of_string

let () =
  let half = (List.sum xs) / n in
  let half2 = (List.sum xs) / n + 1 in
  let n = List.sum @@ List.map (fun n -> let k = n - half in k*k) xs in
  let m = List.sum @@ List.map (fun n -> let k = n - half2 in k*k) xs in
  printf "%d" @@ min n m


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ii {
    ll a, b;
    bool operator < (ii o) const {
        return tie(a, b) < tie(o.a, o.b);
    }
};
struct iii {
    ll a, b, c;
    bool operator < (iii o) const {
        return tie(a, b, c) < tie(o.a, o.b, o.c);
    }
};

const ll MOD = 1000000007;
const ll INF = 1000000000;
const ll MAXN = 2000005;
const ll MAX = 40;
const double EPS = 1e-6;

ll N;
ll arr[MAXN], fact[43][43];

ll cntDiv(ll n, ll div) {
    ll cnt = 0;
    while (n%div == 0) {
        n /= div;
        cnt++;
    }
    return cnt;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    cin >> N;
    for (ll i = 0; i < N; i++) {
        double x;
        cin >> x;
        arr[i] = x*INF + 0.5;
    }
    
    for (ll i = 0; i < N; i++) {
        ll f2 = cntDiv(arr[i], 2);
        ll f5 = cntDiv(arr[i], 5);
        fact[f2][f5]++;
    }
    
    ll ans = 0;
    for (ll i = 0; i < MAX; i++) {
        for (ll j = 0; j < MAX; j++) {
            for (ll k = 0; k < MAX; k++) {
                for (ll l = 0; l < MAX; l++) {
                    if (i + k >= 18 && j + l >= 18) {
                        if (i == k && j == l) ans += fact[i][j] * (fact[i][j] - 1);
                        else ans += fact[i][j] * fact[k][l];
                    }
                }
            }
            //~ cerr << i << " " << j << " " << ans << "\n";
        }
    }
    ans /= 2;
    cout << ans << "\n";
    
}


Measured memory_bytes: 5328
if __name__ == "__main__":
    n, w_size = map(int, input().split())
    v = []
    w = []
    for _ in range(n):
        vi, wi = map(int, input().split())
        v.append(vi)
        w.append(wi)
    
    dp = [[0] * (w_size + 1)] * n

    for i in range(1, w_size + 1):
        dp[0][i] = v[0] * (i // w[0])
    
    for i in range(1, n):
        for j in range(1, w_size + 1):
            dp[i][j] = dp[i-1][j]
            if j - w[i] >= 0:
                dp[i][j] = max(dp[i][j], dp[i][j-w[i]] + v[i])
    print(dp[n-1][w_size])


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

#ifdef LOCAL
	#define de(x) cout<<#x<<"="<<x<<endl
	#define rff freopen("input.txt","r",stdin)
	#include "Debug.h"
#else
	#define de(x)
	#define rff
#endif

#define itr(x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define PQ priority_queue
#define pii pair<int,int>
#define vi vector <int>
#define ll long long
#define pb push_back
#define mp make_pair
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=+3;

int n;
vi g[1003];

void solve(){
	int INDEX=1;
	For(i,n){
		for (int j=i+1;j<=n;j++){
			g[i].pb(INDEX);
			g[j].pb(INDEX);
			INDEX++;
		}
	}
	cout<<"Yes"<<endl<<n<<endl;
	For(i,n){
		cout<<n-1<<" ";
		for (int j:g[i]){
			cout<<j<<" ";
		}
		cout<<endl;
	}
	exit(0);
}

int main(){
	cin>>n;
	For(i,1000){
		if (i*(i+1)/2==n){
			n=i+1;
			solve();
		}
	}
	cout<<"No";
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 3005;

LL res[N][N], sum[N][N];
int i, j, tab[N], n;

LL get(int a, int b) {
	if (res[a][b] != -1) return res[a][b];
	if (a == b) {
		res[a][b] = tab[a];
		return res[a][b];
	}
	res[a][b] = sum[a][b] - min(get(a + 1, b), get(a, b - 1));
	return res[a][b];
}

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) scanf("%d", &tab[i]);
for (i=0;i<n;i++) for (j=i;j<n;j++) res[i][j] = -1;
for (i=0;i<n;i++) {
	sum[i][i] = tab[i];
	for (j = i + 1; j < n;j++) sum[i][j] = sum[i][j - 1] + tab[j];
}
printf("%lld\n", -sum[0][n - 1] + 2 * get(0, n - 1));
return 0;
}

Measured memory_bytes: 139904
#include <stdio.h>

int main ()
{
	int a,b,c;
	scanf ("%d %d %d",&a,&b,&c);
	int sum12 = a+b;
	int sum13 = a+c;
	int sum23 = b+c;
	if (sum12<=sum13 && sum12<=sum23)
	{
		printf("%d",sum12);
	}
	else if (sum13<sum12 && sum13<sum23)
	{
		printf("%d",sum13);
	}
	else if (sum23<sum12 && sum23<sum13)
	{
		printf("%d",sum23);
	}
}

Measured memory_bytes: 128
//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W
 
 
#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
#include<bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
#include <map>
#include <string>
#define mi(lol) map<ll,ll>lol
#define fsort(vec) sort(vec.begin(),vec.end())
#define rsort(vec) sort(vec.begin(),vec.end(),compare)
#define inf ll inf=INT_MAX
//sorting according to the second element vector 
 
bool compare(pair<ll,ll> p,pair<ll,ll> q){
	return p.second < q.second;	
}
 
//   example:-
//   sort(vec.begin(),vec.end(),compare);
 
 
int main() {
	fast;
  	read(a)
  	ll sum=0;
  	loop(j,1,a+1){
  		if(j%3==0 && j%5==0) {continue;}
  		else if(j%3==0) continue;
  		else if(j%5==0)continue;
  		else sum+=j;
  	}
  	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define _D(p) std::cout<<"L"<<__LINE__<<" : " #p " = "<<(p)<<std::endl;
#define _D2(p,q) std::cout<<"L"<<__LINE__<<" : " #p " = "<<(p) << ", " #q " = "<<(q)<<std::endl;
#define _DN(v) std::cout<<"L"<<__LINE__<<" : " #v " = ["; rep(i,(v).size()) {std::cout<<v[i]<<(i==v.size()-1?"":", ");}std::cout<<"]"<<std::endl;
#define _DNN(v) std::cout<<"L"<<__LINE__<<" : " #v " = [" << std::endl; rep(i,(v).size()) {std::cout<<"    [";rep(j,(v)[0].size()){std::cout<<v[i][j]<<(j==v[0].size()-1?"":", ");}std::cout<<"],"<<std::endl;}std::cout<<"]"<<std::endl;
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    bool f = false;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '9') {
            f = true;
            break;
        }
    }
    if (f) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
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;}
const int MOD = 1000000007;

void solve() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> v(m);
  rep(i,m) cin >> v[i].first >> v[i].second;
  int l = 1;
  int r = n;
  rep(i,m) {
    l = max(l, v[i].first);
    r = min(r, v[i].second);
  }
  cout << max(0, r - l + 1) << endl;
}

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

Measured memory_bytes: 3952