akhauriyash/Code-Regression huggingface dataset:
import std.stdio,std.string,std.conv;

int main()
{
	string s;
	while((s = readln.chomp).length != 0)
	{
		string[] _s = s.split(" ");
		double a[8];
		foreach(i;0..8)
		{
			a[i] = _s[i].to!double;
		}
		
		if(a[6] < a[0] || a[2] < a[4] || a[7] < a[1] || a[3] < a[5])
		{
			writeln("NO");
		}
		else
		{
			writeln("YES");
		}
	}
	return 0;
}

Measured memory_bytes: 1076
#include<bits/stdc++.h>
using namespace std;
// greedy Solution
// int main(){
//     int n;
//     cin>>n;
//     vector<long long> A(n);
//     for(int i=0; i<n; ++i) cin>>A[i];
//     long long current=1000;

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

//         long long stocks=0;

//         if(A[i-1]<A[i]) stocks = current/A[i-1];
//         current += (A[i]-A[i-1])*stocks;
//         //cout<<current<<"\n";
//     }
//     cout<<current<<"\n";
// }

// Dp solution

int main(){
    int n;
    cin>>n;
    vector<long long> A(n);
    for(int i=0; i<n; ++i) cin>>A[i];
    vector<long long> Dp(n,0);
    Dp[0]=1000;
    for(int i=1; i<n; ++i){
        Dp[i] = Dp[i-1];
        for(int j=0; j<i; ++j){
            long long v = Dp[j]/A[j];
            long long w = Dp[j] + (A[i]-A[j])*v;
            Dp[i] = max(Dp[j],w);
        }
    }
    cout<<Dp[n-1]<<"\n";
}

Measured memory_bytes: 3588
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    for(;;){
        int n, m;
        cin >> n >> m;
        if(n == 0)
            return 0;

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

        if(n < m){
            swap(n, m);
            x.swap(y);
        }

        vector<int> dp(1<<n, 0);
        for(int i=0; i<(1<<n); ++i){
            bitset<32> bs(i);
            int k = bs.count();
            if(k >= m)
                continue;

            for(int j=0; j<n; ++j){
                if(bs[j])
                    continue;
                bs[j] = true;

                int e = abs(x[j] - y[k]);
                e *= (e - 30) * (e - 30);
                dp[bs.to_ulong()] = max(dp[bs.to_ulong()], dp[i] + e);

                bs[j] = false;
            }
        }

        int ans = *max_element(dp.begin(), dp.end());
        cout << ans << endl;
    }
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define ll long long
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

int main() {
	ll n, W;
	cin >> n >> W;
	vector<ll> v(n+1), w(n+1);
	for(ll i=1; i<=n; i++) {
		cin >> w[i] >> v[i];
	}
	vector<vector<ll>> dp(n+1, vector<ll>(W+1, 0)); 
	for(ll i=1; i<=n; i++) {
		for(ll j=0; j<=W; j++) {
			if (j-w[i] >= 0) {
				if (dp[i-1][j] >= dp[i-1][j - w[i]] + v[i]) dp[i][j] = dp[i-1][j];
				else dp[i][j] = dp[i-1][j - w[i]] + v[i];
			} else dp[i][j] = dp[i-1][j];
		}
	}
	/*cout << "dp: " << endl;
	for(ll i=1; i<=n; i++) {
		for(ll j=0; j<=W; j++) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	ll ans = 0;
	for(ll j=1; j<=W; j++) {
		if (dp[n][j] > ans) ans = dp[n][j]; 
	}
	cout << ans << endl;
}


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

using namespace std;

int main()
{
    string s,t;
    cin>>s>>t;
    s=" "+s,t=" "+t;
    int dp[s.size()+1][t.size()+1];
    memset(dp,0,sizeof(dp));
    for(int i=1; i<s.size(); i++)
    {
        for(int j=1; j<t.size(); j++)
        {
            if(s[i]==t[j])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    string ans;
    int i=s.size()-1,j=t.size()-1;
    while (i&&j)
    {
        if(s[i]==t[j])
        {
            ans+=s[i];
            i--;
            j--;
        }
        else if(dp[i-1][j]>=dp[i][j-1])
            i--;
        else
            j--;
    }

    for(int i=ans.size()-1; i>=0; i--)
        cout << ans[i];


    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> X(N), Y(N), P(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i] >> P[i];
  }
  vector SX(1 << N, vector(N, 1 << 28)), SY(1 << N, vector(N, 1 << 28));
  for (int bit = 0; bit < (1 << N); bit++) {
    for (int i = 0; i < N; i++) {
      SX[bit][i] = min(SX[bit][i], abs(X[i]));
      SY[bit][i] = min(SY[bit][i], abs(Y[i]));
      if ((bit >> i) & 1) {
        for (int j = 0; j < N; j++) {
          SX[bit][j] = min(SX[bit][j], abs(X[i] - X[j]));
          SY[bit][j] = min(SY[bit][j], abs(Y[i] - Y[j]));
        }
      }
    }
  }
  vector res(N + 1, INT64_C(1) << 58);
  for (int bitx = 0; bitx < (1 << N); bitx++) {
    int mask = ((1 << N) - 1) ^ bitx;
    for (int bity = mask;; bity = (bity - 1) & mask) {
      int64_t r = 0;
      for (int i = 0; i < N; i++) {
        r += static_cast<int64_t>(P[i]) * min(SX[bitx][i], SY[bity][i]);
      }
      int a = __builtin_popcount(bitx), b = __builtin_popcount(bity);
      res[a + b] = min(res[a + b], r);
      if (bity == 0) break;
    }
  }
  for (auto&& e : res) {
    cout << e << '\n';
  }
  return 0;
}


Measured memory_bytes: 9740
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll=long long;
using P = pair<int,int>;
int main(){
    string a,b;
    cin >> a >> b;
    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    string s;
    cin >> n >> s >> k;
    rep (i, s.size()) {
        if (s[i] != s[k - 1]) s[i] = '*';
    }
    cout << s << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <queue>

int n;

int V[100][100];
int D[100];
int d = 0;

std::queue<int> Q;

void bfs(int r) {
    Q.push(r);
    D[r] = 0;
    while (Q.size()) {
        r = Q.front();
        Q.pop();
        for (int i = 0; i < n; i++) {
            if ((D[i] == -1) && (V[r][i] == 1)) {
                Q.push(i);
                D[i] = D[r] + 1;
            }
        }
    }
}


int main() {
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        int id, e_num;
        std::cin >> id >> e_num;
        for (int j = 0; j < e_num; j++) {
            int t;
            std::cin >> t;
            V[id - 1][t - 1] = 1;
        }
    }

    for (int i = 0; i < n; i++) {
        D[i] = -1;
    }

    bfs(0);
    for (int i = 0; i < n; i++) {
        std::cout << i + 1 << " " << D[i] << std::endl;
    }
}


Measured memory_bytes: 3184
#include<cstdio>
#define N 6
char s[N];
bool f[N];
int main()
{
	scanf("%s",s);
	for(int i=0;i<3;i++)
	f[int(s[i]-97)]=1;
	if(f[0]&&f[1]&&f[2]) printf("Yes\n");
	else printf("No\n");
}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//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();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int main(){

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

    int a,b,c;
    cin >> a >> b>> c;

    int x,y;
    cin >> x >> y;

    int mini = min( x, y);

    int sum = 0;

    if( a + b > 2* c){
        sum = mini * 2 * c;

        if( x > y){
            cout << sum + (x - y )* min( a, 2 * c) << endl;
        }
        else if( x < y){
            cout << sum + (y - x )* min( b, 2 * c) << endl;
        }
        else{
            cout << sum << endl;
        }
    }

    else{

        cout << a * x +b * y << endl;
    }

    return 0;
}


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

int main()
{
    int n;
    cin>>n;
    
    int a[10050]={0};
    for(int i=1;i<105;i++)
    {
        for(int j=1;j<105;j++)
        {
            for(int k=1;k<105;k++)
            {
                int v= i*i + j*j + k*k + i*k + k*j + j*i;
                if( v < 10050)
                a[v  ]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        cout<<a[i] <<'\n';
    }
}

Measured memory_bytes: 3576
#include <stdio.h>

void grading(void)
{
	int pm, pe, pj;
	scanf("%d %d %d", &pm, &pe, &pj);
	if (pm == 100 || pe == 100 || pj == 100 || (pm + pe) >=180 || (pm + pe + pj) >= 240) printf("A\n");
	else if ((pm + pe + pj) >= 210 || (( pm + pe + pj) >= 150 && (pm >= 80 || pe >= 80))) printf("B\n");
	else printf("C\n");
}

int main(void)
{
	while (1)
	{
		int n;
		scanf("%d", &n);
		if (n == 0) break;
		int j;
		for (j = 0; j < n; j++){
			grading();
		}
	}
	return 0;
}

Measured memory_bytes: 584
package main

import (
	"fmt"
	"strconv"
)

func solve() {
	var s string
	fmt.Scan(&s)

	fmt.Println(string(s[0]) + strconv.Itoa(len(s)-2) + string(s[len(s)-1]))
}

func main() {
	solve()
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    string s;cin>>s;
    vvl f(n+1,vl(10,0));
    rep(i,n){
        f[i+1][s[i]-'0']=1;
    }
    rep(i,n)rep(j,10)f[i+1][j]+=f[i][j];
    set<string> st;
    range(i,1,n-1)rep(l,10)rep(r,10){
        // puta(l,s[i],r);
        if(f[i][l] and f[n][r]-f[i+1][r])st.insert(""+to_string(l)+s[i]+to_string(r));
    }
    puta(st.size());

    return 0;
}

Measured memory_bytes: 5888
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
 
#define LL long long
 
int main(){
	char a, b;
	cin >> a >> b;
	if(a==b) cout << "H" << endl;
	else cout << "D" << endl;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    string a, b;
    cin >> a >> b;

    if(a.size() < b.size()){
        cout << "LESS" << endl;
    } else if(a.size() > b.size()){
        cout << "GREATER" << endl;
    } else {
        for(int i = 0; i < a.size(); i++){
            if(a[i] - '0' < b[i] - '0'){
                cout <<"LESS" << endl;
                return 0;
            } else if(a[i] - '0' > b[i] - '0'){
                cout << "GREATER" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
}

Measured memory_bytes: 256
fun main(args:Array<String>){
  var s = readLine()!!.toInt()
  var a = s/100
  var b = s%100
  if(b<13 && 0<b){
    if(a<13 && 0<a){
      println("AMBIGUOUS")
    }
    else{
      println("YYMM")
    }
  }
  else{
    if(a<13 && 0<a ){
      println("MMYY")
    }
    else{
      println("NA")
    }
  }
}

Measured memory_bytes: 31608
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pp;

ll dp[101][100001];ll n;
vector<pp> a;

ll f(int i,ll w)
{
    if(i==n)
    {
        return 0;
    }
    if(dp[i][w]!=-1)
    return dp[i][w];
    ll res=0;
    if(a[i].first<=w)
    res=max(res,f(i+1,w-a[i].first)+a[i].second);
    res=max(res,f(i+1,w));
    dp[i][w]=res;
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    ll w;
    cin>>n>>w;
    for(int i=0;i<n;i++)
    {
		
        ll u,v;
        cin>>u>>v;
        a.push_back(make_pair(u,v));
    }
    
    for(int i=0;i<=n;i++)
    {
    	for(int j=0;j<=w;j++)
    	dp[i][j]=-1;
	}

    cout<<f(0,w)<<"\n";

}


Measured memory_bytes: 79232
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m,sum=0;
    cin >> n >> m;
    vector<int> a(m);
    for(int i = 0; i < m; ++i) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    if(sum > n) {
        cout << -1 << endl;
        return 0;
    }
    cout << n - sum << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char p[100], s[100];
	cin >> p >> s;
	int pLength = strlen(p);
	int sLength = strlen(s);
	bool HasFind = false;
	for(int i = 0;i < pLength;i++)
	{
		if(p[i] == s[0])
		{
			HasFind = true;
			for(int j = 1;j < sLength;j++)
			{
				if (p[(i + j) % pLength] != s[j])
					HasFind = false;
			}
			if(HasFind)
				break;
		}
	}

	if (HasFind)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

struct UnionFind{
    vector<int> par; // par[i]:iの親の番号
    
    UnionFind(int N) : par(N) {
        for(int i=0; i<N; i++) par[i] = i;
    }
    
    int root(int x){ // xが属する木の根
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y){ // xとyの木を併合
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
    }
    
    bool same(int x, int y){ // xとyが同じ木に属するかどうか
        return root(x) == root(y);
    }
};

int main(void){
    int N,M; cin >> N >> M;
    UnionFind uf(N);
    REP(i,M){
        int x,y,z; cin >> x >> y >> z;
        x--; y--;
        uf.unite(x,y);
    }

    VI r(N,0);
    int ans = 0;
    REP(i,N){
        int root = uf.root(i);
        if(r[root] == 0){
            r[root] = 1;
            ans++;
        }
    }

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

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

	final int N = 100;
	int[][] M = new int[N][N];

	Scanner scan = new Scanner(System.in);
	int n = scan.nextInt();

	for(int i = 0; i < n; i++){
	    for(int j = 0; j < n; j++){
		M[i][j] = 0;
	    }
	}
	for(int i = 0; i < n; i++){
	    int u  = scan.nextInt();
	    int k = scan.nextInt();
	    u--;
	    for(int j = 0; j < k; j++){
		int v = scan.nextInt();
		v--;
		M[u][v] = 1;
	    }
	}
	for(int i = 0; i < n; i++){
	    for(int j = 0; j < n; j++){
		System.out.print(M[i][j]);
		if(j < n-1) System.out.print(" ");
	    }
	    System.out.println();
	}
    }
}




Measured memory_bytes: 33976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

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

    int n;
    cin >> n;
    vector<pair<int,int>> z(n);

    for(int i = 0; i < n; i++){
        int x,y;
        cin >> x >> y;
        z[i] = make_pair(x,y);
    }

    map<pair<int,int>,int> c;

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

    int ans = 0;

    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            int p = z[j].first-z[i].first;
            int q = z[j].second-z[i].second;
            c[make_pair(p,q)]++;
            ans = max(ans,c[make_pair(p,q)]);
        }
    }

    ans = n-ans;

    cout << ans << endl;




    
    return 0;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a[12];
	for (int b = 0; b < 12; b++)cin >> a[b];
	sort(a, a + 12);
	if (a[0] == a[3] && a[4] == a[7]&&a[8]==a[11])puts("yes");
	else puts("no");
}

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

int main(){
  int n;
  cin >> n;
  map<string, int> mp;
  mp["AC"]=0;
  mp["WA"]=0;
  mp["TLE"]=0;
  mp["RE"]=0;
  rep(i,n){
    string key;
    cin >> key;
    mp[key] +=1;
  }
  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
}


Measured memory_bytes: 3628
package main
import "fmt"
func main() {
  var a,b,c,v int64
  fmt.Scan(&a,&b,&c)
  if a%2 == 0 || b%2 == 0 || c%2 == 0 {
    fmt.Println(0)
  } else {
    v = a*b
    if v > b*c { v = b*c }
    if v > c*a { v = c*a }
    fmt.Println(v)
  }
}

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

using namespace std;
typedef long long ll;
const int maxn=2e5+5;
int a[maxn],b[maxn];
int main(){ 
    int n;
    vector<int>p;
    cin>>n;
    for(int i=1;i<=n;++i)scanf("%d",&a[i]);
    for(int i=1;i<=n;++i)scanf("%d",&b[i]);
    reverse(b+1,b+n+1);
    int h1=n,q1=1,mx;
    for(int i=1;i<=n;++i){ 
        if(a[i]==b[i]){ 
            mx=a[i];
            h1=i;
            while(a[i]==b[i]){ 
                i++;
            }
            q1=i-1;
            break;
        }
    }
    for(int i=1;i<=n;++i){ 
        if(a[i]!=mx&&b[i]!=mx&&h1<=q1){ 
            swap(b[i],b[h1]);
            h1++;
        }    
    }
    if(h1<=q1){ puts("No");return 0;}
    puts("Yes");
    for(int i=1;i<n;++i)
        printf("%d ",b[i]);
    printf("%d\n",b[n]);
}


Measured memory_bytes: 5392
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int n; 
  cin >> n;

  if (n % 10 == 0) {
    cout << 'p';
  } else if (n % 10 == 1) { 
    cout << 'p';
  } else if (n % 10 == 2) { 
    cout << 'h';
  } else if (n % 10 == 3) { 
    cout << 'b';
  } else if (n % 10 == 4) { 
    cout << 'h';
  } else if (n % 10 == 5) { 
    cout << 'h';
  } else if (n % 10 == 6) { 
    cout << 'p';
  } else if (n % 10 == 7) { 
    cout << 'h';
  } else if (n % 10 == 8) { 
    cout << 'p';
  } else if (n % 10 == 9) { 
    cout << 'h';
  }

  cout << "on";
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
 
const int MAXN = 100100;
 
int n;
int a[MAXN], p[MAXN], csum[2*MAXN];
 
bool good(int c){
  for(int i=0;i<n;i++){
    if (a[i] >= c) p[i] = 1;
    else p[i] = -1;
  }
  for(int i=0;i<2*MAXN;i++) csum[i] = 0;
 
  int cs = MAXN;
  csum[cs] = 1;
  int ctot = 1;
  long long res = 0;
  for(int i=0;i<n;i++){
    if(p[i] == -1){
      ctot -= csum[cs];
      cs--;
    }else{
      ctot += csum[cs+1];
      cs++;
    }
    res += ctot;
    csum[cs]++;
    ctot++;
  }
  return res * 2 >= (n*((long long)n+1))/2;
}
 
int main(){
  cin >> n;
  for(int i=0;i<n;i++) cin >> a[i];
 
  int l=0, r=1e9;
  while(l<r){
    int mid = (l+r+1)/2;
    if(good(mid)) l = mid;
    else r = mid - 1;
  }
  cout << l << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>

#define MAX_N 200'000

typedef long long ll;

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<vector<int>> V;
  for (int i = 0; i < N; ++i) {
    int a, b;
    cin >> a >> b;
    V.emplace_back(vector<int>{b, a});
  }
  sort(V.begin(), V.end());
  ll s = 0;
  ll t = 0;
  for (auto &v : V) {
    s += v[1];
    if (s > v[0]) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
}

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

int main() {
  int N;
  cin>>N;
  std::vector<int> A(N);
  int up=0;
  int down=0;
  int ans=1;
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=1;i<N;i++){
    if(A[i]<A[i-1]&&up){
      ans++;
      up=0;
      continue;
    }
    if(A[i]>A[i-1]&&down){
      ans++;
      down=0;
      continue;
    }
    if(A[i]<A[i-1])down++;
    if(A[i]>A[i-1])up++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

const int N = 10;
bool visited[N];
vector<ll> vals;
ll cost[N][N];
int n, j;

void dfs(int i, ll s) {
	visited[i] = true;
	int outs = 0;
	for (int t = 0; t < n; ++t) {
		if (! visited[t]) {
			++outs;
			dfs(t, s + cost[i][t]);
		}
	}
	if (outs == 0 && i > j) vals.push_back(s);
	visited[i] = false;
}

bool works() {
	for (j = 0; j+1 < n; ++j) dfs(j, 0);
	sort(vals.begin(), vals.end());
	cerr << vals.back() << '\n';

	bool ans = true;
	for (int i = 0; i+1 < vals.size(); ++i) {
		if (vals[i] == vals[i+1]) ans = false;
	}
	vals.clear();
	return ans;
}

int main() {
	vector<vector<int>> xr = {
	{1},
	{1,2},
	{1,2,4},
	{1,2,4,7},
	{1,2,4,7,12},
	{1,2,4,8,13,18},
	{1,2,4,8,14,19,24},
	{1,2,4,8,15,24,29,34},
	{1,2,4,8,15,24,29,34,46}
	/*
	{1},
	{1,2},
	{1,2,4},
	{1,2,4,7},
	{1,2,4,7,12},
	{1,2,4,8,13,18},
	{1,2,4,8,14,19,24},
	{1,2,4,8,15,24,29,34},
	{1,7,10,13,21,26,41,43,45}
	*/
	};

	cin >> n;
	ll b = 1;
	for (int i = 0; i+1 < n; ++i) {
		for (j = i+1; j < n; ++j) {
			cost[i][j] = b * xr[n-2-i][j-1-i];
			cost[j][i] = cost[i][j];
		}
		if (i+2 < n) b *= (xr[n-2-i][n-2-i] + xr[n-2-i][n-3-i]);
	}
	if (works()) {
		for (int i = 0; i < n; ++i) {
			for (j = 0; j < n; ++j) {
				cout << cost[i][j] << ' ';
			}
			cout << '\n';
		}
	} else cout << "QAQ\n";
}


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

using namespace std;
using ll = long long;

int main() {
    int N = 0;
    cin >> N;
    vector<int> A(N,0);
    int now = 1;
    bool check = 0;
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
        if(A.at(i) == now) {
            now++;
            check = 1;
        }
    }
    if(!check) {
        cout << -1 << endl;
        return 0;
    }
    cout << N - now + 1 << endl;



    return 0;
}

Measured memory_bytes: 4028
n = int(input())
a = list(map(int, input().split()))
ans = []
count = 1
for i in range(n):
    if a[i] == count:
        ans.append(a[i])
        count += 1
if count == 1:
    print(-1)
else:
    print(len(a) - len(ans))

Measured memory_bytes: 85456
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n, k, x, y, ans;
    
    scanf("%d%d%d%d", &n, &k, &x, &y);
    
    if (n<k) {
        ans=n*x;
    } else {
        ans=k*x+(n-k)*y;
    }
    
    printf("%d", ans);
    
    return 0;
}



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

int	main()
{
	int N, X, T;
	int ans;

	scanf("%d", &N);
	scanf("%d", &X);
	scanf("%d", &T);
	ans = T * (N / X);
	if (N % X != 0)
		ans += T;
	printf("%d\n", ans);
	return (0);
}


Measured memory_bytes: 1736
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		
		int x3 = x2 - (y2 - y1);
		int y3 = y2 + (x2 - x1);
		
		int x4 = x3 - (x2 - x1);
		int y4 = y3 - (y2 - y1);
		
		System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);
		
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
 
bool judge(vector<bool> &bt) {
  for (int i = 0; i < 9; i += 3) {
      if (bt.at(i) && bt.at(i+1) && bt.at(i+2)) {
          return true;
      }
  }
  for (int i = 0; i < 3; i++) {
      if (bt.at(i) && bt.at(i+3) && bt.at(i+6)) {
          return true;
      }
  }
  if (bt.at(0) && bt.at(4) && bt.at(8)) {
      return true;
  }
  if (bt.at(2) && bt.at(4) && bt.at(6)) {
      return true;
  }
  return false;
}

int main() {
  vector<int> table(9,0);
  vector<bool> bt(9);
  for (int i = 0; i < 9; i++) cin >> table.at(i);
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    int j = distance(table.begin(), find(table.begin(), table.end(), K));
    if (j >= 0 && j < 9) {
        bt.at(j) = true;
    }
    if (judge(bt)) {
        cout << "Yes" << endl;
        return 0;
    }
  } 
  cout << "No" << endl;
}

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

const int MAX_W = 1e5;
ll dp[MAX_W];

int main(){
    long long N;
    scanf("%lld",&N);
    long long W;
    scanf("%lld",&W);
    std::vector<long long> w(N);
    std::vector<long long> v(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&w[i]);
        scanf("%lld",&v[i]);
    }

    for(int i=1; i<=N; i++)
        for(int j=W; j>=0; j--)
        {
            if (j-w[i-1] >= 0) dp[j] = max(dp[j], dp[j-w[i-1]] + v[i-1]);
        }

    cout << dp[W] << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
long long longpow(long long n, long long a, long long mod) {
  if (a == 0) return 1;
  if (a == 1) return n % mod;
  if (a % 2 == 1) return (n * longpow(n, a - 1, mod)) % mod;
  ll t = longpow(n, a / 2, mod) % mod;
  return (t * t) % mod;
}
int main() {
  string a, b;
  cin >> a >> b;
  string num = a + b;
  int N = 0;
  reverse(num.begin(), num.end());
  REP(i, num.size()) {
    int a = longpow(10, i, MOD);
    N += a * (num[i] - '0');
  }
  bool t = false;
  for (int i = 1; i <= 10000; i++)
  {
    if(longpow(i,2,MOD)==N){
      t = true;
      break;
    }
  }
  puts(t ? "Yes" : "No");
}

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

int main() {

int N, Alice, Bob;
  Alice = 0;
  Bob = 0;
cin >> N;
vector<int> vec(N);
for(int i = 0; i < N; i++)
{

cin >> vec.at(i);

}

sort(vec.begin(), vec.end());
reverse(vec.begin(), vec.end());
for(int i = 0; i < N; i += 2)
{

Alice += vec.at(i);

}

for(int i = 1; i < N; i += 2)
{

Bob += vec.at(i);

}

cout << Alice - Bob << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
int n;
int k;
vector <int> v;
int main(){
    cin >> n >> k;
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    //cout << "aaaa" << endl;
    int ans = 0;
    int a_max = min(n,k);
    for(int a=0;a<=a_max;a++){
        for(int b=0;b<=a_max-a;b++){

            vector <int> out;
          // cout << a << " " << b <<endl;
            int sum = 0;
            for(int i=0;i<a;i++){

               // cout << "v" << i << "=" << v[i]<<endl;
                sum += v[i];
                out.push_back(v[i]);
               }
            for(int i =0;i<b;i++){

               // cout << "v" << n-i-1 << "=" << v[n-i-1]<<endl;
                sum += v[n-i-1];
                out.push_back(v[n-i-1]);
            }

            sort(out.begin(),out.end());
           
            for(int i=0;i<min((k-a-b),(int)out.size());i++){
                if(out[i]<0){
                      //cout << "out"<<i << "=" << out[i]<< endl;

                    sum -=out[i];
                }
                else{
                    break;
                }
            }
          //  cout << "a=" << a << "b=" << b << "sum=" << sum << endl;
            if(sum > ans){
                ans = sum;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define RANGE(i,a,b) for(int i=(a);i<=(b);i++)
#define RANGER(i,a,b) for(int i=(b);i>=(a);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)
using ll=long long int;
using vi=vector<int>;
using vvi=vector<vi>;
using pi=pair<int,int>;
constexpr int INF=1<<30;
constexpr ll INTL=1ll<<60;
int main(){
  int n,d;
  vvi x;
  cin>>n>>d;
  REP(i,n){
    vi xx;
    REP(j,d){
      int xxx;
      cin>>xxx;
      xx.push_back(xxx);
    }
    x.push_back(xx);
  }
  int r=0;
  REP(i,n) REP(j,i){
    int pow2=0;
    REP(k,d){
      pow2+=pow(x[i][k]-x[j][k],2);
    }
    if(pow(int(sqrt(double(pow2))),2)==pow2)
    r++;
  }
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, int> pii;
#define f(i, l, r) for (int i = l; i <= r; i++)
#define rf(i, r, l) for (int i = r; i >= l; i--)
#define all(x) (x).begin(), (x).end()
#define sf(a) scanf("%d",&a)
#define llsf(a) scanf("%lld", &a)
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))

const int inf = 2e9 + 7;
const ll INF = INT64_MAX;
double eps = 1e-6;
int mod = 1e9 + 7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);

char s[N];
int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	scanf("%s", s);
	int w = strlen(s);
	f(i, 0, w - 2) {
		if (s[i] == s[i + 1]) {
			cout << i+1 << " " << i + 2; return 0;
		}
	}
	f(i, 0, w - 3) {
		if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3; return 0;
		}
	}
	cout << -1 << " " << -1;
}

Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;
ll INF=1e10;
vector<ll>cnt(1e7);
Graph G(1e7);
void dfs(ll v,ll p){
    for(auto nv:G[v]){
        if(nv==p)continue;
        cnt[nv]+=cnt[v];
        dfs(nv,v);
    }
}
int main(){
  ll n,q; cin>>n>>q;
  G.resize(n);
  rep(i,n-1){
      ll a,b; cin>>a>>b;
      a--;b--;
      G[a].push_back(b);
      G[b].push_back(a);
  }
  cnt.resize(n);
  rep(i,q){
      ll p,q; cin>>p>>q;
      p--;
      cnt[p]+=q;
  }
  dfs(0,-1);
  rep(i,n){
      cout<<cnt[i]<<" ";
  }
  cout<<endl;
}



























































































Measured memory_bytes: 331376
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    _, k = mi()
    h_passed = list(filter(lambda x: x>=k, lmi()))
    print(len(h_passed))


if __name__ == "__main__":
    main()

Measured memory_bytes: 11880
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


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

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

int main(void) {

  int n;
  string s;
  set<string> set;

  cin >> n;
  rep(i, n) {
    cin >> s;
    set.insert(s);
  }

  cout << set.size() << endl;
}


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

int main() {
    long long H;
    cin >> H;
    long long i=0;
    long long ans=0;
    while (H>=1) {
        ans += pow(2,i);
        H/=2;
        i++;
    }
    cout << ans << endl;
}

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

long N;int rec=0;
bool TFS[3];

bool judge(long m){
    if(m<=N){
        TFS[0]=false;TFS[1]=false;TFS[2]=false;
        while(m>0){
            TFS[((m%10)-3)/2]=true;
            if(TFS[0]&&TFS[1]&&TFS[2]){
                rec++;
                return true;
            }m=m/10;
        }return true;
    }else{
        return false;
    }
}
void func(long n){    
    if(judge(10*n+3)){
        func(10*n+3);
    }if(judge(10*n+5)){
        func(10*n+5);
    }if(judge(10*n+7)){
        func(10*n+7);
    }return;
}

int main(){
    cin>>N;
    func(0);
    cout<<rec<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
#define forn(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define FORR(i,a,b) for(int i = a; i >= b; i--)

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;

const double EPS = 1e-9;

void solve(){
    int n;
    double k;
    cin >> n >> k;

    double ans = 0.0;
    for(int i = 1; i <= n; i++){
        double op = 1.0/n;
        double coin = 1;
        double value = (double)i;
        while(value+EPS < k){
            coin = coin*(0.5);
            value *= 2;
        }
        ans += op * coin;
    }
    printf("%.12lf\n", ans);
}

int main(){
    //int t; cin >> t;
    //while(t--) solve();

    solve();
    return 0;
}


Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 500 + 10;

ll a[N][N], f[N][N], b[N][N];
ll dp[N][N];

int main() {
	// cout << sizeof(dp) / 1e6 << endl;
	fast_cin();
	int n; cin >> n;
	ll sum = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			if (i != j) {
				cin >> a[i][j];
				sum += a[i][j];
			}
		}
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			f[i][j] = f[i][j - 1] + a[j][i];
		}
		for (int j = i - 1; j >= 1; --j) {
			b[i][j] = b[i][j + 1] + a[i][j];
		}
	}
	ll ans = 0;
	for (int i = 1; i < n; ++i) {
		for (int j = i; j >= 0; --j) {
			for (int k = j; k >= 0; --k) {
				ll cost = dp[j][k] + f[i + 1][j] + b[i + 1][k + 1];
				dp[i + 1][j] = max(dp[i + 1][j], cost);
				dp[j][k] = cost;
				ans = max(ans, cost);
			}
		}
	}
	cout << sum - ans << endl;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,k,n) for(ll i = k;i<n;i++)
#define mo unordered_map<ll,ll> 
#define mi map<ll,map<ll,ll>>


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n;
    cin>>n;
   ll action = 0;
   ll mul = 1;
   while(n != 0){
  if(n>1){
  	if(n%2 == 0){
  		n = n/2;
  		action += mul;
  		mul *= 2;
  	}
  	else{
  		if(n%2 == 1){
  		n = n/2;
  		action += mul;
  		mul *= 2;
  	}
  	}
  	
  }
  else{
  	if(n == 1){
  	action += mul;
  	 n = 0;
  	 break;
  }
  }
   }
   cout<<action<<"\n";
    
    
    }

Measured memory_bytes: 256
/*
    Problem 1
    https://onlinejudge.u-aizu.ac.jp/problems/ITP1_7_B
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 1000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
vector<int> a(MAX);
int n, k;
int ans;
/* function */
void dfs(int cnt, int cur, int ind) {
    if (cnt == 3) {
        if (cur == k) ans++;
        return ;
    }
    if (ind >= n) return ;
    dfs(cnt + 1, cur + a[ind], ind + 1);
    dfs(cnt, cur, ind + 1);
}

/* main */
int main(){
    for (int i = 0; i < MAX; i++) a[i] = i+1;
    while (1) {
        cin >> n >> k;
        if (n+k == 0) return 0;
        ans = 0;
        dfs(0, 0, 0);
        cout << ans << '\n';
    }
}



Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  long long s=0,a,b,n,c=1e18;
  scanf("%lld",&n);
  while(n--){
    scanf("%lld %lld",&a,&b);
    s+=a;
    if(a>b&&c>b)c=b;
  }
  if(s<c)c=s;
  printf("%lld\n",s-c);
  return 0;
}


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

int main() {
	int A, B, M;
	cin >> A >> B >> M;
	vector<int> a(A,0);
	vector<int> b(B,0);
	for (int i = 0; i < A; i++) cin >> a[i];
	for (int i = 0; i < B; i++) cin >> b[i];
	vector<int> x(M, 0);
	vector<int> y(M, 0);
	vector<int> c(M, 0);
	for (int i = 0; i < M; i++) {
		cin >> x[i] >> y[i] >> c[i];
		x[i]--;
		y[i]--;
	}

	int Amin = 1000000;
	int Bmin = 1000000;
	for (int i = 0; i < A; i++) Amin = min(Amin, a[i]);
	for (int i = 0; i < B; i++) Bmin = min(Amin, b[i]);

	int Min = Amin + Bmin;
	for (int i = 0; i < M; i++) Min = min(Min, a[x[i]] + b[y[i]] - c[i]);
	cout << Min;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int n; cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    vector<int> v(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    rep(i,n) v[i] = i+1;
    int a,b,count = 1;
    do {
        bool isOK = true;
        rep(i,n) {
            if(p[i]!=v[i])
                isOK = false;
        }
        if(isOK)
            a = count;
        isOK = true;
        rep(i,n) {
            if(q[i]!=v[i])
                isOK = false;
        }
        if(isOK)
            b = count;
        count++;
    } while (std::next_permutation(v.begin(), v.end()));
    cout << abs(a-b) << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Main main = new Main();
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		Map<Integer, Answer> map = new HashMap<>();
		for (int i = 0; i < M; i++) {
			int p = sc.nextInt();
			String ans = sc.next();
			if (map.containsKey(p)) {
				Answer nowAns = map.get(p);
				if (ans.equals("AC")) {
					nowAns.setAc(true);
				} else if (!nowAns.getAc()) {
					nowAns.Add();
				}
			} else {
				Answer answer = main.new Answer(ans);
				map.put(p, answer);
			}
		}
		int acCount = 0;
		int waCount = 0;
		for (Integer key : map.keySet()) {
			Answer nowAns = map.get(key);
			if (nowAns.getAc()) {
				acCount++;
				waCount += nowAns.getWa();
			}
		}
		System.out.println(acCount + " " + waCount);
	}
	
	public class Answer {
		
		public Answer(String key) {
			if (key.equals("AC")) {
				this.ac =true;
			} else {
				this.wa++;
			}
		}
		
		public boolean ac = false;
		public int wa = 0;
		
		public boolean getAc() {
			return this.ac;
		}
		
		public void setAc(boolean b) {
			this.ac = true;
		}
		
		public void Add() {
			this.wa++;
		}
		
		public int getWa() {
			return this.wa;
		}
	}
}

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

int main() {
  int N,X,T;
  cin >> N >> X >> T;
  
  int pertime;
  if (N%X == 0) {
    pertime = N/X;
  }
  else {
    pertime = N/X+1;
  }
  
  cout << pertime*T << endl;  
  
}

Measured memory_bytes: 3628