akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  long long int cnt=0,ans=0,N;
  cin>>N;
  vector<long long int> A(N);
  for(long long int i=0;i<N;i++){
    cin>>A.at(i);
  }
  
  vector<long long int> B(N);
  for(long long int i=0;i<N;i++){
    B.at(A.at(i)-1)++;
  }
  long long int sum=0;
  for(long long int i=0;i<N;i++){
    sum+=B.at(i)*(B.at(i)-1)/2;
  }
  for(long long int i=0;i<N;i++){
    if(B.at(A.at(i)-1)>0)cout<<sum-B.at(A.at(i)-1)+1<<endl;
    else cout<<sum<<endl;
  }
}


Measured memory_bytes: 5760
'use strict'

function main(input) {

    input = input.split('\n')
    let n = ~~input[0]
    let x = input[1].split(' ').map(v => ~~v) //.sort((a, b) => a - b)
    let x2 = input[1].split(' ').map(v => ~~v).sort((a, b) => a - b)
    let mid = x2[n / 2]
    let index = 0
    for (let i = 0; i < n; i++) {

        // 
        if (x[i] < mid) {
            index = (n) / 2

        } else {
            index = (n) / 2 - 1
        }

        console.log(x2[index])

    }
}

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

Measured memory_bytes: 67788
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long H = long.Parse(str[0]);
		long W = long.Parse(str[1]);
		long[,]A = new long[H,W];
		for(var i=0;i<H;i++){
			string[] str2 = Console.ReadLine().Split();
			for(var j=0;j<W;j++){
				A[i,j] = long.Parse(str2[j]);
			}
		}
		long ih = 0;
		long iw = 0;
		long ct = 0;
		long[,]AN = new long[H*W,4];
		while(true){
			if(A[ih,iw] % 2 == 1){
				if(iw < W-1){
					A[ih,iw] -= 1;
					A[ih,iw+1] += 1;
					AN[ct,0] = ih+1;
					AN[ct,1] = iw+1;
					AN[ct,2] = ih+1;
					AN[ct,3] = iw+2;
					ct += 1;
				}
			}
			if(A[ih,iw] % 2 == 1){
				if(ih < H-1){
					A[ih,iw] -= 1;
					A[ih+1,iw] += 1;
					AN[ct,0] = ih+1;
					AN[ct,1] = iw+1;
					AN[ct,2] = ih+2;
					AN[ct,3] = iw+1;
					ct += 1;
				}
			}
			iw += 1;
			if(iw >= W){
				ih += 1;
				iw = 0;
			}
			if(ih >= H){
				break;
			}
		}
		Console.WriteLine(ct);
		for(var i=0;i<ct;i++){
			Console.WriteLine(AN[i,0]+" "+AN[i,1]+" "+AN[i,2]+" "+AN[i,3]);
		}
	}
}

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

int main(void)
{
 int n,m,i,j,cnt[100],max;
 char bul[100][11],red[100][11];
 
 scanf("%d",&n);
 for(i=0;i<n;i++){
  scanf("%s",bul[i]);
 }
 scanf("%d",&m);
 for(i=0;i<m;i++){
  scanf("%s",red[i]);
 }

 for(i=0;i<n;i++){
  cnt[i]=0;
  for(j=0;j<n;j++){
   if(strcmp(bul[i],bul[j])==0)
    cnt[i]++;
  }
  for(j=0;j<m;j++){
   if(strcmp(bul[i],red[j])==0)
    cnt[i]--;
  }
 }
 
 max=0;
 for(i=0;i<n;i++){
  if(cnt[i]>max)
   max = cnt[i];
 }

 printf("%d",max);

 return 0;
}

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

int main()
{
    int N;
    int l, r;
    int ans = 0;

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> l >> r;
        ans += abs(l - r) + 1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	string s, t = "2019/04/30";
	cin >> s;
	if (s > t) {
		cout << "TBD" << endl;
	}
	else {
		cout << "Heisei" << endl;
	}
	return 0;
}


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

signed main(){
    int x,y;cin>>x>>y;
    int ans=0;
    while(x!=y){
        if(x>0){
            if(abs(x)>abs(y)) x=-x,ans++;
            else if(y<0) ans+=-y-x+1,x=y;
            else ans+=y-x,x=y;
        }else if(x==0){
            x=abs(y);ans+=x;
        }else{
            if(abs(x)>abs(y)) ans+=abs(x)-abs(y),x=-abs(y);
            else if(abs(x)==abs(y)) x=y,ans++;
            else ans++,x=-x;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int n;
ll k, a[200000];

// o(nlogn)
bool check(ll x) {
    ll cnt = 0;
    int suf;
    for (int i = 0; i < n; ++i) { // 積がx未満
        if (a[i] < 0) {
            if (x > 0) {
                if (x % a[i] == 0)
                    suf = upper_bound(a, a + n, x / a[i]) - a;
                else
                    suf = lower_bound(a, a + n, x / a[i]) - a;
                cnt += n - max(i + 1, suf);
            }
            else {
                suf = upper_bound(a, a + n, x / a[i]) - a;
                cnt += n - suf;
            }
        }
        else if (a[i] > 0) {
            if (x > 0) {
                if (x % a[i] == 0)
                    suf = lower_bound(a, a + n, x / a[i]) - 1 - a;
                else
                    suf = upper_bound(a, a + n, x / a[i]) - 1 - a;
                cnt += max(0, suf - i);
            }
            else {
                cnt += 0; // i < jで存在しない
            }
        }
        else if (x > 0) { // a[i] == 0
            cnt += n - i - 1;
        }
    }
    if (cnt < k)
        return true;
    return false;
}

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

    ll l = -1e18, r = 1e18 + 1, mid; // l:ok, r:ng
    while (l + 1 < r) { // l + 1 == r となったら終了
        mid = (l + r) / 2;
        if (check(mid)) {
            l = mid;
        }
        else {
            r = mid;
        }
    }
    cout << l << endl;

    return 0;
}

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

int main(){
  int N,count=0;
  string A;
  cin>>N;
  cin>>A;
  
  for(int i=0;i<N;i++)
  {
    if ((int(A[i])-82)==0){
      count++;
    }
  }
  
  if (count>(N-count)){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
import scipy.misc as ms

n,a,b = map(int, raw_input().split())
v = map(int, raw_input().split())
v = sorted(v)[::-1]
sum = 0.0
for i in range(a): sum += v[i]
print "%.6f" % (sum / a)

m = v[a-1]
c = 0
al = 0
for i in range(a):
	if v[i] == m: c += 1
for i in range(n):
	if v[i] == m: al += 1

ans = 0
if int(sum / a) != m:
	print ms.comb(al, c, 1)
	exit(0)
for i in range(c, min(al, b) + 1):
	ans += ms.comb(al, i, 1)
print ans


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
#define mp            make_pair
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

const int SZ = 1 << 19;
int n, _n;
int x[111111];
ll dp[4 * SZ + 1];

void init(int n)
{
  _n = 1;
  while(_n < n) _n *= 2;
}

void update(int k, ll x)
{
  k += _n - 1;
  dp[k] = x;
  while(k > 0){
    k = (k - 1) / 2;
    dp[k] = max(dp[2 * k + 1], dp[2 * k + 2]);
  }
}

ll query(int a, int b, int k = 0, int l = 0, int r = _n)
{
  if(r <= a || b <= l) return 0;
  if(a <= l && r <= b) return dp[k];
  return max(query(a, b, 2 * k + 1, l, (l + r) / 2),
             query(a, b, 2 * k + 2, (l + r) / 2, r));
}

int main(int argc, char *argv[])
{
  cin >> n;
  rep(i, n) cin >> x[i];

  ll res = 0;
  init(n);
  rep(i, n){
    update(x[i], query(1, x[i] + 1) + x[i]);
    maxup(res, query(x[i], x[i] + 1));
  }

  cout << (ll)n * (n + 1LL) / 2LL - res << endl;
    
  return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int k, x;
    cin >> k >> x;
    if (k * 500 >= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  int LEN, i;
  cin >> S;

  LEN = S.size();
  int ans = 0;
  
  if (LEN % 2 == 1 ){
    cout << "No" << endl;
    return 0;
  } else {
    for(i = 0; i < LEN; i++){
      if(i % 2 == 0){
        if(S[i] != 'h'){
          ans += 1;
        }
      } else {
        if(S[i] != 'i'){
          ans += 1;
        }
      }
    }

    if (ans > 0){
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;    
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{

	long int n,k,i,j;
  long double p[200001],max,sum;
  sum=0;
  max=0;
(void) scanf("%ld %ld",&n,&k);
  
  for (i=1;i<=n;i++)
  {
(void) scanf("%llf",&p[i]);
   p[i]=(p[i]+1)/2;
  }
  
  for (i=1;i<=k;i++)
  {
  	sum+=p[i];
  }
  
  if (n==k)
  {
  	printf("%llf",sum);
    return 0;
  
  }
  
  //printf("%llf\n",sum);
  
  for (i=k+1;i<=n;i++)
   {
   sum=sum+p[i];
   sum=sum-p[i-k];
    //printf("%llf %llf %llf \n",p[i],p[i-k],sum);
    if (sum>max)
    {
    	max=sum;
    }   
  }
  
  
  printf("%llf",max);
  return 0;

}


Measured memory_bytes: 4840
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<iomanip>

using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

int atcoder(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    REP(i,0,n) cin>>a[i];
    ll x,y=0;
    x = *max_element(ALL(a));
    ll check=LLONG_MAX;
    REP(i,0,n){
        if(abs(x-a[i]-x/2)<check && a[i]!=x){
            y=a[i];
            check=abs(x-a[i]-x/2);
        }
    }
    cout << x << " " << y << ENT;
    return 0;
}


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


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}
///////////////////////////////////////////////////////////////

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  sort(all(a));
  int p = a[n-1];
  int k = lower_bound(all(a),(p+1) / 2) - a.begin();
  if (a[k] - (p+1) / 2 > p / 2 - a[k-1]) k--;
  if (a[k] == p) k--;
  cout << p << " " << a[k] << endl;
}

Measured memory_bytes: 640
N, M = gets.split.map(&:to_i)

list = Array.new( N ).map{ gets.split.map(&:to_i)  }

list.sort!

ans = 0

m = M

list.each do |l|
  
  l[1] = m if l[1] > m  
  
  ans += l[0] * l[1]
  
  m -= l[1] 
  
  break if m <= 0
  
end

p ans

Measured memory_bytes: 11128
N = int(input())
A = list(map(int,input().split()))
cnt = [0] * (N + 1)
total = 0
for i in range(N):
    total += cnt[A[i]]
    cnt[A[i]] += 1
for i in range(N):
    ans = total - (cnt[A[i]] - 1)
    print(ans)

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

int N,M,W,T;
map<string,int> mp;
string s[7];
ll v[7],p[7],l[7],x[7],y[7];
ll dp[100001];
vector<string> R[7];
vector<ll> Q[7];
ll a[(1<<7)],b[(1<<7)];

int main(){
  cin>>N>>M>>W>>T;
  for(int i=0;i<M;i++){
    cin>>s[i]>>v[i]>>p[i];
    assert(mp.count(s[i])==0);
    mp[s[i]]=i;
  }
  for(int i=0;i<N;i++){
    cin>>l[i]>>x[i]>>y[i];
    R[i].resize(l[i]);
    Q[i].resize(l[i]);
    for(int j=0;j<l[i];j++){
      cin>>R[i][j]>>Q[i][j];
      assert(mp.count(R[i][j])>0);
    }
  }
  for(int S=1;S<(1<<N);S++){
    vector<int> k;
    for(int i=0;i<N;i++)
      if(S>>i&1)k.push_back(i);
    ll mini=1e9;    
    do{
      ll cnt=0,px=0,py=0;
      for(int i=0;i<(int)k.size();i++){
        cnt+=abs(px-x[k[i]]);
        cnt+=abs(py-y[k[i]]);
        px=x[k[i]];
        py=y[k[i]];
      }
      cnt+=abs(x[k.back()]);
      cnt+=abs(y[k.back()]);
      mini=min(mini,cnt);
    }while(next_permutation(k.begin(),k.end()));
    
    if(mini>T)continue;
    memset(dp,0,sizeof(dp));
    vector<ll> c(M,0);
    for(int i=0;i<N;i++){
      if(S>>i&1){
        for(int j=0;j<l[i];j++){
          int id=mp[R[i][j]];
          c[id]=max(c[id],p[id]-Q[i][j]);
        }
      }
    }
    for(int i=0;i<M;i++){
      for(int j=v[i];j<=W;j++){
        dp[j]=max(dp[j],dp[j-v[i]]+c[i]);
        a[S]=max(a[S],dp[j]);
      }
    }
    b[S]=mini;
  }
  ll ans=0;
  memset(dp,0,sizeof(dp));
  for(int i=1;i<(1<<N);i++){
    for(int j=b[i];j<=T;j++){
      dp[j]=max(dp[j],dp[j-b[i]]+a[i]);
      ans=max(ans,dp[j]);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2040
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
using namespace std;
int test[123456], uiop[123456];
signed main() {
	int n, m, k, a, b = 100000000000, ans = 0; string s, t; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> a; b = min(a, b);
		if (a <= b) {
			ans++;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

string s;

int main() {
  cin >> s;
  if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
    cout << "Yes" <<endl;
  else cout << "No" <<endl;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
#define ALL(x) (x).begin(),(x).end()
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

vector<pll> AB;

signed main() {
    ll N, M;
    cin >> N >> M;
    AB.resize(N);
    ll ai, bi;
    REP(i, N) {
        cin >> ai >> bi;
        AB[i] = make_pair(ai, bi);
    }

    sort(ALL(AB));

    ll idx = 0;
    ll cnt = 0;
    ll mn = 0;
    REP(i, N) {
        if (cnt + AB[i].second >= M) {
            idx = i;
            break;
        }
        cnt += AB[i].second;
        mn += AB[i].first * AB[i].second;
    }
    ll cnt2 = M - cnt;
    ll ans = mn + cnt2 * AB[idx].first;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n;
  cin >> n;
  vi t(n);
  ll total = 0;
  rep(i, n){
    cin >> t[i];
    total += t[i];
  }
  ll m;
  cin >> m;
  rep(i,m){
    ll sum = total;
    ll p, x;
    cin >> p >> x;
    sum += x - t[p - 1];
    print(sum);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = (int)1e5 + 777;

int parent[MAXN], cnt[MAXN];
int n, m;

void init_DSU() {
	for(int i = 0; i < n; ++i) {
		parent[i] = i;
		cnt[i] = 1;
	}
}

int get_parent(int i) {
	while(parent[i] != i) {
		i = parent[i];
	}

	return i;
}

int connect(int i, int j) {
	i = get_parent(i);
	j = get_parent(j);

	if(i != j) {
		if(cnt[i] > cnt[j]) {
			swap(i, j);
		}

		parent[i] = j;
		cnt[j] += cnt[i];

		return 1;
	} else {
		return 0;
	}
}

void solve() {
	n = fetch<int>();
	m = fetch<int>();
	init_DSU();

	int answ = n;

	for(int i = 0; i < m; ++i) {
		int x = fetch<int>() - 1;
		int y = fetch<int>() - 1;
		int z = fetch<int>();

		answ -= connect(x, y);
	}

	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int n, k,ans =0,sum;cin >> k >> n;
	rep(z, k+ 1) {
		sum = n - z;
		rep(x, k + 1) {
			if (sum - x >= 0 &&sum - x <= k) ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int H, W;
	cin >> H >> W;
	vector<string> A(H);
	for(int i = 0; i < H; i++) cin >> A[i];
	int dx[] = {1, -1, 0, 0};
	int dy[] = {0, 0, 1, -1};
	queue< pair<int, int> > q;
	vector< vector<int> > dist(H, vector<int>(W, -1));
	for(int i = 0; i < H; i++) for(int j = 0; j < W; j++)
		if(A[i][j] == '#') {
			q.push({i, j});
			dist[i][j] = 0;
		}
	while(!q.empty()) {
		for(int i = 0; i < 4; i++) {
			pair<int, int> p = {q.front().ff+dx[i], q.front().ss+dy[i]};
			if(p.ff < 0 || p.ss < 0 || p.ff >= H || p.ss >= W) continue;
			if(dist[p.ff][p.ss] == -1) {
				dist[p.ff][p.ss] = dist[q.front().ff][q.front().ss]+1;
				q.push(p);
			}
		}
		q.pop();
	}
	int maxdist = 0;
	for(int i = 0; i < H*W; i++) maxdist = max(maxdist, dist[i/W][i%W]);
	cout << maxdist << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 13456
// Author: Amey Bhavsar
// IDE: Geany/Ubuntu
// Platform: CF

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;

#define bpc __builtin_popcount
#define bpcl __builtin_popcountll
#define bpr __builtin_parity
#define bprl __builtin_parityll
#define ctz __builtin_ctz
#define ctzl __builtin_ctzll
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second


// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define MOD 1000000007

//make sure to change MAXN according to constraints
#define MAXN 100001

ll t,n,k,a[MAXN];
void solution() {
	
	cin >> n >> k;
	rep(i,1,n+1) {
		a[i] = 0;
	}
	int d,x;
	rep(i,0,k) {
		cin >> d;
		rep(j,0,d) {
			cin >> x;
			a[x]++;
		}
	}
	
	int cnt = 0;
	rep(i,1,n+1) {
		if (a[i] == 0)
			cnt ++;
	}
	//~return cnt;
	cout << cnt;
}

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	//~cin >> t;	
	//~while(t--) {
		solution();
	//~}
	return 0;
}


Measured memory_bytes: 3592
A=int(input())
B=int(input())
C=int(input())
X=int(input())
n=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500+j*100+50*k==X :
                n+=1
            else :
                n+=0
print(n)


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

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

  vector<int> W(N);
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> W[i];
    sum += W[i];
  }

  int mini = sum;
  int prefix_sum = 0;
  for(int i = 0;i < N; i++){
    prefix_sum += W[i];
    mini = min(mini, abs(prefix_sum - (sum - prefix_sum)));
  }

  cout << mini << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	
	double r,s,pi,l;
	scanf("%lf",&r);
	pi=3.141592653589;
	s=r*r*pi;
	l=2*r*pi;
	printf("%lf %lf \n",s,l);
	
	
	 return 0;
}

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

int main()
{
	int n;
	cin>>n;
    
    if(n>=400 && n<=599)
        cout<<8;
    else if(n>=600 && n<=799)
        cout<<7;
    else if(n>=800 && n<=999)
        cout<<6;
    else if(n>=1000 && n<=1199)
        cout<<5;
    else if(n>=1200 && n<=1399)
        cout<<4;
    else if(n>=1400 && n<=1599)
        cout<<3;
    else if(n>=1600 && n<=1799)
        cout<<2;
    else if(n>=1800 && n<=1999)
        cout<<1;

    return 0;
}
    

Measured memory_bytes: 3604
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
for i in range(N):
    b  = B[i]
    a  = A[i]
    a2 = A[i+1]

    if a <= b:
        ans += a
        A[i] = 0
        b -= a
    else:
        ans += b
        A[i] -= b
        b = 0

    if b > 0:
        if a2 <= b:
            ans += a2
            A[i+1] = 0
            b -= a2
        else:
            ans += b
            A[i+1] -= b
            b = 0
print(ans)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    vector<vector<int>> v(3,vector<int>(3));
    REP(i,3) REP(j,3) cin >> v[i][j];
    int n; cin >> n;
    vector<vector<bool>> v2(3,vector<bool>(3));
    REP(i,n) {
        int b; cin >> b;
        REP(j,3) REP(k,3) {
            if (v[j][k] == b) v2[j][k] = true;
        }
    }

    bool ans = false;
    REP(i,3) {
        bool tmp = true;
        REP(j,3) {
            if (!v2[i][j]) tmp = false;
        }
        if (tmp) ans = true;
    }
    REP(i,3) {
        bool tmp = true;
        REP(j,3) {
            if (!v2[j][i]) tmp = false;
        }
        if (tmp) ans = true;
    }

    bool tmp = true;
    REP(j,3) {
        if (!v2[j][j]) tmp = false;
    }
    if (tmp) ans = true;

    tmp = true;
    REP(j,3) {
        if (!v2[2-j][j]) tmp = false;
    }
    if (tmp) ans = true;

    ATYN(ans)

    return 0;
}

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

int main(){
    int A,N;
    0<=A<=1000;
    1<=N<=10000;
    cin>>N;
    cin>>A;
    int n=int(N/500);
    if(N-n*500<=A){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define in freopen("input.txt", "r" ,stdin)
#define out freopen("output.txt", "w" , stdout)
#define ll long long
#define inf 200005
#define fr first
#define  sc second
#define pb push_back
#define p_b pop_back
#define mp make_pair
#define N 100100
using namespace std;
int n,m;
vector <int> g[100005];
vector <int> order;
bool used[100005];
bool used1[100005];
int dp[100005];
void dfs (int v){
used[v] = 1;
for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (!used[to]){
        dfs (to);
    }
}
order.pb (v);
}

void dfs1 (int v) {
used1[v] = 1;
for (int i = 0; i < g[v].size(); i++){
     int to = g[v][i];
     dp[to] = max (dp[to] , dp[v] + 1);
     if (!used1[to]){
        dfs1(to);
     }
}
}
int main (){
//in;out;
ios_base::sync_with_stdio(0);
cin >> n >> m;
for (int i = 1; i <= m; i++){
     int x , y;
     cin >> x >> y;
     g[x].pb (y);
}

for (int i = 1; i <= n; i++){
    if (!used[i]) {
         dfs (i);
    }
}
reverse(order.begin() , order.end());

for (int i = 0; i < order.size(); i++)
{
    int to = order[i];
      dfs1 (to);
}
int ans = 0;
for (int i = 1; i <=n; i++){
    ans = max (ans , dp[i]);
}
cout << ans;
}



Measured memory_bytes: 11512
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー
#include <stack>
#include <bitset>

#define rep(i,m,n) for(int i=(m);i<(n);i++)
#define mer(i,m,n) for(int i=(m);i>(n);--i)

#define MOD 1000000007
//#define MOD 998244353
//#define MAX 

using namespace std;

using ll = long long int;
using ld = long double;
using std::swap;

vector<int> v;
vector<int> w;
vector<long long int> vll;
vector<long long int> wll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<vector<int>> ww;
//vector<char> vc;
vector<string> vs;




int main() {
	
	int D;
	cin >> D;
	v.resize(D + 1,0);
	w.resize(27, 0);
	vector<int> x(27, 0);
	vector<int> c(27);
	vv.resize(D + 1, vector<int>(27, 0));

	rep(i, 1, 27)cin >> c[i];
	rep(i, 1, D+1) {
		rep(j, 1, 27)cin >> vv[i][j];
	}

	rep(i, 1, D+1) {
		int t, ans = 0;
		cin >> t;
		rep(j, 1, 27) {
			if (j == t)ans += vv[i][j];
			else ans -= c[j] * (i - x[j]);
		}
		x[t] = i;
		v[i] = ans + v[i - 1];
	}
	rep(i, 1, D + 1)cout << v[i] << '\n';
	return 0;
}

Measured memory_bytes: 3676
// Problem : D - Redistribution
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
const long long int  modu=1e9+7;
#define endl '\n'
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define inp(x)  for(auto &t:x) cin>>t;
#define itr     vector<int>::iterator
#define debug(a) cout << #a << "=" << a << ' '<<endl;
#define out(x)  for(auto &t:x) cout<<t<<" "; cout<<endl;
#define ff first
#define ss second
#define pb push_back
#define initialize(a,v)  for(int i=0;i<a.size();++i) a[i]=v;
#define all(x) x.begin(),x.end()
#define mpt(mp) for(auto it=mp.begin();it!=mp.end();it++)
#define trav(x) for(int i=0;i<(int)x.size();++i)
#define mkp(a,b) make_pair(a,b)
#define sz(x)  (int)x.size()

int noofdig(int N)
{
	return floor(log10(N))+1;
}


ll f(ll a)
{

return 0;

}



void pre()
{

}



void solve()
{
   
   int n;
   cin>>n;
   
   ll dp[n+1]={0};
   dp[0]=1;
   
   for(int i=3;i<=n;++i)
   {
   	for(int j=3;j<=i;++j)
   	{
   		dp[i]+=dp[i-j];
   		dp[i]%=modu;
   	}
   }
   
   cout<<dp[n]%modu<<endl;

}

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

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


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
    int N;
    cin>>N;
    bool a=false;
    rep(i,500000){
        if(int(i*1.08)==N){
            cout<<i<<endl;
            a=true;
            break;
        }
    }
    if(a==false){
        cout<<":("<<endl;
    }
}


Measured memory_bytes: 3596
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    loop {
        let h: u32 = sc.read();
        let w: u32 = sc.read();
        if h == 0 { break }
        let row: String = (0..w).map(|_| '#').collect();
        for _ in 0..h {
            println!("{}", row);
        }
        println!("");
    }
}



Measured memory_bytes: 5024
inputs = []
loop do
    input = gets.split(" ")
    if input[0] == "0" && input[1] == "0"; break; end
    inputs << input
end

inputs.each do |row_column|
    row_column[0].to_i.times do |i|
        row_column[1].to_i.times do |j|
            if (i + j) % 2 == 0
                print "#"
            else
                print "."
            end
        end
        print "\n"
    end
    print "\n"
end


Measured memory_bytes: 6860
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str=new String();
		String p = new String();
		int count=0;
		 p = scan.next();
		 
		 while(scan.hasNext()){
		 str =  scan.next();
		 if(str.equals("END_OF_TEXT"))break;
		 	if(str.equalsIgnoreCase(p))count++;
		}
		 
		 System.out.println(count);
	}
}

Measured memory_bytes: 26200
#include <stdio.h>

int main() {
  int N;
  scanf("%d", &N);

  int A[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }

  int max = 0, def;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      def = A[i] - A[j];
      if (def < 0) {
        def *= -1;
      }
      if (max < def) {
        max = def;
      }
    }
  }

  printf("%d\n", max);

  return 0;
}


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

int Abs(int n){
  return n < 0 ? -n : n;
}
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> dp(n,0);
  vector<int> h(n);
  for(int i = 0; i < n; i++)
    cin>>h[i];
  for(int i = 1; i <= k && i < n; i++)
    dp[i] = Abs(h[i]-h[0]);
  for(int i = k+1; i < n; i++){
    dp[i] = dp[i-1]+Abs(h[i]-h[i-1]);
    for(int j = 1; j <= k && j <= i; j++){
      dp[i] = min( dp[i], dp[i-j]+Abs(h[i]-h[i-j]) );
    }
  }
  cout << dp[n-1] << "\n";
  return 0;
}


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

int main() {
int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A*B < C*D) cout << C*D << endl;
   if (A*B > C*D) cout << A*B << endl;
  if (A*B == C*D) cout << A*B << endl;
}

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

long long com(long long N, long long R) {
    if (R < 0 || R > N) return 0;
    if (R == 1) return N;
    else if (R == 2) return N * (N-1) / 2;
    else return N * (N-1) * (N-2) / 6;
}

long long pow(long long N, long long k) {
    long long res = 1;
    for (int i = 0; i < k; ++i) res *= N;
    return res;
}

string S;
int N, K;

long long solve(int i, int k, int smaller) {
    if (i == N) {
        if (k == 0) return 1;
        else return 0;
    }
    if (k == 0) return 1;
    
    if (smaller) return com(N-i, k) * pow(9, k);
    else {
        if (S[i] == '0') return solve(i+1, k, false);
        else {
            long long zero = solve(i+1, k, true);
            long long aida = solve(i+1, k-1, true) * (S[i] - '1');
            long long icchi = solve(i+1, k-1, false);
            return zero + aida + icchi;
        }
    }
}

int main() {
    cin >> S >> K;
    N = S.size();
    cout << solve(0, K, false) << endl;
}

Measured memory_bytes: 512
a,b,c = [int(i) for i in input().split()]
num_list = sorted([a,b,c])
#print(num_list)
min = int((num_list[2]-num_list[0])/2)+int((num_list[2]-num_list[1])/2)
if (num_list[2]-num_list[0])%2==0 and(num_list[2]-num_list[1])%2==0:
    print(min)
elif (num_list[2]-num_list[0])%2!=0 and(num_list[2]-num_list[1])%2!=0:
    print(min+1)
else:
    print(min+2)
    


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

ll solve() {
    ll N;
    set<string> a;
    string s;
    cin >> N;
    for ( int i = 0; i < N; i++ ) {
        cin >> s;
        a.insert(s);
    }

    return a.size();
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

using namespace std;
int dp[100005][15];
const long long MOD=1e9+7;
int main(){
	string s;
	cin>>s;
	dp[0][0]=1;
	for(int i=0;i<s.size();i++){
		if(s[i]=='?'){
			for(int j=0;j<13;j++){
				for(int k=0;k<10;k++){
					dp[i+1][(j*10+k)%13]+=dp[i][j];
					if(dp[i+1][(j*10+k)%13]>=MOD)dp[i+1][(j*10+k)%13]-=MOD;
				}	
			}	
		}
		else{
			for(int j=0;j<13;j++){
				dp[i+1][(j*10+s[i]-'0')%13]+=dp[i][j];
				if(dp[i+1][(j*10+s[i]-'0')%13]>=MOD)dp[i+1][(j*10+s[i]-'0')%13]-=MOD;
			}
		}
	}
	cout<<dp[s.size()][5];
	return 0;
}

Measured memory_bytes: 6272
package main

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

func main() {
	fmt.Printf("%d\n", resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) (int, int, int) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	a, b, k := scanInt(sc), scanInt(sc), scanInt(sc)
	return a, b, k
}

func resolve(a, b, k int) int {
	max := min(a, b)
	count := 0
	for i := max; i > 0; i-- {
		if a%i == 0 && b%i == 0 {
			count++
		}
		if count == k {
			return i
		}
	}
	// out of scope
	return -1
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 640
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())

def main():
    n = II()
    def dfs(cur, use):
        counter = 0
        def dfs_(cur, use):
            nonlocal counter
            if cur > n:      return None
            if use == 0b111: counter += 1
            dfs_(cur*10 + 7, use | 0b001)
            dfs_(cur*10 + 5, use | 0b010)
            dfs_(cur*10 + 3, use | 0b100)
        dfs_(cur, use)
        return counter
    print(dfs(0, 0))

if __name__ == '__main__':
    main()

Measured memory_bytes: 8956
/**
 *  Hi, I'm Arpan.
 *
*/

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
#define inv(v)         \
    for (auto &it : v) \
        cin >> it;
#define MOD 1000000007
#define pb push_back
#define popb pop_back()
#define endl "\n"
#define fi first
#define se second
typedef priority_queue<ll, vector<ll>, greater<ll>> minheap;
typedef priority_queue<ll> maxheap;
#define sortv(v) sort(v.begin(),v.end())
#define rsortv(v) sort(v.begin(),v.end(), greater<>());

ll modPower(ll num,ll r) {
	if(r==0) return 1;
	if(r==1) return num%MOD;
	ll ans=modPower(num,r/2)%MOD;
	if(r%2==0) {
		return (ans*ans)%MOD;
	} return (((ans*ans)%MOD)*num)%MOD;
}

ll nCr(ll n, ll r) {
    ll res = 1;
    if (r > n - r) {
        r = n - r;
    }
    for(int i=0;i<r;i++) {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

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

void solve()
{
    int n;
    cin >> n;
    cout << n + n*n + n*n*n << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    while (t--)
        solve();
    return 0;
}



Measured memory_bytes: 3648
def binarySearch(key, lst):
    start = 0
    end = len(lst) - 1
    while end - start >= 0:
        i = (end - start) / 2 + start
        if lst[i] > key:
            end = i - 1
        elif lst[i] < key:
            start = i + 1
        else:
            del lst[i]
            return True
    return False

if __name__ == "__main__":
    input()
    S = map(int, raw_input().split())
    input()
    T = map(int, raw_input().split())

    n = 0
    for t in T:
        if binarySearch(t, S):
            n += 1
    print n

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

int main() {
  int n; cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  int cnt = 0;
  for (int i = 1; i < n - 1; ++i) {
    if (arr[i - 1] < arr[i] and arr[i] < arr[i + 1]) ++cnt;
    if (arr[i - 1] > arr[i] and arr[i] > arr[i + 1]) ++cnt;
  }
  cout << cnt << endl;
}

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

const int INF = 1001001001;
const double pi = 3.1415926535897;

int main(){
    double a,b,x;
    cin >> a >> b >> x ;
    double ans;
    double conv = 180.0 / pi;
    if(a*a*b / 2.0 <= x){
    ans = atan((2.0*(a*a*b - x))/(a*a*a)) * conv;
    }else{
    ans = (atan((a*b*b)/(2.0*x))) * conv; 
    }
    std::cout << std::setprecision(10) << ans; 
}

Measured memory_bytes: 256
S = input()
N = len(S)
 
def isp(s):
  n = len(s)
  for i in range(n // 2):
    if s[i] != s[n - 1 - i]:
      return False
  return True
 
if isp(S) and isp(S[0:(N - 1) // 2]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9016
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  if (N == 1) {
    cout << "Hello World" << endl;
  } else {
    ll a, b;
    cin >> a >> b;
    cout << a + b << endl;
  }
  return 0;
}

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

ll max_total_comfort(vi xs) {
    sort(xs.begin(), xs.end(), greater<int>{});
    const int sz = xs.size();

    ll ans = xs[0];
    for (int i = 1; i < sz / 2; ++i) ans += 2 * xs[i];
    if (sz % 2) ans += xs[sz / 2];
    return ans;
}

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

    int sz;
    cin >> sz;
    vi xs(sz, 0);
    for (auto &x : xs) cin >> x;

    cout << max_total_comfort(xs) << '\n';

    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

ll keta(ll n)
{
    int cnt = 0;
    while (n)
    {
        cnt++;
        n /= 10;
    }
    return cnt;
}

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

    ll b, ans = 1 << 30;

    for (ll a = 1; a * a < n + 1; a++)
    {
        if (n % a == 0)
        {
            b = n / a;
            ll tmp = max(keta(a), keta(b));
            ans = min(tmp, ans);
        }
    }

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


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if(a < 10 && b < 10) cout << a * b << endl;
  else cout << -1 << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include<stdio.h>
        #define NUMBER 200001
        int main(){
         int i = 0;
          int ans = 0;
        char S[NUMBER],T[NUMBER];
        scanf("%s",S);
        scanf("%s",T);
         
         
        while(S[i]){
          if(S[i] != T[i]){
          ans++;
          
          }
          i++;
          }
        printf("%d",ans);
          
          return 0;
        }

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

int main(){
	int ans = 0, a[5];
	for(int i=0; i<5; i++){
		cin >> a[i];
		if(a[i] % 10 == 0) ans += a[i];
		else ans += (a[i] + 10 - (a[i]%10));
	}
	int min = 10;
	for(int i=0; i<5; i++){
		if(min > (a[i]%10) && a[i]%10 != 0) min = a[i]%10;
	}
	cout << ans - (10-min) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  stack<char> stk;
  int n;
  cin >> n;
  string s;
  cin >> s;
  int l, r;
  l = r = 0;
  rep(i, n){
    char now = s.at(i);
    if(now == '(') stk.push(now);
    else{
      if(stk.empty()) l++;
      else stk.pop();
    }
  }
  r = stk.size();
  rep(i, l) cout << '(';
  cout << s;
  rep(i, r) cout << ')';
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
s = 0
for q in range(n):
    s += b[a[q] - 1]
    if q != 0:
        if a[q - 1] == a[q] - 1:
            s += c[a[q - 1] - 1]
print(s)

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

#define ll long long

int N, A[200000];

int main(){
	cin >> N;
	for (int i = 0; i < N; i ++){
		cin >> A[i];
	}
	int mx = 0;
	long long result = 0;
	for (int i = 0; i < N; i ++){
		// cout << max(0, mx - A[i]) << " ";
		result += max(0, mx - A[i]);
		mx = max(mx, A[i]);
	}
	cout << result << "\n";
}

Measured memory_bytes: 4412
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a[i];
    vector<int> b(100010, 0);
    for(int i=0; i<N; i++){
        b[a[i]]++;
        b[a[i]+1]++;
        b[a[i]+2]++;
    }
    cout << *max_element(b.begin(), b.end()) << endl;

    return 0;
}

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

int main(){
  int N,Y;
  cin >> N >> Y;
  bool able = false;
  for(int x=N;x>=0;x--){
    for(int y=N-x;y>=0;y--){
      int z=N-x-y;
      if(10000*x+5000*y+1000*z==Y){
        cout << x <<" "<< y <<" " << z << endl;
        able = true;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256