akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
bool used[SIZE];
int v[SIZE];
VI e[SIZE];
bool dfs(int x){
    used[x]=1;
    bool ret=true;
    REP(i,SZ(e[x])){
        int y=e[x][i];
        if(used[y]){
            if(!(v[y]^v[x]))ret=false;
        }
        else{
            v[y]=v[x]^1;
            if(!dfs(y))ret=false;
        }

    }
    return ret;
}
int main(){
    DRII(N,M);
    REP(i,M){
        DRII(x,y);
        x--;y--;
        e[x].PB(y);
        e[y].PB(x);
    }
    LL one=0,even=0,odd=0;
    REP(i,N){
        if(!used[i]){
            if(SZ(e[i])==0)one++;
            else{
                if(dfs(i))even++;
                else odd++;
            }
        }
    }
    LL an=0;
    an+=one*one; //1
    an+=one*(N-one)*2; //12
    an+=even*even*2; //2
    an+=odd*odd;
    an+=even*odd*2;
    cout<<an<<endl;
    return 0;
}


Measured memory_bytes: 32768
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)
#define myforInv(i,N) for(i=N;i>=0;i--)
#define myforFLInv(i,f,l) for(i=f;i>l;i--)
#define ifMeetBoundaryCondition(x,xMax,xMin,y,yMax,yMin) if(x < xMax && x >= xMin &&y < yMax && y >= yMin)
#define INF pow(10,9)
using namespace std;

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

int main(){
	int n, m, i, j=0,move_num =0;
	string s;
	cin >> s;
	myfor(i,s.length()){
		if(s[i] != s[0]){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		if (n % 1000 == 0) {
			System.out.println(0);
		} else {
			System.out.println((n / 1000 + 1) * 1000 - n);
		}

		sc.close();
	}

}


Measured memory_bytes: 35824
from itertools import accumulate
from bisect import bisect_left
import sys
readlines = sys.stdin.buffer.readlines
readline = sys.stdin.buffer.readline

N = int(readline())

memo = [None]*N

for i,s in enumerate(readlines()):
    s = s.rstrip().decode()
    memo[i] = (min(0,min(accumulate(1 if c =='(' else -1 for c in s))),sum(1 if c =='(' else -1 for c in s))



positives = sorted((m,d) for m,d in memo if d >= 0)
negatives = sorted((m-d,-d) for m,d in memo if d < 0)

def solve():
    left = 0
    for m,d in reversed(positives):
        if left+m < 0:
            return False
        left += d
    right = 0
    for m,d in reversed(negatives):
        if right+m < 0:
            return False
        right += d
    return left == right

print('Yes' if solve() else 'No')



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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define pi 3.14159265

bool compare(pll a, pll b){
    return a.first*b.second<a.second*b.first;
}

const int mod = 1e9+7;
const ll inf = ll(1e18);

ll modexp(ll x,ll n){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%mod,n/2);
    return (x*modexp((x*x)%mod,n/2))%mod;
}

int main(){
    //clock_t tm = clock();
    fastio;
    char c;
    cin>>c;
    cout<<char(c+1)<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    string s,t,ans;
    cin >> n >> s >> t;
    
    rep(i,n){
      ans += s.at(i);
      ans += t.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 2e5+35;
int main(){
	int h,m,hh,mm,k; cin >> h >> m >> hh >> mm >> k;
	int t = h*60+m;
	int tt = hh*60+mm;
	cout << tt-k-t << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define OP_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fo(i,a,b) for(int i = a; i < b; i++)
#define fi first
#define si second
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

int main(){
  OP_IO;
  ll N,W;
  cin>>N>>W;
  vpii inp(N);
  fo(i,0,N){
    cin>>inp[i].fi>>inp[i].si;
  }
  ll dp[N+1][W+1];
  fo(j,0,N+1){
    fo(i,0,W+1){
      if (i ==0 || j==0){
	dp[j][i] = 0;
      }else if(inp[j-1].fi <= i){
	dp[j][i] = max(dp[j-1][i], inp[j-1].si + dp[j-1][i-inp[j-1].fi]);
      }else{
	dp[j][i] = dp[j-1][i];
      }
    }
  }
  cout<<dp[N][W]<<endl;
  return 0;
}


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

int n,idx; string s;
vector<string> v;

int exp(){
    char c=v[idx].back(),lev=v[idx].size(); ++idx;
    if (isdigit(c)) return c-'0';
    int res=(c=='*');
    while(idx<n&&lev<v[idx].size()){
        if (c=='*') res*=exp();
        if (c=='+') res+=exp();
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n,n){
        v.clear();
        for (int i=0;i<n;++i){
            cin >> s; v.emplace_back(s);
        }
        idx=0;
        cout << exp() << '\n';
    }
}


Measured memory_bytes: 3132
n,m,x=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]

ans=[]
for i in range(2**n):
  s=[0]*m
  c=0
  for j in range(n):
    if ((i >> j) & 1):
      for k in range(m):
        s[k]+=l[j][k+1]
      c+=l[j][0]
  t=0
  for j in range(m):
    if s[j]>=x:
      t+=1
  if t==m:
    ans.append(c)

print(min(ans) if ans!=[] else -1)

Measured memory_bytes: 9248
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};



int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if (a+b+c >= 22){
        cout << "bust";
    }
    else{
        cout << "win";
    }
}































Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////


void solve() {
	int A, B, C;
	cin >> A >> B >> C;
	cout << min(C, B / A) << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');

  (function(S) {
    var h = Math.floor(S / (60 * 60));
    var m = Math.floor(S / 60 % 60);
    var s = S % 60;// ????????????????????????
    console.log([h,m,s].join(':'));
  })(parseInt(inputs[0], 10)); // ??°?????????

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15536
//E
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e6+10;
int raw[maxn];
int main(){
	int n;
	cin >> n;
	int s = 0;
	for(int i = 1;i <= n;i++){
		cin >> raw[i];
		s ^= raw[i];
	}
	for(int i = 1;i <= n;i++)cout << (s^raw[i]) << " "; 
	return 0;
}


Measured memory_bytes: 4392
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const ll mod=998244353; 
int main()
{
	int n,cou=0,bj=0;
	sc(n);
	for(int i=1;i<=n;i++){
		int u,v;
		sc(u);sc(v);
		if(u==v)cou++;
		else cou=0;
		if(cou>=3)bj=1;
	}if(bj==1)pf("Yes\n");
	else pf("No\n");
}


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

using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll n;
    cin >> n;
    ll ans=0;
    for(int i=1; i<=n; i++)
    {
        if (i%3 && i%5) ans += i;
    }
    cout << ans << "\n";
    
    return 0;
}

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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

int solve() {
	ll n, a, b;
	cin >> n >> a >> b;

	if (a + b - 1 > n || a * b < n) {
		cout << -1 << endl;
		return 0;
	}

	vector<ll> nums(a);
	nums[0] = b;
	for (ll i = 1; i < a; ++i) {
		ll num = n - b;
		nums[i] = num / (a - 1LL) + (i <= (num % (a - 1LL)) ? 1 : 0);
	}
	ll res = 0;
	for (ll i = 0; i < a; ++i) {
		res += nums[i];
		for (ll j = 0; j < nums[i]; ++j) {
			cout << res - j;
			if (i + 1 != a || j + 1 != nums[i]) {
				cout << " ";
			}
		}
	}
	cout << endl;

	return 0;
}

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

	solve();

	return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main()
{
    ll n;cin>>n;
    ll ans=0;
    for(ll a=1;a*a<=n;a++){
        if(n%a==0&&n/a>a+1){
            ans+=n/a-1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int i,j,k,a,b,cnt,s1[3],s2[3];
	char sabu[102];
	while(1) {
		cnt=0;
		for(i=0;i<3;i++) {
			cin>>sabu;
			if(sabu[0]=='0') {
				cnt=1;
				break;
			}
			a=b=0;
			for(j=1;j<strlen(sabu);j++) {
				if(sabu[j]=='A')a++;
				else b++;
				//if(a==b&&a>10) a=b=10;					
			}
			if(a>b)s1[i]=a+1,s2[i]=b;
			else s1[i]=a,s2[i]=b+1;

		}
		if(cnt==1) break;
		for(i=0;i<3;i++) cout<<s1[i]<<" "<<s2[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3056
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<map>
#include<iostream>
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s.length()==2)cout<<s;
    else cout<<s[2]<<s[1]<<s[0];
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>

typedef long long int ll;

const int MAXN = 1e5 + 5;

int n;
ll ans;
ll A[MAXN], B[MAXN];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n + 1; ++i) {
        scanf("%lld", &A[i]);
    }
    for (int i = 1; i <= n; ++i) {
        scanf("%lld", &B[i]);
        if (B[i] <= A[i])
            ans += B[i];
        else if (B[i] <= A[i] + A[i + 1]) {
            ans += B[i];
            A[i + 1] -= (B[i] - A[i]);
        }
        else {
            ans += (A[i] + A[i + 1]);
            A[i + 1] = 0;
        }
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int fun(int ,int );
int fun(int a,int b)
{
    int x;
    if(b>=1&&b<10)
    {
        a=a*10+b;
    }
    if(b>=10&&b<100)
    {
        a=a*100+b;
    }
    if(b==100)
    {
        a=a*1000+b;
    }
    x=a;
    a=(int)sqrt(a);
    a=a*a;
    if(x==a)
    {
        return 1;
    }
    return 0;
}
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    printf((fun(a,b)==1)?"Yes\n":"No\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
 
int main(void){
    long L, R;
    long x = 2019;
    long y = 0;
    long diff = 0;
    
    cin >> L >> R;
    diff = R-L;
    
    if (diff==1) {
        cout << (L*R)%2019;
        return 0;
    } else if (diff>=2019) {
        cout << 0;
        return 0;
    } else {
        for (long i = L; i < R; i++) {
            for (long j = i+1; j < R + 1; j++) {
                y = (i*j)%2019;
                if (x >= y) {
                    x = y;
                }
            }
        }
        cout << x;
    }
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 998244353;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

clock_t start=clock();
const double tl = 1.9;
const double T0=2e3;
const double T1=6e2;
double T=T0;

const int w=5;
const int k=100;
const int n=26;

int d;
VI c(n);
VVI s(365,VI(n));

struct st{
	VI a;
	ll score;
	bool operator<(const st &another) const {return score < another.score;};
};

ll f(VI a){
	ll ret=0;
	VI last(n,-1);
	REP(i,d){
		last[a[i]]=i;
		ret+=s[i][a[i]];
		REP(j,26)
			ret-=c[j]*(i-last[j]);
	}
	return ret;
}

vector<st> f2(st p){
	VI a=p.a; ll score=p.score;
	int now=a.size()+1;
	VI last(n,0);
	REP(i,a.size())
		last[a[i]]=i+1;
	VI down(n); ll downsum=0;
	REP(i,n){
		down[i]=c[i]*(now-last[i]);
		downsum+=down[i];
	}
	a.push_back(-1);
	vector<st> tmp;
	REP(i,n){
		a[now-1]=i;
		tmp.push_back({a,score-downsum+down[i]+s[now-1][i]});
	}
	sort(ALL(tmp));
	vector<st> ret;
	REP(i,w)
		ret.push_back(tmp[n-1-i]);
	return ret;
}

int main(){
	cin >> d;
	REP(i,n) cin >> c[i];
	REP(i,d)REP(j,n) cin >> s[i][j];
	priority_queue<st> q;
	VI a(0);
	q.push({a,0});
	REP(i,d){
		priority_queue<st> next;
		REP(j,k){
			if(q.empty())
				break;
			for(auto nx:f2(q.top()))
				next.push(nx);
			q.pop();
		}
		q=next;
	}
	VI ans(d,10); ans=q.top().a;
	int cnt=0;
	while(1){
		cnt++;
		if(cnt%100==0){
			double t=(double)(clock()-start)/CLOCKS_PER_SEC/tl;
			if(t>=1.0)
				break;
			T=pow(T0,1.0-t)*pow(T1,t);
		}
		ll oldscore=f(ans);
		if(rand()%2){
			int cd=rand()%d;
			int old=ans[cd];
			ans[cd]=rand()%26;
			ll newscore=f(ans);
			if(rand()%1000000<=exp((newscore-oldscore)/T)*1e6)
				continue;
			ans[cd]=old;
		}
		else{
			int cd1=rand()%(d-1);
			int cd2=cd1+1+(rand()%(d-cd1-1));
			swap(ans[cd1],ans[cd2]);
			ll newscore=f(ans);
			if(rand()%1000000<=exp((newscore-oldscore)/T)*1e6)
				continue;
			swap(ans[cd1],ans[cd2]);
		}
	}
	REP(i,d)
		cout << ans[i]+1 << endl;
	//cout << f(ans) << endl;
	return 0;
}

Measured memory_bytes: 8052
const main = (input) => {
  const lines = input.trim().split("\n");
  const [N, T] = lines[0].split(' ').map(x => parseInt(x));
  let minCost = 10000;
  lines.slice(1).forEach(line => {
    const [c, t] = line.split(' ').map(str => parseInt(str));
    if (t <= T && c < minCost) {
      minCost = c;
    }
  });

  if (minCost === 10000) {
    console.log('TLE');
  } else {
    console.log(minCost);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7500
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
using namespace std;

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

int w, h;

struct t_node {
	short f[20][20];
	int x, y;
	int d;
	t_node(){ d=0; }
	t_node( const t_node &tn ) {
		rep(dy,h){ rep(dx,w){ f[dx][dy]=tn.f[dx][dy]; }}
		x = tn.x;
		y = tn.y;
		d = tn.d;
	}
	t_node& operator=( const t_node &r ) {
		rep(dy,h){ rep(dx,w){ f[dx][dy]=r.f[dx][dy]; }}
		d = r.d;
		x = r.x;
		y = r.y;
		return *this;
	}
	bool check(int dx, int dy, int &nx, int &ny) {
		nx = x;
		ny = y;
		while(0<=nx+dx && nx+dx<w && 0<=ny+dy && ny+dy<h) {
			if( f[nx+dx][ny+dy] == 1 ) {
				return true;
			}
			nx += dx;
			ny += dy;
			if( f[nx][ny] == 3 ) {
				return true;
			}
		}
		return false;
	}
};

int main() {
	while(cin >> w >> h, w||h) {
		t_node tn;
		rep(y, h) {
			rep(x, w) {
				cin >> tn.f[x][y];
				if( tn.f[x][y] == 2 ) {
					tn.f[x][y] = 0;
					tn.x = x;
					tn.y = y;
				}
			}
		}
		queue<t_node> que;
		que.push(tn);
		bool found = false;
		while( !que.empty() ) {
			tn = que.front();
			que.pop();
			if( tn.f[tn.x][tn.y] == 3 ) {
				found = true;
				cout << tn.d << endl;
				break;
			}
			if( tn.d == 10 ) {
				continue;
			}
			int dx[4]={-1,0,1,0}, dy[4]={0,-1,0,1};
			int nx, ny;
			rep(i, 4) {
				if( tn.f[tn.x+dx[i]][tn.y+dy[i]]!=1 && tn.check(dx[i], dy[i], nx, ny) ) {
					bool flg = (tn.f[nx+dx[i]][ny+dy[i]] == 1);
					if(flg) {
						tn.f[nx+dx[i]][ny+dy[i]] = 0;
					}
					tn.d++;
					int tmpx=tn.x, tmpy=tn.y;
					tn.x = nx;  tn.y = ny;
					que.push( tn );
					tn.x = tmpx;  tn.y = tmpy;
					tn.d--;
					if(flg) {
						tn.f[nx+dx[i]][ny+dy[i]] = 1;
					}
				}
			}
		}
		if( !found ) {
			cout << "-1" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 61988
#include <cstdio>
#include <cstring>
 
const int mod = 1e9 + 7;
#define maxn 1000010
int f[maxn], g[maxn], n;
typedef int Matrix[5][5];
typedef int Vector[5];
Matrix base;
Vector ret;
inline void mul(Matrix A, Matrix B)
{
	Matrix C;
	int *ci, aik, *bk;
	for (int i = 0; i < 5; ++i)
	{
		ci = C[i];
		memset(ci, 0, 20);
		for (int k = 0; k < 5; ++k)
			if (aik = A[i][k])
			{
				bk = B[k];
				for (int j = 0; j < 5; ++j)
					ci[j] = (ci[j] + 1ll * aik * bk[j]) % mod;
			}
	}
	memcpy(A, C, 100);
//	for (int i = 0; i < 5; ++i, puts("")) for (int j = 0; j < 5; ++j) printf("%d ", A[i][j]); puts("");
//	for (int i = 0; i < 5; ++i, puts("")) for (int j = 0; j < 5; ++j) printf("%d ", C[i][j]); puts("");
}
inline void mul(Vector A, Matrix B)
{
	Vector C; memset(C, 0, 20);
	int *bi, ai;
	for (int i = 0; i < 5; ++i)
	{
		bi = B[i]; ai = A[i];
		for (int j = 0; j < 5; ++j)
			C[j] = (C[j] + 1ll * bi[j] * ai) % mod;
	}
	memcpy(A, C, 20);
}
inline void qpow(int power)
{
	for (; power; power >>= 1, mul(base, base)) power & 1 ? mul(ret, base), 1 : 0;
}
int main()
{
	scanf("%d", &n);
	int n2 = 1ll * (n - 1) * (n - 1) % mod;
	f[0] = 1; g[0] = f[0];
	f[1] = n; g[1] = g[0] + f[1];
	f[2] = (f[1] + n - 1 + n2 % mod) % mod; g[2] = (g[1] + f[2]) % mod;
	if (n <= 2) return !printf("%d\n", f[n]);
	ret[0] = f[2];
	ret[1] = f[1];
	ret[2] = g[0];
	ret[3] = 2;
	ret[4] = 1;
	base[0][0] = 1; base[0][1] = 1;
	base[1][2] = 1;
	base[2][0] = 1; base[2][2] = 1;
	base[3][0] = mod - 1; base[3][3] = 1;
	base[4][0] = (n + n2) % mod; base[4][3] = 1; base[4][4] = 1;
	qpow(n - 2);
	printf("%d\n", ret[0]);	
	return 0;
}

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

int main(void){
    char dia[3];
    scanf("%s", dia);

    if (strcmp(dia, "MON") == 0) {
        printf("6\n");
    } else if (strcmp(dia, "TUE") == 0){
        printf("5\n");
    } else if (strcmp(dia, "WED") == 0){
        printf("4\n");
    } else if (strcmp(dia, "THU") == 0){
        printf("3\n");
    } else if (strcmp(dia, "FRI") == 0){
        printf("2\n");
    } else if (strcmp(dia, "SAT") == 0){
        printf("1\n");
    } else {
        printf("7\n");
    }
    return 0;
}


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

dp = [float('inf')] * (1 << n)
dp[0] = 0
for i in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))

    SS = sum([1 << (cc - 1) for cc in c])
    for S in range(1 << n):
        dp[S | SS] = min(dp[S | SS], dp[S] + a)

if dp[-1] == float('inf'):
    print(-1)
else:
    print(dp[-1])


Measured memory_bytes: 50012
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		AtCoder2();
	}

	public static void AtCoder2(){
		Scanner scanner = new Scanner(System.in);
		int H = scanner.nextInt();
		int W = scanner.nextInt();
		int MP[][] = new int[10][10];
		int wall[][] = new int[H][W];
		int optMP[] = new int[10];
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				MP[i][j] = scanner.nextInt();
			}
		}
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				wall[i][j] = scanner.nextInt();
			}
		}
		boolean check[] = new boolean[10];
		check[1] = true;
		for(int i=0;i<10;i++){
			optMP[i] = MP[i][1];
		}
		for(int i=1;i<10;i++){
			int min = min(optMP, check);
			check[min] = true;
			for(int j=0;j<10;j++){
				if(!check[j]){
					if(optMP[j]>optMP[min]+MP[j][min]){
						optMP[j]=optMP[min]+MP[j][min];
					}
				}
			}
		}
		int ans=0;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(wall[i][j]==-1){
					continue;
				}
				ans = ans + optMP[wall[i][j]];
			}
		}
		System.out.println(ans);
	}

	public static int min(int array[],boolean check[]){
		int min=-1;
		for(int i=0;i<array.length;i++){
			if(min==-1){
				if(!check[i])
					min = i;
				else{
					continue;
				}
			}
			if(!check[i] & array[min]>array[i]){
				min = i;
			}
		}
		return min;
	}
}

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

int main(){
  int n, ans = 0;
  cin >> n;
  vector<int> v(n), c(n);
  
  for(int i = 0; i < n; i++){
    cin >> v.at(i);
  }
  
  for(int i = 0; i < n; i++){
    cin >> c.at(i);
    int tmp = v[i] - c[i];

    if(tmp > 0){
     ans += tmp;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            int x = sc.nextInt();
            int num = 0;
            if(n == 0 && x == 0){
                break;
            }
            for(int i = 1; i < n-1; i++){
                for(int j = i+1; j < n; j++ ){
                    for(int k = j+1; k <= n; k++){
                        if(i+j+k == x){
                            num++;
                        }
                    }
                }
            }
            System.out.println(num);
       }
    }
}


Measured memory_bytes: 26624
module Main where
import Data.List

int = read::String -> Int
main = interact $ printer . solver . parser

printer = unlines . (:[]) . show
parser = map int . tail . words

solver :: [Int] -> Int
solver list = result
  where
    gr = filter (\x -> length x >= 2) . group . sortBy (flip  compare) $ list
    result = 
      if length gr >= 1 && length (gr !! 0) >= 4
      then head (gr !! 0) * head (gr !! 0)
      else if length gr >= 2 
           then head (gr !! 0) * head (gr !! 1)
           else 0


Measured memory_bytes: 17660
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int H, W;
    scan(H, W);
    vector<vector<char>> v(H, vector<char>(W));
    scan(v);
    int wcnt = 0;
    for (auto &&i : v) {
        for (auto &&j : i) {
            if (j == '.')
                wcnt++;
        }
    }
    vector<int> dx = {-1, 1, 0, 0};
    vector<int> dy = {0, 0, -1, 1};
    auto exist     = [](int H, int W, int nx, int ny) -> bool {
        if (nx < 0 || W <= nx || ny < 0 || H <= ny)
            return false;
        else
            return true;
    };
    queue<pair<int, int>> que;
    que.push({0, 0});
    vector<vector<int>> minpath(H, vector<int>(W));
    minpath[0][0] = 1;
    while (!que.empty()) {
        auto now = que.front();
        que.pop();
        int x = now.first;
        int y = now.second;
        REP(i, 4) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (exist(H, W, nx, ny) && minpath[ny][nx] == 0 &&
                v[ny][nx] == '.') {
                minpath[ny][nx] = minpath[y][x] + 1;
                que.push({nx, ny});
            }
        }
    }
    int ans = minpath[H-1][W-1] == 0 ? -1 : wcnt - minpath[H - 1][W - 1];
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <numeric>

using namespace std;

long long MOD = 998244353L;

long long pow(int a, int n) {
    long long ret = 1;
    for (int i = 0; i < n; i++) {
        ret = (ret * a) % MOD;
    }
    return ret;
}

map <int, long long> memo;

long long doit(vector <int> &a, int n, int suma, int index, int s) {
    if (s * 2 > suma) {
        return 0;
    }
    if (index >= n) {
        return 3;
    }
    int key = s * n + index;
    if (memo.find(key) == memo.end()) {
        memo[key] = (doit(a, n, suma, index + 1, s + a[index]) * 2 +
                     doit(a, n, suma, index + 1, s)) % MOD;
    }
    return memo[key];
}

map <int, long long> memo2;

long long doit2(vector <int> &a, int n, int suma, int index, int s) {
    if (s * 2 > suma) {
        return 0;
    }
    if (index >= n) {
        return (s * 2 == suma) ? 3 : 0;
    }
    int key = s * n + index;
    if (memo2.find(key) == memo2.end()) {
        memo2[key] = (doit2(a, n, suma, index + 1, s + a[index]) +
                     doit2(a, n, suma, index + 1, s)) % MOD;
    }
    return memo2[key];
}

int main()
{
    int n;
    cin >> n;

    vector <int> a(n);
    int suma = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        suma += a[i];
    }

    vector <long long> dp1(suma + 1, 0);
    vector <long long> dp2(suma + 1, 0);
    dp1[0] = 3;
    dp2[0] = 3;
    for (int i = 0; i < n; i++) {
        for (int j = suma / 2; j >= 0; j--) {
            dp1[j] = (dp1[j] + (j >= a[i] ? dp1[j - a[i]] * 2 : 0)) % MOD;
            dp2[j] = (dp2[j] + (j >= a[i] ? dp2[j - a[i]] : 0)) % MOD;
        }
    }
    long long ret = pow(3, n);
    for (int j = 0; j <= suma / 2; j++) {
        ret = (ret - dp1[j] + MOD) % MOD;
    }
    if (suma % 2 == 0) {
        ret = (ret + dp2[suma / 2]) % MOD;
    }
    cout << ret << endl;

    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    int memo;
    memo=a.at(0);
    for(int i=0;i<n;i++){
        if(memo==2){
            cout<<i+1<<endl;
            break;
        }
        memo=a.at(memo-1);
        if(i==n-1){
            cout<<-1<<endl;
        }
    }

}

Measured memory_bytes: 640
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}


ll dfs(ll n,ll k){
  if(n==0) return 1;
  ll burger=(1LL<<(n+1))-3;
  ll patty=(1LL<<n)-1;
  if(k==1) return 0;
  else if(k<=burger+1) return dfs(n-1,k-1);
  else if(k<=burger+2) return patty+1;
  else if(k<=2*burger+2) return patty+1+dfs(n-1,k-burger-2);
  else return 2*patty+1;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k;
  cin>>n>>k;
  cout<<dfs(n,k)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
 
#define rp(i, k, n) for (int i = k; i < n; i++)
using ll = long long;
using ld = double;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

int main() {
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> S, T;
    rp(i, 0, a) {
        ll s; cin >> s;
        S.emplace_back(s);
    }
    rp(i, 0, b) {
        ll t; cin >> t;
        T.emplace_back(t);
    }

    while(q--) {
        ll x; cin >> x;
        ll sr, sl, tr, tl;
        auto sitr = lower_bound(S.begin(), S.end(), x);
        auto titr = lower_bound(T.begin(), T.end(), x);
        if(sitr == S.begin()) {
            sr = *sitr;
            sl = -INF;
        }
        else if(sitr == S.end()) {
            sr = INF;
            sl = *(--sitr);
        } else {
            sr = *sitr;
            sitr--;
            sl = *sitr;
        }
        if(titr == T.begin()) {
            tr = *titr;
            tl = -INF;
        } else if(titr == T.end()) {
            tr = INF;
            tl = *(--titr);
        } else {
            tr = *titr;
            titr--;
            tl = *titr;
        }
        ll res1 = llabs(max(sr, tr) - x);
        ll res2 = llabs(min(sl, tl) - x);
        ll res3 = min(llabs(sl - x), llabs(tr - x)) + llabs(sl - tr);
        ll res4 = min(llabs(sr - x), llabs(tl - x)) + llabs(sr - tl);
        cout << min({res1, res2, res3, res4}) << endl;
    }
    return 0;
}


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

int main(){
    char a[10];
    char b[10];
    char c[10];
    scanf("%s%s%s",a,b,c);
    
    

    int l,m,n;
    l = strlen(a);
    m = strlen(b);
    n = strlen(c);

        if((a[l-1]==b[0]) && (b[m-1]==c[0])) {
            printf("YES\n");
        }
       else {
            printf("NO\n");

        }
        return 0;

}


Measured memory_bytes: 128
//克鲁斯卡尔算法，求最小生成树，其思想是先对所有的边排序，然后对每两个点之间选取最短的那条边，舍弃其他边
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Edge {
	public:
		int source,target,cost;
		Edge(int source,int target,int cost) {
			this->source = source;
			this->target = target;
			this->cost = cost;
		}

		bool operator<(const Edge & e) {
			return cost < e.cost;
		}
};

//互质集合
class DisjointSet {
		vector<int> rank,p;
	public:
		DisjointSet(int n) {
			rank.resize(n,0);
			p.resize(n,0);
			for (int i=0; i<n; i++) {
				makeSet(i);
			}
		}
		void makeSet(int x) {
			p[x] = x;
			rank[x] = 0;
		}

		int findSet(int x) {
			if (x != p[x]) {
				p[x] = findSet(p[x]); //路径压缩
			}
			return p[x];
		}

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

		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]++;
				}
			}
		}
		void unite(int x,int y) {
			link(findSet(x),findSet(y));
		}
};
//边
vector<Edge> edges;
int n; //点数

int kruskal() {
	int totalCost = 0;
	//对边按升序排序 
	sort(edges.begin(),edges.end());
	
	DisjointSet dset = DisjointSet(n);

	for (int i=0; i<edges.size(); i++) {
		Edge e = edges[i];
		if (!dset.same(e.source,e.target)) {
			totalCost += e.cost;
			dset.unite(e.source,e.target);
		}
	}
	return totalCost;
}

int main() {
	int e;
	cin >> n >> e;
	for (int i=0;i<e;i++) {
		int s,t,w;
		cin >> s >> t >> w;
		edges.push_back(Edge(s,t,w));
	}
	cout << kruskal() << endl;
	return 0;
}



Measured memory_bytes: 4532
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int ans = A*B >= C*D ? A*B : C*D;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
dp = [[float('inf') for _ in range(10**5+10)] for _ in range(10**2+10)]

N, W = map(int,input().split())
w = []
v = []

for i in range(N):
    wi,vi = map(int,input().split())

    w.append(wi)
    v.append(vi)

#初期条件
dp[0][0] = 0

for i in range(N):
    for sum_v in range(10**5+10):
        if v[i] <= sum_v:
            dp[i+1][sum_v] = min(dp[i][sum_v], dp[i][sum_v-v[i]] + w[i])
        else:
            dp[i+1][sum_v] = dp[i][sum_v]
            
#最適値の出力
res = 0

for i in range (10**5+10):
    if (dp[N][i] <= W):
        res = i

print(res)


Measured memory_bytes: 322420
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BPalace {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    double t, a;
	    in >> n >> t >> a;
	    vector<double> h(n);
	    for(int i=0; i<n; i++){
	        in >> h[i];
	    }

	    double height = inf;
        int res = 0;
	    for(int i=0; i<n; i++){
            if(height > abs(t - h[i] * 0.006 - a)){
                res = i+1;
                height = abs(t - h[i] * 0.006 - a);
            }
	    }

	    out << res << endl;
	}
};


int main() {
	BPalace solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
 
using namespace std;

#define int long long
 
struct segtree {
    vector<int> dat;
    int n;
 
    segtree(int n_) {
        n = 1;
 
        while (n < n_) n *= 2;
 
        dat.resize(2*n, 0);
    }
 
    void update(int i, int x) {
        i += n - 1;
        int diff = x - dat[i];
        dat[i] = x;
 
        while (i > 0) {
            i = (i - 1) / 2;
            dat[i] += diff;
        }
    }
 
    int query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r == -1) r = n;
 
        if (r <= a || l >= b) return 0;
 
        if (a <= l && r <= b) {
            return dat[k];
        }
 
        int lv = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int rv = query(a, b, k * 2 + 2, (l + r) / 2, r);
 
        return lv + rv;
    }
};

signed main()
{
    int N; cin >> N;
    vector<int> a(N), b(N);
 
    segtree P(N), Q(N);
    vector<tuple<int, int, int>> tmp;
 
    for (int i = 0; i < N; ++i) {
        cin >> a[i] >> b[i];
        tmp.push_back(make_tuple(a[i], i, b[i]));
    }
 
    sort(begin(a), end(a));
    sort(begin(tmp), end(tmp));
 
    vector<pair<int, int>> data;
 
    for (int i = 0; i < N; ++i) {
        int aaa, bbb, val;
        tie(aaa, bbb, val) = tmp[i];
        data.push_back(make_pair(val, i));
    }
 
    sort(begin(data), end(data));
     
    for (int i = 0; i < N; ++i) {
        P.update(i, a[i]);
        Q.update(i, 1);
    }
 
    int ma = 0;
 
    for (int i = 0; i < N; ++i) {
        pair<int, int> d = data[i];
 
        int l = 0, r = N;

        int PP, QQ;
 
        for (int j = 0; j < 30; ++j) {
            int mid = (l + r) / 2;

            PP = P.query(0, mid + 1);
            QQ = Q.query(0, mid + 1);
 
            if (PP <= d.first * QQ) {
                l = mid;
            } else {
                r = mid;
            }
        }
 
        if (PP <= d.first * QQ) {
            ma = max(ma, QQ);
        }
 
        P.update(d.second, 0);
        Q.update(d.second, 0);
    }
 
    cout << ma << endl;
}

Measured memory_bytes: 43728
#include <stdio.h>

int main(){
  int h, w, i, j;
  while(scanf("%d%d", &h, &w) && h && w){
    for(i = 0;i < h;i++){
      for(j = 0;j < w;j++) putchar('#');
      puts("");
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 588
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,c,d,t=0,x=0,m=INT_MAX;
    string s;
    cin>>s;
    for(int i = 0; i <= s.size()-3; i++)
    {
        x = (s[i]-'0')*10+(s[i+1]-'0');
        x  = (x)*10;
        x  += (s[i+2]-'0');
        d = abs(753-x);
        if(m > d)
        {
            m = d;
        }

    }

    cout<<m<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<char> S(4);
  for (int i = 0; i < 4; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(), S.end());
  if (S.at(0) == S.at(1) && S.at(2) == S.at(3) && S.at(1) != S.at(2)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3600
import sys

s = input().strip()
t = input().strip()

d = dict()
for i, sc in enumerate(s):
    tc = t[i]

    if sc in d:
        if d[sc] == tc:
            continue
        else:
            print('No')
            sys.exit(0)

    d[sc] = tc

vs = list(d.values())
for v in vs:
    if vs.count(v) > 1:
        print('No')
        sys.exit(0)

print('Yes')


Measured memory_bytes: 3632
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line
}

fn main() {
    let _ = get_line();
    let mut num: Vec<i32> = get_line().trim()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect();
    num.reverse();
    for i in 0..num.len() {
        if i == num.len() - 1 {
            print!("{}\n", num[i]);
        } else {
            print!("{} ", num[i]);
        }
    }
}



Measured memory_bytes: 5032
#include<cstdio>
#include<algorithm>
using namespace std;

long long n,a[105],ans=0x7fffffff;

int main()
{
	scanf("%lld",&n);
	
	for (int i=1 ; i<=n ; i++)
	    scanf("%lld",&a[i]);
	
	for (int i=1 ;i<=100 ; i++)
	{
		long long sum=0;
		for (int j=1 ; j<=n ; j++)
		    sum+=(a[j]-i)*(a[j]-i);
		ans=min(ans,sum);
	}
	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.*

fun main(args:Array<String>):Unit {
    val (n, q) = readLine()!!.split(' ').map(String::toInt)
    val stacks = Array(n){LinkedList<Int>() as Deque<Int>}
    repeat(q){
        val query = readLine()!!.split(' ').map(String::toInt)
        when(query.first()){
            0 -> stacks[query[1]].addLast(query.last())
            1 -> if (stacks[query.last()].isNotEmpty()) println(stacks[query.last()].first)
            else -> if (stacks[query.last()].isNotEmpty()) stacks[query.last()].removeFirst()
        }
    }
}



Measured memory_bytes: 118492