akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> // Include every standard library
using namespace std;
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed << setprecision(n)
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;

const int maxsize= 1e5+5;
vi graph[maxsize];
bool visited[maxsize];
int deg[maxsize]; //deg[v]= no of edges going into node v. 
int dist[maxsize];

void dfs(int v) {
    visited[v] = true;
    for (int a : graph[v]) {
        dist[a] = max(dist[a], dist[v] + 1);
        deg[a]--;
        if(deg[a]==0)
            dfs(a);
    }
}

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    while (m--){
        int x,y;
        scanf("%d%d", &x, &y);
        graph[x].pb(y);
        deg[y]++;
    }
    for (int a = 1; a <=n; a++) {
        if (!visited[a] && deg[a] == 0)
            dfs(a);
    }
    int res = 0;
    for (int a = 1; a <= n; a++)
        res = max(res, dist[a]);
    printf("%d", res);
}


Measured memory_bytes: 14716
#include<bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<typename T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<typename T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T> T Min(T a, T b) { return a > b ? b : a; }
template<typename T> T Max(T a, T b) { return a < b ? b : a; }
template<typename T> void de(T a){ 
#ifdef LOCAL_DEFINE
	cout<< a << endl;
#endif
}	
const int INF = 2e5+1;
const int mod = 1e9+7;
         	
void solve(){
	int a,b;
	cin>>a>>b;
	a--;
	fore(i,Max(b-a,-1000000),Min(b+a,1000000)) cout<<i<<" ";
	cout<<endl;
}
 
 
int main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    	cout.precision(10);
    	cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
	freopen("output.txt","w",stdout);
#endif  
        int q=1;
#ifdef LOCAL_DEFINE
        cin>>q;
#endif
        while(q--){
         	solve();
        }
 
#ifdef LOCAL_DEFINE
         
             
        cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif
 
	return 0;
}	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <climits>
using namespace std;
typedef long long ll;
int main(void){
    int n,ans = 0;
    cin >> n;
    vector<int> v(n),c(n);
    for(int i = 0;i < n;i++) cin >> v[i];
    for(int i = 0;i < n;i++) cin >> c[i];
    for(int i = 0;i < n;i++){
        if(v[i]-c[i] > 0) ans += (v[i]-c[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
d={0:1}
suf=0
pot=1
ans=0
for i in range(len(s)-1,-1,-1):
    dig=int(s[i])
    suf=(suf+dig*pot)%2019
    pot=(pot*10)%2019
    if suf in d:
        ans+=d[suf]
        d[suf]+=1
    else:
        d[suf]=1
print(ans)

Measured memory_bytes: 9360
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    int n,s=0;
    cin >> n;
    int w[n];
    rep(i,n){
        cin >> w[i];
        s+=w[i];
    }
    vector<int> v;
    rep(i,n-1){
        s -= 2*w[i];
        v.push_back(abs(s));
    }
    sort(v.begin(),v.end());
    cout << v.at(0) << endl;
    
}

Measured memory_bytes: 256
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int main()
{
	LL a, b, c;
	scanf("%lld %lld %lld", &a, &b, &c);
	int cnt = 0;
	while (!((a & 1) || (b & 1) || (c & 1))) {
		int x = b / 2 + c / 2;
		int y = a / 2 + b / 2;
		int z = c / 2 + a / 2;
		a = x, b = y, c = z;
		cnt++;
		if (cnt >= 1000000) break;
	}
	if (cnt >= 1000000) printf("-1\n");
	else printf("%d\n", cnt);
	return 0;
}


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

typedef long long ll;

int main(){
    ll N; cin >> N;
    vector<string> S(N);
    vector<ll> c(5);
    for(int i=0; i<N; i++){
        cin >> S[i];
        if(S[i][0]=='M')
            c[0]++;
        else if(S[i][0]=='A')
            c[1]++;
        else if(S[i][0]=='R')
            c[2]++;
        else if(S[i][0]=='C')
            c[3]++;
        else if(S[i][0]=='H')
            c[4]++;
    }
    
    ll ans=0;
    ans += c[0]*c[1]*c[2];
    ans += c[1]*c[2]*c[3];
    ans += c[2]*c[3]*c[4];
    ans += c[0]*c[1]*c[3];
    ans += c[0]*c[1]*c[4];
    ans += c[1]*c[2]*c[4];
    ans += c[0]*c[3]*c[4];
    ans += c[0]*c[2]*c[3];
    ans += c[1]*c[3]*c[4];
    ans += c[0]*c[2]*c[4];
    
    cout << ans << endl;
}


Measured memory_bytes: 6144
#include <stdio.h>
#include <string.h>
int lcs(char *,char*);
int main(){
  int num,i;
  char carray1[1001],carray2[1001];
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%s",carray1);
    scanf("%s",carray2);
    printf("%d\n",lcs(carray1,carray2));
  }
  return 0;
}
int lcs(char * carray1, char * carray2){
  int array[1001][1001];
  int length1,length2,i,j;
  length1=strlen(carray1);
  length2=strlen(carray2);
 
  for(i=0;i<=length1;i++) array[i][0]=0;
  for(j=1;j<=length2;j++) array[0][j]=0;
  for(i=1;i<=length1;i++){
    for(j=1;j<=length2;j++){
      if(carray1[i-1]==carray2[j-1]) array[i][j]=array[i-1][j-1]+1;
      else if(array[i-1][j]>=array[i][j-1]) array[i][j]=array[i-1][j];
      else array[i][j]=array[i][j-1];
    }
  }
  return array[i-1][j-1];
}



Measured memory_bytes: 5652
#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>
#include <random>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define endl '\n'

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7;
const int MAXN = static_cast<int>(1e6) + 17;

int n;
int a[MAXN];
vector< pair<ll, int> > kek;

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n)
        cin >> a[i];

    return true;
}

void solve() {
    map<int, ll> kok;

    forn (i, n)
        kok[i + 1] = a[i];

    ll all = 0;

    for (auto i : kok) {
        kek.push_back(make_pair(i.second, i.first));
        all += i.second;
    }

    sort(kek.begin(), kek.end());
    int ans = 1;
    n = sz(kek);
    all -= kek[n - 1].first;

    for (int i = n - 2; i >= 0; --i) {
        if (2ll * all >= kek[i + 1].first) {
            ++ans;
            all -= kek[i].first;
        } else {
            break;
        }
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 9080
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int n;
    cin >> n;
    int a, b, c;
    a = n/100;
    b = (n%100)/10;
    c = n%10;
    if(b <= a && c <= a){
    } else {
        a++;
    }
    cout << a << a << a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>
#include <iomanip>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main() {
	for (int a, b, n; cin >> a >> b >> n; ) {
		int d = a % b;
		int sum = 0;
		rep(i, n) {
			d *= 10;
			sum += d / b;
			d %= b;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a[100];
	int n,l;
	cin>>n>>l;
	for (int i=0;i<n;i++) cin>>a[i];
	for (int j=0;j<l;j++) sort (a,a+n);
	for (int k=0;k<n;k++) cout<<a[k];
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;

int main() {

  int n;
  cin >> n;
  vector<tuple<string,int,int>> t;
  for(int i = 1; i < n+1; i++) {
    string s;
    int p;
    cin >> s >> p;
    p = -p;
    t.push_back(tie(s,p,i));
  }

  sort(t.begin(), t.end());
  for(int i = 0; i < n; i++) {
    cout << get<2>(t[i]) << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18



int main(){
    int N,M; cin >> N >> M;
    vector<vector<int>> S(M);
    rep(i,M){
        int k;
        cin >> k;
        rep(j,k){
            int s; cin >> s;
          	s--;
            S[i].push_back(s);
        }
    }
    vector<int> p(M);
    rep(i,M) cin >> p[i];

    //bit全探索
    int ans = 0;
    rep(bit,1<<N){
        bool ok = true;
        rep(i,M){
            int cnt = 0;
            rep(j,S[i].size()){
                if(bit & 1<<S[i][j]) cnt++;
            }
            if(cnt % 2 != p[i]) ok = false;
        }
        if(ok) ans++;
    }
    cout << ans << endl;
}



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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=105,MOD=1e9+7;
inline int pow_mod(int x,int i){int y=1;while(i){if(i&1)y=(ll)y*x%MOD;x=(ll)x*x%MOD;i>>=1;}return y;}
int n,h[MAXN];
vector<int>vec,w[MAXN];
int solve1(int l,int r,int k,int low){
	//cout<<"dp1 "<<l<<" "<<r<<" "<<k<<endl;
	int mx=0,mn=2e9;
	for(int i=l;i<=r;++i)mx=max(mx,h[i]),mn=min(mn,h[i]);
	if(mn>k)return solve1(l,r,mn,low);
	if(mx==k&&mx==mn)return pow_mod(2,vec[k]-low);
	
	int ans=1,st=lob(w[k].begin(),w[k].end(),l)-w[k].begin(),ed=lob(w[k].begin(),w[k].end(),r)-w[k].begin();
	ed=min(ed,(int)w[k].size()-1);
	if(w[k][ed]>r)ed--;
	int lst=l,t=0;
	
	for(int i=st;i<=ed;++i){
		assert(w[k][i]>=l&&w[k][i]<=r);
		t=1;
		if(lst<=w[k][i]-1)ans=(ll)ans*solve1(lst,w[k][i]-1,k+1,vec[k])%MOD;
		lst=w[k][i]+1;
	}
	if(lst<=r)ans=(ll)ans*solve1(lst,r,k+1,(!t)?low:vec[k])%MOD;
	if(t)ans=(ll)ans*pow_mod(2,vec[k]-low)%MOD;
	return ans;
}
int solve2(int l,int r,int k,int low){
	//cout<<l<<" "<<r<<" "<<k<<endl;
	int mx=0,mn=2e9;
	for(int i=l;i<=r;++i)mx=max(mx,h[i]),mn=min(mn,h[i]);
	if(mn>k)return solve2(l,r,mn,low);
	if(mx==k&&mx==mn)return (pow_mod(2,r-l+1)-2+pow_mod(2,vec[k]-low))%MOD;
	
	int st=lob(w[k].begin(),w[k].end(),l)-w[k].begin(),ed=lob(w[k].begin(),w[k].end(),r)-w[k].begin();
	ed=min(ed,(int)w[k].size()-1);
	if(w[k][ed]>r)ed--;
	vector<int>dp1,dp2;
	int lst=l,t=0;
	for(int i=st;i<=ed;++i){
		assert(w[k][i]>=l&&w[k][i]<=r);
		t++;
		if(lst<=w[k][i]-1)dp1.pb(solve1(lst,w[k][i]-1,k+1,vec[k])),dp2.pb(solve2(lst,w[k][i]-1,k+1,vec[k]));
		lst=w[k][i]+1;
	}
	if(lst<=r)dp1.pb(solve1(lst,r,k+1,(!t)?low:vec[k])),dp2.pb(solve2(lst,r,k+1,(!t)?low:vec[k]));
	int ans1=1,ans2=1;
	for(int i=0;i<(int)dp1.size();++i)ans1=(ll)ans1*(dp1[i]+dp2[i])%MOD,ans2=(ll)ans2*dp1[i]%MOD;
	ans1=(ll)ans1*pow_mod(2,t)%MOD;
	if(t)ans2=(ll)ans2*(pow_mod(2,vec[k]-low)-2)%MOD;
	return (ans1+ans2)%MOD;
}
int main() {
	n=read();
	for(int i=1;i<=n;++i)h[i]=read(),vec.pb(h[i]);
	vec.pb(0);
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	for(int i=1;i<=n;++i)h[i]=lob(vec.begin(),vec.end(),h[i])-vec.begin(),w[h[i]].pb(i);
	cout<<solve2(1,n,1,0)<<endl;
	return 0;
}

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

//	LLONG_MAX 9.2*1e18	9223372036854775807LL = (2^63)-1
//	INT_MAX 2.1*1e9 2147483647 = (2^31)-1
//	O(1e8) 1.2sec

void Main()
{
	ll X,K,D;
	cin>>X>>K>>D;
	X=abs(X);
	if(K<=abs(X/D)){
		cout<<abs(X-D*K)<<_n;
		return;
	}

	if(K%2==(X/D)%2)cout<<abs(X%D)<<_n;
	else cout<<abs(X%D-D)<<_n;
}


void Test();
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>

#define fr(i,n) for(int i = 0; i < n ;i++)
using namespace std;

int main(void)
{
  int n;
  cin >> n;
  int w[n];
  fr(i,n)
    cin >> w[i];
  int min = 1000000;
  fr(i,n - 1){
    int s1 = 0;
    int s2 = 0;
    fr(j,i + 1)
      s1 += w[j];
    for(int j = i + 1; j < n;j++){
      s2 += w[j];
    }
    int diff;
    if(s1 > s2)
      diff = s1 - s2;
    else
      diff = s2 - s1;
    if(min > diff)
      min = diff;
  }
  cout << min;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
import numpy as np
# n = int(input())
# a, b = map(int, input().split())
# int_list = list(map(int, input().split()))
# l = list(input().split())

def solve():
    n, k = map(int, input().split())
    v_list = list(map(int, input().split()))

    temoti_max = 0
    for i in range(k+1):
        for j in range(min(k+1-i, n-i+1)):
            #print(v_list)
            temoti_list = []
            temoti_list +=  v_list[:i]
            #print(i, j)
            #print(temoti_list)
            temoti_list += v_list[n-j:]
            #print(temoti_list)
            temoti_list.sort()
            #print(temoti_list)

            temoti = sum(temoti_list)
            for iret in range(min(len(temoti_list), k-i-j)):
                if temoti_list[iret] < 0:
                    temoti -= temoti_list[iret]

            if temoti_max <= temoti:
                temoti_max = temoti

    print(temoti_max)

solve()

Measured memory_bytes: 12508
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007
    #define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
    #define GCD(m,n) __gcd(m,n)
    #define LCM(m,n) m*(n/GCD(m,n))
    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    #define REVERSE(v) reverse(ALL(v))
    #define display(x) trav(a,x) cout<<a<<" ";cout<<endl
    #define debug cerr<<"bhau"<<endl
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        std::cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}
    void amax(int &a,int b){a=max(a,b)%M; }
    void amin(int &a,int b){ a=min(a,b)%M;}
    void inc(int &a,int b){a=(a+b)%M;}
    void dec(int &a,int b){a=(a-b+M)%M;}


    
     int solve()
     {  
        int n;cin>>n;
        vi a(n);
        inputarr(a,n);
        int sum=0;
        rep0(n){
          repi(j,i+1,n) sum+=a[i]*a[j];
        }
        cout<<sum;  

        r0   
     }
    signed main()
    {   
        asdf
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define sz(x) ((int) x.size())
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {sws;

    ll n, d;
    cin >> n >> d;

    int ans = 0;
    fo(i, n) {
        ll x, y;
        cin >> x >> y;
        if ( d * d >= x * x + y * y ) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a, b;
  cin >> a >> b;
  vector<int> x(5);
  int ans = 0;
  for(int i = a; i <=b; i++){
    x[0] = i % 10;
    x[1] = i/10 % 10;
    x[2] = i/100 % 10;
    x[3] = i/1000 % 10;
    x[4] = i/10000 % 10;
    if(x[0] == x[4] && x[1] == x[3]){
      ans++;
    }
  }
  cout << ans << endl;
}

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

#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}
void input(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}

void swap(int& a, int& b){
	int t=a;
	a = b;
	b = t;
}


void solveTest(){
	int n;
	cin>>n;
	vector<pair<int,int>> vp;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		vp.push_back(make_pair(x,i));
	}
	sort(vp.begin(),vp.end());
	for(auto i: vp){
		cout<<i.second<<" ";
	}
	return ;
}

int main(){
	fastio();
	//input();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();

	}
	
	return 0;
}


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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define FI ios_base::sync_with_stdio(0); cin.tie(NULL);

#define LL long long

const int MOD = 1e9 + 7;
const int INF = 1e9 + 9;
const int MX = 1e5 + 5;

int main() {
	string s;
	cin >> s;

	if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
		cout << 3 << endl;
		return 0;
	}
	if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) {
		cout << 2 << endl;
		return 0;
	}
	if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
		cout << 1 << endl;
		return 0;
	}
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {
  public static void Main (string[] args) {
    var list = Console.ReadLine().Split(' ').Select(long.Parse);
    var a = list.ElementAt(0);
    var b = list.ElementAt(1);

    if(a < b){
      var t = a;
      a = b;
      b = t;
    }
    for(var i = 0; i < a; i++){
      Console.Write(b);
    }
    Console.WriteLine("");
 
  }

}


Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
    string s;
    cin>>s;
    map<string,string> mp;
    mp["Sunny"]="Cloudy";
    mp["Cloudy"]="Rainy";
    mp["Rainy"]="Sunny";
    cout<<mp[s]<<endl;
}

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

int main(void)
{
  bool cups[] = { true, false, false };
  char buf_commma;
  char from, to;
  while (true)
  {
    cin >> from >> buf_commma >> to;
    if (cin.eof() ) break;
    if (cups[from - 65] ^ cups[to - 65])
    {
      cups[from - 65] = !cups[from - 65];
      cups[to - 65] = !cups[to - 65];
    }
  }
  cout << (cups[0] ? 'A' : cups[1] ? 'B' : 'C') << endl;
  return 0;
}

Measured memory_bytes: 1132
#define TCI ll t;cin>>t;while(t--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define cinl for(int i=0;i<n;i++)
#define vpair vector< pair <ll,ll> >
#define vll vector<ll>
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ll n,f=0;
    cin>>n;
    for(;n!=0;n/=10)
    {
        ll x=n%10;
        if(x==7)
        {
            f=1;
            break;
        }
    }
    if(f)
    cout<<"Yes";
    else
    cout<<"No";
}


Measured memory_bytes: 3620
program histogram_coloring
  implicit none
  type pair
    integer(8) :: x, y
  end type
  integer(8), parameter :: md = 1000000007_8
  integer :: n, h(100) = 0
  type(pair) :: p
  read(*,*) n
  read(*,*) h(1:n)
  p = solve(h(1:n))
  write(*,'(i0)') p%y
contains
  recursive function solve(h) result(ret)
    integer, intent(in) :: h(:)
    integer :: m, x(size(h)+1)
    integer :: n, i, j, w
    integer(8) :: dp1, dp2
    type(pair) :: ret, tmp
    n = size(h)
    m = minval(h)
    x(1:n) = h-m
    x(n+1) = 0
    w = n
    dp1 = 1_8
    dp2 = 1_8
    i = 0
    do while (i <= n)
      j = i+1
      do while (x(j) /= 0)
        j = j+1
      end do
      if (i+1 <= j-1) then
        tmp = solve(x(i+1:j-1))
        dp1 = mod(dp1*tmp%x,md)
        dp2 = mod(dp2*(tmp%x+tmp%y),md)
        w = w-(j-i-1)
      end if
      i = j
    end do
    ret%x = mod(dp1*pow(2_8,m),md)
    ret%y = modulo(mod(dp2*pow(2_8,w),md)+mod(dp1*(pow(2_8,m)-2_8),md),md)
  end
  function pow(a,b) result(r)
    integer(8), intent(in) :: a
    integer, intent(in) :: b
    integer(8) :: r, p
    integer :: k
    r = 1_8
    p = a
    k = b
    do while (k > 0)
      if (btest(k,0)) r = mod(r*p,md)
      p = mod(p*p,md)
      k = rshift(k,1)
    end do
  end
end program histogram_coloring

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define x first
#define pb push_back
#define y second
const int NMAX=100666;
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;

int n,a,pred,l;
bool q;

int main()
{
    //freopen("input.in", "rt", stdin);
    cin>>n>>l;
    pred=-1;
    for(int i=1; i<=n; ++i)
    {
        cin>>a;
        if(pred!=-1){
            if(a+pred>=l)
            {
                cout<<"Possible\n";
                for(int j=1; j<=i-2; ++j)
                    cout<<j<<"\n";
                for(int j=n-1; j>=i; --j)
                    cout<<j<<"\n";
                cout<<i-1<<"\n";
                return 0;
            }
        }
        pred=a;
    }
    cout<<"Impossible";
    return 0;
}


Measured memory_bytes: 768
def main():

    n = int(input()) 
    verdict = []
    for i in range(n):
        verdict.append(input())
        # AC, WA, TLE, and RE

    print('AC' , 'x' , verdict.count('AC'))
    print('WA' , 'x' , verdict.count('WA'))
    print('TLE' , 'x' , verdict.count('TLE'))
    print('RE' , 'x' , verdict.count('RE'))


if __name__ == "__main__":
    main()



Measured memory_bytes: 16176
var
 a:string;
 i,s,x,y:longint;
begin
 read(a);
 for i:=1 to length(a) do 
 if x=y then 
  begin 
   x:=x+1;
   if a[i]='p' then dec(s);
  end
  else 
   begin
    y:=y+1;
    if a[i]='g' then inc(s);
   end;
 writeln(s);
 end.

Measured memory_bytes: 256
import math
import numpy as np

n,k=(int(x) for x in input().split())
a = [int(x) for x in input().split()]


for _ in range(k):
    new_a = np.zeros(n+1,dtype=int)
    np.add.at(new_a, np.maximum(0,np.arange(0, n)-a), 1)
    np.add.at(new_a, np.minimum(n,np.arange(0, n)+a+1), -1)
    a = new_a.cumsum()[:-1]
    if np.all(a==n):
        break

print(" ".join([str(x) for x in a]))

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

int main() {

  int A[128][128];
  int n, m;
  int V[128];
  int temp;

  std::cin >> n >> m;
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < m; ++j) {
      std::cin >> A[i][j];
    }
  }

  for(int i = 0; i < m; ++i) {
    std::cin >> V[i];
  }

  for(int i = 0; i < n; ++i) {
    temp = 0;
    for(int j = 0; j < m; ++j) {
      temp += A[i][j] * V[j];
    }
    std::cout << temp << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <sstream>

using namespace std;


string IntToString(int number) {

  ostringstream ss;

  ss << number;

  return ss.str();

}

int main() {

  int n;
  string seq;

  string prev_seq;
  char prev_char;
  int count;


  while(cin >> n,n) {

    cin >> seq;

    for(int i=0;i<n;i++) {

      prev_seq=seq;

      seq="";

      prev_char=prev_seq[0];

      count=1;

      for(int j=0;j<prev_seq.size();j++) {

	if(j==prev_seq.size()-1) {

	  seq+=IntToString(count);

	  seq+=prev_char;

	}

	else if(prev_char==prev_seq[j+1]) {

	  count++;

	}

	else {

	  seq+=IntToString(count);

	  seq+=prev_char;

	  prev_char=prev_seq[j+1];

	  count=1;

	}

      }

    }

    cout << seq << endl;

  }

  return 0;

}

      

Measured memory_bytes: 1052
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");

		//0 origin
		int n = Integer.parseInt(tmpArray[0]);
		int m = Integer.parseInt(tmpArray[1]);

		Edge edges[] = new Edge[m];

		for(int i = 0; i < m; i++){
			tmpArray = br.readLine().split(" ");
			int from = Integer.parseInt(tmpArray[0]);
			int to = Integer.parseInt(tmpArray[1]);
			int cost = Integer.parseInt(tmpArray[2]);

			edges[i] = new Edge(from,to, cost);
		}

		System.out.println(kruskal(edges, n));
	}


	static final int INF = Integer.MAX_VALUE;


	static long kruskal(Edge[] edges, int n){
		int numOfEdge = edges.length;

		Arrays.sort(edges);

		DisjointSet set = new DisjointSet(n);

		long result = 0;

		for(int i = 0; i < numOfEdge ; i++){
			Edge tmpEdge = edges[i];

			if(!set.isSameSet(tmpEdge.from, tmpEdge.to)){
				set.union(tmpEdge.from, tmpEdge.to);
				result += tmpEdge.cost;
			}
		}

		return result;

	}
}

class DisjointSet {
    private int n;
    private int[] p;
    private int[] rank;

    public DisjointSet(int n){
        this.n = n;

        p = new int[n + 1];
        rank = new int[n + 1];

        for(int i = 1; i <= n; i++){
            makeSet(i);
        }
    }

    private void makeSet(int x){
        p[x] = x;
        rank[x] = 0;
    }

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

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

    public boolean isSameSet(int x, int y){
        return findSet(x) == findSet(y);
    }

    private void link(int x, int y){
        if(rank[x] > rank[y]){
            p[y] = x;
        }
        else {
            p[x] = y;
            if(rank[x] == rank[y]){
                rank[y]++;
            }
        }
    }
}

class Edge implements Comparable<Edge>{
	int from;
	int to;
	int cost;

	Edge(int from, int to, int cost){
		this.from = from;
		this.to = to;
		this.cost = cost;
	}

	@Override
	public int compareTo(Edge e) {
		return this.cost - e.cost;
	}
}


Measured memory_bytes: 66800
N = int(input())
A = list(map(int, input().split()))

if A[0] == 1:
    if N == 0:
        print("1")
    else:
        print("-1")
    exit()
if N == 0:
    if A[0] == 1:
        print("1")
    else:
        print("-1")
    exit()
if sum(A) == 0:
    print("-1")
    exit()

B = dict()
sm = 0
for i in range(len(A)-1, -1, -1):
    sm += A[i]
    B[i] = sm


cnt = 1
roots = 1
for i in range(N):
    roots = roots * 2
    k = B[i+1]
    if roots > k:
        roots = k

    if roots - A[i+1] < 0:
        print("-1")
        exit()

    cnt += roots
    roots -= A[i+1]
print(cnt)

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

int main() {
    int N[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << N[K-1] << endl;

    return 0;
}

 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int a[][] = new int[n][m];
		int b[] = new int[m];
		int c[] = new int[n];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				a[i][j] = scan.nextInt();
			}
		}

		for (int i = 0; i < m; i++) {
			b[i] = scan.nextInt();
		}
		
		for (int i = 0; i < n; i++) {
			int num = 0;
			for (int j = 0; j < m; j++) {
				num += a[i][j] * b[j];
			}
			c[i] = num;
		}

		for (int i = 0; i < n; i++) {
			System.out.println(c[i]);
		}
		
		scan.close();
	}

}

Measured memory_bytes: 31820
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cstdint>
using namespace std;
static const long long MOD = 1000000007LL;
int n;
char s[100005];
uint64_t dp[100005][13];
int main() 
{ 
	int i, j, ki; 
	uint64_t res = 0;
	scanf("%s", s); 
	n = strlen(s);
	dp[0][0] = 1;
	for (i = 0; i < n; i++) 
	{
		int c;
		if (s[i] == '?') 
			c = -1; 
		else 
			c = s[i] - '0';

		for (j = 0; j < 10; j++) 
		{

			if (c != -1 && c != j) 
				continue; 
			for (ki = 0; ki < 13; ki++) 
			{
				dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki]; 
			}
		}
		for (j = 0; j < 13; j++) 
			dp[i + 1][j] %= MOD;
 	}
	res = dp[n][5];
	printf("%llu\n", res);
	return 0;
}

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

vector<int> vs;
ll tot = 0;

int rec(int i,vector<int> &v, vector<int> &result){
    if(i == v.size()-1){
        ll count = 0;
        ll cluster = v[0];
        int j = 1;
        while(j < i+1){
            if (result[j-1] == 0){
                cluster = cluster*10 + v[j];
            }else if(result[j-1] == 1){
                count += cluster;
                cluster = v[j];
            } 
            j += 1;
        }
        count += cluster;
        tot += count;
        return 0;
    }
    result[i] = 0;
    rec(i+1,v,result);

    result[i] = 1;
    rec(i+1,v,result);
    

}

int main(void)
{
    string s;
    cin >> s;
    for (int i=0; i < s.length() ;++i){
        vs.push_back((int)(s[i] - '0'));
    }
    vector<int> result(vs.size()-1,-1) ;
    rec(0,vs,result);
    cout << tot << endl;
}


Measured memory_bytes: 256
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
LL n,k_;
const int MOD=1e9+7;
int main(){
	fastio;
	cin>>n>>k_;
	n++;
	
	LL Min,Max;
	LL res=0;	
	
	for(LL k=k_;k<=n;k++){
	Min=((1ll+k)*k)/2;
	Max=(((n-k+1)+n)*k)/2;
//	cout<<Max<<" "<<Min<<" "<<(n-k+1+k)<<endl;
	Min%=MOD;
	Max%=MOD;
	Max-=Min;
	Max++;
//	cout<<Max<<endl;
	Max+=MOD;
	res+=Max;
	res%=MOD;}
	cout<<res;
	return 0;
}


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

int main() {
  int N;
  long power = 1;
  cin >> N;
  long e = pow(10, 9) + 7;

  for(int i = 1; i <= N; i++) {
    power *= i;
    if(power >= e) power %= e;
  }
  cout << power << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

void solve()
{
	vector<double> a(3);
	while(cin >> a[0] >> a[1] >> a[2], a[0] || a[1] || a[2])
	{
		sort(a.begin(), a.end());
		double Length = sqrt(a[0] * a[0] + a[1] * a[1]);
		int N;
		cin >> N;
		while(N--)
		{
			int hole;
			cin >> hole;
			if(hole * 2 > Length)
			{
				cout << "OK" << endl;
			}
			else
			{
				cout << "NA" << endl;
			}
		}
	}
}

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

Measured memory_bytes: 0
// Undone
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    int N = ReadInt();
    int[] TA = ReadIntArray();
    int[] H = ReadIntArray();
    // int[] temp = H.Select(x => Math.Abs(TA[1] - (TA[0] - x*0.006)).Min();
    double min = double.MaxValue;
    int pos = 0;
    for (int i = 0; i < N; i++) {
      double temp = Math.Abs(TA[1] - (TA[0] - H[i] * 0.006));
      if (temp < min) {
        min = temp;
        pos = i + 1;
      }
    }
    Console.WriteLine(pos);
  }

  private static string ReadStr() { return Console.ReadLine(); }
  private static int ReadInt() { return int.Parse(Console.ReadLine()); }
  private static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  private static long ReadLong() { return long.Parse(Console.ReadLine()); }
  private static char ReadChar() { return Console.ReadLine()[0]; }
  private static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  private static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  private static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  private static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  private static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
  private static string[] ReadCharStringArray() { return Console.ReadLine().ToCharArray().Select(c => c.ToString()).ToArray(); }
}


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

using namespace std;

int main(void) {
    int k, n;

    cin >> k >> n;

    vector<int> v(n);
    for (auto &x : v) cin >> x;

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

    int max_dist = (k - v[n - 1]) + v[0];
    for (int i = 1; i < n; i++) {
        max_dist = max(max_dist, v[i] - v[i - 1]);
    }

    cout << k - max_dist << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define MAX 1000000001

vector<vector<int>>g(200001);
int cnt=0;
bool vis[200001]={};

void dfs(int u){
    vis[u]=1;
    cnt++;
    for(auto &i:g[u]){
        if(!vis[i]){
            dfs(i);
        }
    }
}

int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    int n,m;
	    cin >> n >> m;
	    ll arr[n];
	    for(int i=0 ; i<m ; i++){
	        int u,v;
	        cin >> u >> v;
	        g[u].pb(v);
	        g[v].pb(u);
	    }
	    int maxm=-1;
	    for(int i=1 ; i<=n ; i++){
	        if(!vis[i]){
	            cnt=0;
	            dfs(i);
	            maxm=max(maxm,cnt);
	        }
	    }
	    cout << maxm << endl;
	}
	return 0;
}

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

#define int long long

int s[100], t[100], sumS, sumT;

int N, M;

bool Exists(int target)
{
    int *p = lower_bound(t, t + M, target);
    if (p >= t + M) return false;
    if (*p == target) return true;
    return false;
}

signed main()
{
    while (cin >> N >> M, N || M)
    {
        sumS = 0; sumT = 0;
        for (int i = 0; i < N; i++)
        {
            cin >> s[i];
            sumS += s[i];
        }
        for (int i = 0; i < M; i++)
        {
            cin >> t[i];
            sumT += t[i];
        }
        sort(t, t + M);
        int ans1 = LLONG_MAX / 2, ans2 = LLONG_MAX / 2;
        for (int i = 0; i < N; i++)
        {
            int target = sumT - sumS + 2 * s[i];
            if (target & 1 || !Exists(target / 2)) continue;
            target /= 2;
            if (ans1 + ans2 > s[i] + target)
            {
                ans1 = s[i]; ans2 = target;
            }
        }
        if (ans1 == LLONG_MAX / 2) puts("-1");
        else printf("%lld %lld\n", ans1, ans2);
    }
    return 0;
}

Measured memory_bytes: 1168
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

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

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	a := nextInt()
	b := nextInt()

	if a > b {
		fmt.Print(b, " ")
	} else {
		fmt.Print(a, " ")
	}

	min := (a + b) - n
	if min > 0 {
		fmt.Println(min)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod=1e9+7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,m,n) for(int i=m;i<(int)n;++i)
#define INF 1e+9
#define P pair<int, int>;
#define YES "Yes"
#define NO "No"
#define MAX_V 1000
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

// テレンス「もしかしてACですかーッ!?」　ジョセフ「Yse! Yse! Yse! Oh~MyGod」

int main(){
  ll n,w;
  cin>>n>>w;
  ll V[n],W[n];
  for(int i=0;i<n;i++){
    cin>>W[i]>>V[i];
  }
  ll dp[110][100100] = {0};
  for(int i=0;i<n;i++){
    for(int j=0;j<=w;j++){
      if(j-W[i]>=0){
        dp[i+1][j]=max(dp[i+1][j],dp[i][j-W[i]]+V[i]);
      }
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
    }
  }
  cout<<dp[n][w]<<endl;
}



Measured memory_bytes: 86272
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
    speed_up;
    char a;
    string s;
    int i, cnt = 0;
    cin>>s;
    for(i = 0; i<s.size()-1; i++)
    {
        a = s[i];
        if(s[i+1] != a) cnt++;
    }
    cout<<cnt<<endl;

    return 0;

}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const long long MOD = 1000000007;
char inv(char a){
  if(a=='B')return 'W';
  return 'B';
}
ll kaijo(ll N){
  ll ret=1;
  for (size_t i = 2; i < N+1; i++)
  {
    ret=ret*i%MOD;
  }
  return ret;
}
void solve(long long N, std::string S){
  vector<ll> s;
  char prev='W';
  REP(2*N){
    if(prev!=S[i]){
      s.push_back(1);
      prev=S[i];
    }else{
      s.push_back(0);
    }
  }
  s.push_back(1);
  dump(s);
  vector<ll> l,r;
  REP(2*N){
    if(s[i]==1){
      l.push_back(i);
      s[i]=0;
    }else{
      if(l.size()<r.size()+1){
        cout<<0<<endl;
        return;
      }
      r.push_back(i);
      s[i+1]=!(s[i+1]);
    }
  }
  dump(l);
  dump(r);
  if(l.size()!=r.size()){
    cout<<0<<endl;
    return;
  }
  ll ans=1;
  auto itrl=l.begin();
  auto itrr=r.begin();
  ll tmp=0;
  while(itrl!=l.end()||itrr!=r.end()){
    if(itrr==r.end()||itrl!=l.end()&&*itrl<*itrr){
      ++tmp;
      dump(tmp);
      ++itrl;
    }else{
      ans=tmp*ans%MOD;
      dump(ans);
      --tmp;
      dump(tmp);
      ++itrr;
    }
  }
  ans=ans*kaijo(N)%MOD;
  cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 5364
<?php
list($n, $m, $v, $p) = ints();
$a = ints();
rsort($a);
$min = 0;
$max = $n-1;
while($max > $min){
    $mid = floor(($min + $max + 1) / 2);
    if(isOK($mid)){
        $min = $mid;
    }else{
        $max = $mid - 1;
    }
}
echo $max + 1;
function isOK($k){
    global $a, $m, $v, $n, $p;
    $minusable = ($n-$v) * $m;
    $over = 0;
    for($i = $k-1; $i >= $p-1; $i--){
        $o = $a[$i] - $a[$k];
        if($o > $m){
            return false;
        }
        $over += $o; 
    }
    return $over<=$minusable;
}

function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}


Measured memory_bytes: 16884
#include<iostream>

using namespace std;

int main(){
  long long n, x;
  long long a[100000] = {};
  cin >> n >> x;
  for(long long i = 0 ; i < n ; i++) cin >> a[i];

  long long summ = 0;
  for(long long i = 0; i < n; i++){
    if(i > 0){
      if(a[i] + a[i-1] > x){
       summ += a[i-1] + a[i] - x;
       a[i] -= a[i] + a[i-1] -x;
     }
    }
    else {
      if(a[0] > x){
        summ += a[0] - x;
        a[0] = x;
      }
    }
  }
  cout << summ << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int h, w;
  cin >> h >> w;
  vector<vector<int> > c(10, vector<int>(10));
  for (auto &x: c) {
    for (auto &y: x) cin >> y;
  }
  vector<vector<int> > a(h, vector<int>(w));
  for (auto &x: a) {
    for (auto &y: x) cin >> y;
  }

  vector<int> c1(10);
  for (int i = 0; i <= 9; i++) {
    priority_queue<Pii, vector<Pii>, greater<Pii> > pque;
    vector<bool> visited(10);
    pque.emplace(0, i);
    while (!pque.empty()) {
      auto now = pque.top();
      pque.pop();
      if (visited[now.second]) continue;
      visited[now.second] = true;
      if (now.second == 1) {
        c1[i] = now.first;
        break;
      }
      for (int j = 0; j <= 9; j++) {
        if (!visited[j]) pque.emplace(now.first + c[now.second][j], j);
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == -1) continue;
      else ans += c1[a[i][j]];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384