akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<long> a(n);
	for (long& i : a) cin >> i;
	long b = 0, c = 0;
	vector<long> d = a;
	if (0 <= d.front()) {
		b = 1 + d.front();
		d.front() = -1;
	}
	for (int i = 1; i < n; ++i) {
		d[i] += d[i - 1];
		if (i % 2) {
			if (0 >= d[i]) {
				b += 1 - d[i];
				d[i] = 1;
			}
		}
		else {
			if (0 <= d[i]) {
				b += 1 + d[i];
				d[i] = -1;
			}
		}
	}
	d = a;
	if (0 >= d.front()) {
		c += 1 - d.front();
		d.front() = 1;
	}
	for (int i = 1; i < n; ++i) {
		d[i] += d[i - 1];
		if (i % 2) {
			if (0 <= d[i]) {
				c += 1 + d[i];
				d[i] = -1;
			}
		}
		else {
			if (0 >= d[i]) {
				c += 1 - d[i];
				d[i] = 1;
			}
		}
	}
	cout << min(b, c);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
int n;
 priority_queue<double,vector<double>,greater<double> >q;
cin>>n;
double x,sum,a,b;
for(int i=0;i<n;i++)
{
    cin>>x;
    q.push(x);
}
while(!q.empty())
{
    a=q.top();
    q.pop();
    if(!q.empty())
    {
        b=q.top();
        q.pop();
        a=a+b;
        a/=2.0;
        q.push(a);
    }

}

printf("%.7lf\n",a);

return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ri register int
typedef long long ll;
#define rll register ll
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// input a letter
	template <class I>
	inline void get (I &x) {
		for (c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		x = c;
	}
	// input a string
	inline void read (char *s){
		for(c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		for(; c >= 'A' && c <= 'Z'; c = gc()) *++s = c;
		*++s = '\0';
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: get;
using io :: read;
using io :: putc;
using io :: print;
const int N=5e2+5;
const ll inf=1e18;
ll dp[N][N],a[2][N][N];
inline ll query(ri d,ri x1,ri x2,ri y1,ri y2){
	return x1>x2||y1>y2?0:a[d][x2][y2]-a[d][x1-1][y2]-a[d][x2][y1-1]+a[d][x1-1][y1-1];
}
int main(){
	ri n,i,j,k;
	gi(n);
	for(i=1;i<=n;++i)
		for(j=1;j<=n;++j)
			if(i!=j){
				gi(k);
				if(i<j)
					a[0][i][j]=k;
				else
					a[1][i][j]=k;
			}
	for(k=0;k<=1;++k)
		for(i=1;i<=n;++i)
			for(j=1;j<=n;++j)
				a[k][i][j]+=a[k][i-1][j]+a[k][i][j-1]-a[k][i-1][j-1];
	for(i=0;i<=n;++i)
		for(j=0;j<=n;++j)
			dp[i][j]=1e18;
	dp[0][0]=0;
	for(i=0;i<=n;++i)
		for(j=i;j<=n;++j)
			if(dp[i][j]!=inf)
				for(k=j+1;k<=n;++k)
					dp[j][k]=min(dp[j][k],dp[i][j]+query(0,i+1,j,i+1,j)+query(1,k+1,n,i+1,j));
	rll ans=inf;
	for(i=0;i<=n;++i)
		for(j=i;j<=n;++j)
			if(dp[i][j]!=inf)
				ans=min(ans,dp[i][j]+query(0,i+1,j,i+1,j)+query(0,j+1,n,j+1,n));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10240
#include<cstdio>
#include<cstring>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll t[1000+5],a[1000+5];
ll n,p,q,m1,m2,k1,k2,e1,e2;
ll ans;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&t[i],&a[i]);//比例
	for(int i=1;i<=n;i++)
	{
		ll x=t[i],y=a[i];
		if(x<p||y<q)
		{
			k1=p-x;
			k2=q-y;
			e1=k1/x;
			e2=k2/y;
			
			if(e1*x!=k1)
				m1=e1+2;
			else
				m1=p/x;
				
			if(e2*y!=k2)
				m2=e2+2;
			else
				m2=q/y;
			if(x<p&&y>=q)
			{
				x*=m1;
				y*=m1;
			}
			else if(x>=p&&y<q)
			{
				x*=m2;
				y*=m2;
			}
			else
			{
				x*=max(m1,m2);
				y*=max(m1,m2);
			}
		}
		p=x;
		q=y;
		ans=x+y;
	}
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> s(n);
    for (int i = 0; i < n; ++i)
        cin >> s[i];

    int q;
    cin >> q;
    vector<int> t(q);
    for (int i = 0; i < q; ++i)
        cin >> t[i];

    int count = 0;
    for (int i = 0; i < q; ++i) {
        for (int j = 0; j < n; ++j) {
            if (s[j] == t[i]) {
                ++count;
                break;
            }
        }
    }
    cout << count << '\n';
}



Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
#define pi 3.1415926


int main(){
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if(a1 + a2 + a3 >= 22)
        cout << "bust";
    else 
        cout << "win";
    
    
    
    
}

    

		


Measured memory_bytes: 256
///////////////////////////////////////////////////
/* __                                       __   */
/*|  |--.-----.---.-.----.----.-----.-----.|  |_ */
/*|  _  |  -__|  _  |  __|  __|  -__|  _  ||   _|*/
/*|_____|_____|___._|____|____|_____|   __||____|*/
/*                                  |__|         */
///////////////////////////////////////////////////
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long lint; using namespace std;
#define rep(counter, limit) for (int counter = 0; counter < limit; counter++)
#define INF 1000000000000
#define MOD 10000007
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}setupios;
int main() {

  int n,m,c;
  cin>>n>>m>>c;
  vector<int> b(m);
  vector<vector<int> > a(n,vector<int>(m));
  rep(i,m)cin>>b[i];
  rep(q,n)rep(i,m)cin>>a[q][i];
  int ans=0;

  rep(q,n){
    int sum=0;
    rep(i,m){
      sum+=(b[i]*a[q][i]);
    }
    sum+=c;
    if(sum > 0){
      ans++;
    }
  }
  cout<<ans<<endl;

}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int H, W;
	cin >> H >> W;

	string smap[110];
	rep(i, 0, H)cin >> smap[i];

	rep(i, 0, W + 2)cout << "#";
	cout << endl;

	rep(i, 0, H)
	{
		cout << "#";
		cout << smap[i];
		cout << "#" << endl;
	}

	rep(i, 0, W + 2)cout << "#";
	cout << endl;


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	long long n,ans=0,ans2=0,l,r,x;
	scanf("%lld",&n);
	for(long long a=1;a<=9;a++)
	for(long long b=1;b<=9;b++){
		long long cnt1=0,cnt2=0;
	    for(long long i=1;i<=n;i++){
		    x=i;r=x%10;
	     	while(x!=0){
		    	l=x%10;x/=10;
		   }
		   if(l==a&&r==b) cnt1++;
		   if(r==a&&l==b) cnt2++;
	    }
	    ans+=cnt1*cnt2;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
N=int(input())
A=[int(x) for x in input().split()]

mi=100000000
ma=-100000000
mi_n=0
ma_n=0
for i in range(N):
  if A[i]>ma:
    ma=A[i]
    ma_n=i+1
  if A[i]<mi:
    mi=A[i]
    mi_n=i+1

if mi>=0:
  print(N-1)
  for i in range(N-1):
    print(i+1,i+2)
elif ma<=0:
  print(N-1)
  for i in range(N-1):
    print(N-i,N-i-1)
else:
  print(N+N-1)
  if abs(ma)>abs(mi):
    for i in range(N):
      print(ma_n,i+1)
    for j in range(N-1):
      print(j+1,j+2)
  else:
    for i in range(N):
      print(mi_n,i+1)
    for j in range(N-1):
      print(N-j,N-j-1)

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

int main()
{
    ll n,a,ans=0;
    scanf("%lld",&n);
    for(ll i=0;i<n;i++)
    {
        scanf("%lld",&a);
        if(a%2==0)
        {
           while(a%2==0)
           {
               ans++;
               a/=2;
           }
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define For(i,x,y) for(int i = x; i <= y; ++i)
#define FOR For
#define rev_For(i,x,y) for(int i = x; i >= y; --i)
#define REV_FOR rev_For
#define ll long long
#define Size(v) ((int)v.size())
#define _section "\n--------------------\n"
#define fi first
#define se second
#define pb push_back
using namespace std;
// using namespace __gnu_pbds;


int n;
const int nax = 1e5 + 5;
int h[nax];
int dp[nax];
const int INF = 1e9;

void input() {
	cin >> n;
	FOR (i, 1 ,n) cin >> h[i];
	FOR (i, 0, nax - 1) dp[i] = -1;
	dp[1] = 0;
}

int calc(int i) {
	if (dp[i] != -1) return dp[i];
	if (i <= 0) return INF;

	int ret = INF;
	if (i > 1) ret = min(ret, calc(i - 1) + abs(h[i] - h[i - 1]));
	if (i > 2) ret = min(ret, calc(i - 2) + abs(h[i] - h[i - 2]));

	return (dp[i] = ret);
}

void solve() {
	cout << calc(n);
}

signed main() {
#ifdef _DEBUG
	// freopen("INPUT.inp", "r", stdin);
	//freopen("OUTPUT.out", "w", stdout);
	clock_t start, end;
	start = clock();
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//------------------------------------------------------------------------------------
//----------------------------------MAIN PROGRAM--------------------------------------
	int t = 1;
	while (t--) {
		input();
		solve();
	}
//--------------------------------------END-------------------------------------------
//------------------------------------------------------------------------------------
#ifdef _DEBUG
	end = clock();
	cerr << "\n----------\nTime Elapsed: " << fixed << double(end - start) / double(CLOCKS_PER_SEC) << setprecision(6) << '\n';
#endif
	return 0;
}

Measured memory_bytes: 4224
#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(){
    int n,a;
    double t;
    cin >> n >> t >> a;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    double maxim = 1e9;
    int point = 0;
    rep(i,n){
        if(abs(a-(t-h[i]*0.006)) < maxim){
            maxim = abs(a-(t-h[i]*0.006));
            point = i+1;
        }
    }
    cout << point << endl;
}

Measured memory_bytes: 3664
#include<iostream>
    #include<algorithm>
    #include<cstdio>
    #include<cmath>
    #include<math.h>
    #include<string>
    #include<string.h>
    #include<stack>
    #include<queue>
    #include<vector>
    #include<utility>
    #include<set>
    #include<map>
    #include<stdlib.h>
    #include<iomanip>
     
    using namespace std;
     
    #define ll long long
    #define ld long double
    #define EPS 0.0000000001
    #define INF 1e9
    #define MOD 1000000007
    #define rep(i,n) for(i=0;i<n;i++)
    #define loop(i,a,n) for(i=a;i<n;i++)
    #define all(in) in.begin(),in.end()
    #define shosu(x) fixed<<setprecision(x)
     
    typedef vector<int> vi;
    typedef pair<int,int> pii;
     
    int ans=0;
    int n,m;
    vi v[8];
    vi used(8,0);
     
    void dfs(int now,int time){
      int i;
      if(time==0){
        bool c=true;
        rep(i,n)
          if(used[i]==0)c=false;
        if(c)ans++;
        used[now]--;
        return;
      }
      rep(i,v[now].size()){
        used[v[now][i]]++;
        dfs(v[now][i],time-1);
      }
      used[now]--;
    }
     
    int main(void) {
      cin>>n>>m;
      int i;
      rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
      }
      used[0]++;
      dfs(0,n-1);
      cout<<ans<<endl;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
ll n;
P p[200005];
P q[200005];
P S[200005];
ll a[200005];
ll par[200005],Rank[200005];
void init(ll n){
    for(ll i=0;i<n;i++){
        par[i]=i; Rank[i]=0;
    }
}
ll find(ll x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}
void unite(ll x,ll y){
    x=find(x); y=find(y);
    if(x==y) return;
    if(Rank[x]<Rank[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(Rank[x]==Rank[y]) Rank[x]++;
    }
}
bool same(ll x,ll y){
    return find(x)==find(y);
}
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p[i].first>>p[i].second;
        q[i].first=p[i].first;
        q[i].second=p[i].second;
    }
    sort(p,p+n);
    set<P> s;
    init(n+1);
    for(int i=0;i<n;i++){
        s.insert(make_pair(p[i].second,p[i].first));
        auto itr=s.lower_bound(make_pair(p[i].second,p[i].first));
        auto itr2=s.begin();
        ll I=0;
        bool x=false;
        while(itr2!=itr){
            x=true;
            P t=(*itr2);
            S[I].first=t.first;
            S[I].second=t.second;
            I++;
            unite(i+1,t.second);
            itr2++;
        }
        for(int j=1;j<I;j++){
            s.erase(S[j]);
        }
        if(x){
            s.erase(make_pair(p[i].second,p[i].first));
        }
    }
    for(int i=0;i<n;i++){
        a[find(q[i].first)]++;
    }
    for(int i=0;i<n;i++){
        cout<<a[find(q[i].first)]<<endl;
    }
    
}


Measured memory_bytes: 19472
//         ONLY FOR KING RAHMANI MASTER OF DP       \\

#include <bits/stdc++.h>
#define int long long
#define lb(a) ((a)&(-a))
using namespace std;

const int maxn=2e5+11,mod=1e9+7;

int n,dp[2][maxn];

vector <int> adg[maxn];

bool mark[maxn];

void dfs(int v)
{
    mark[v]=1;
    dp[0][v]=1;
    dp[1][v]=1;
    for(int u,i=0;i<adg[v].size();i++)
    {
        u=adg[v][i];
        if(!mark[u])
        {
            dfs(u);
            dp[1][v]=(dp[1][v]*dp[0][u])%mod;
            dp[0][v]=(dp[0][v]*((dp[1][u]+dp[0][u])%mod))%mod;
        }
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
   // cout<<setprecision(9);
   // cout<<std::fixed;
 //   ifstream cin("input.txt");
 //   ofstream cout("output.txt");
    cin>>n;
    for(int a,b,i=1;i<n;i++)
    {
        cin>>a>>b;
        adg[a].push_back(b);
        adg[b].push_back(a);
    }
    dfs(1);
    cout<<(dp[1][1]+dp[0][1])%mod<<endl;
	return 0;
}


Measured memory_bytes: 17152
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int n; cin >> n;
	int k; cin >> k;
	vector<int> x(n);
	rep (i, n) {
		cin >> x[i];
	}
	vector<pair<int, int>> type_a(n);
	vector<pair<int, int>> type_b(n);
	vector<pair<int, int>> pos_ball(n);
	rep (i, n) {
		type_a[i] = make_pair(0, i);
		type_b[i] = make_pair(k, i);
		pos_ball[i] = make_pair(x[i], i);
	}
	int ans = 0;
	rep (i, n) {
		int distance_a = 0;
		int distance_b = 0;
		rep (j, n) {
			if (pos_ball[i].second == type_a[j].second) {
				distance_a = abs(pos_ball[i].first - type_a[j].first) * 2;
			}
			if (pos_ball[i].second == type_b[j].second) {
				distance_b = abs(pos_ball[i].first - type_b[j].first) * 2;
			}
		}
		ans += min(distance_a, distance_b);
	}
	cout << ans << endl;
	return;
}

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

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	var a int
	broken := make(map[int]bool)
	for i := 0; i < M; i++ {
		fmt.Scan(&a)
		broken[a] = true
	}

	dp := make([]int, N+2)
	dp[N] = 1
	for i := N - 1; i >= 0; i-- {
		if broken[i] {
			dp[i] = 0
		} else {
			dp[i] = (dp[i+1] + dp[i+2]) % 1000000007
		}
	}
	fmt.Println(dp[0])
}


Measured memory_bytes: 5504
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Scanner;

public class Main {
	static Scanner sc;

	public static void main(String[] args) throws Exception {
		//InputStream in = new FileInputStream("src/input.txt");
		InputStream in = System.in;

		sc = new Scanner(in);

		long N = sc.nextLong();

		for(long i = N; i > 0; i--){
			if(Math.sqrt(i) % 1.0 == 0.0){
				System.out.println(i);
				break;
			}
		}
	}
}

Measured memory_bytes: 23764
#include <iostream>
using namespace std;
int main(){
	int kkk[10000],g;
	for(int i=0;;i++){
		cin>>kkk[i];
		if(kkk[i]==0){
			g=i;
			break;
		}
	}
	for(int i=0;i<g;i++){
		cout<<"Case "<<i+1<<": "<<kkk[i]<<endl;
	}
	return 0;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N);
  vector< int > a(N);
  REP(i, N) {
    cin >> a[i];
  }

  // (i + 1)という数字が左から何番目に存在しているか
  vector< int > num_spot(N);
  vector< int > t(N);
  REP(i, N) {
    num_spot[a[i] - 1] = i;

    // 以下のようにも書けるが、上の方がスマート
    /*
    int tmp = i + 1;
    REP(j, N) {
      if (a[j] == tmp) {
	t[tmp - 1] = j; 
      }
    }
    */
  }

  set< int > st;
  st.insert(-1);
  st.insert(N);

  ll ans = 0ll;
  REP(i, N) {

    // 以下のiterの型はstd::set< int >::iterator
    // 重複がないため、lower_boundでもupper_boundでもどちらでも良い
    auto iter = st.upper_bound(num_spot[i]);

    ll right = (*iter) - num_spot[i];

    // num_spot[i]よりも左に存在し、かつ(i + 1)よりも大きい数の場所に移る
    iter--;

    ll left = num_spot[i] - (*iter);

    ans += left * right * (i + 1);

    st.insert(num_spot[i]);
  }

  cout << ans << endl;

  

  return 0;
}



Measured memory_bytes: 12032
# -*- coding:utf-8 -*-



def main():
  n = int(input())
  tmp = {}
  for i in range(n):
    x = int(input())
    if x in tmp.keys():
      tmp[x] += 1
    else:
      tmp[x] = 0
  print(len(tmp))
    
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0; i<(int)(n);i++)

bool reach(int s,int g,string &c){
  for(int i=s;i<g;i++){
    if(c.at(i) == '#' && c.at(i-1) == '#') return false;
  }
  return true;
}

int main(){
  int n,a,b,c,d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  if(b < c && c < d){
    if(reach(b,d,s) && reach(a,c,s)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
    return 0;
  }
  if(c < b){
    if(reach(b,d,s) && reach(a,c,s)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
    return 0;
  }
  if(d < c){
    if(!reach(b,d,s)){
      cout << "No" << endl;
      return 0;
    }
    if(!reach(a,c,s)){
      cout << "No" << endl;
      return 0;
    }
    for(int i=b-1;i<=d-1;i++){
      if(s.at(i-1) == '.' && s.at(i) == '.' && s.at(i+1) == '.'){
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No" << endl;
    return 0;
  }
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        static void Solve()
        {
            int n = ReadAndParseInt();
            var a = ReadAndParseIntArr();
            int ave = (int) a.Average();

            long minCost = long.MaxValue;
            for(int i=-1;i<=1;++i)
            {
                minCost = Math.Min(minCost, CalcCost(ave + i, a));
            }
            Console.WriteLine(minCost);
        }
        private static long CalcCost(int ave, int[] a)
        {
            int cost = 0;
            foreach (int ai in a)
            {
                cost += (ai - ave) * (ai - ave);
            }
            return cost;
        }
        
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

using namespace std;

int main()
{
    long long a,b,c;
    cin >> a >> b >> c;
    bool ch=true;
    if((c-a-b)<0)ch=false;
    if(4*a*b>=(c-a-b)*(c-a-b))ch=false;
    if(ch)cout << "Yes"<< endl;
    else cout << "No"<< endl;
    return 0;
}


Measured memory_bytes: 384
import math
a,b,C=map(float,input().split())
θ=math.radians(C)
h=b*math.sin(θ)
S=(a*h)/2
c=math.sqrt(a**2+b**2-2*a*b*math.cos(θ))
L=a+b+c
print(S,L,h,)


Measured memory_bytes: 5752
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for (int i = 0; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
#define keta(n) cout << fixed << setprecision((n));
using ll = int64_t;
using v = vector<int>;


int main() {
  int K;
  string S;
  cin >> K >> S;
  int l = S.size();
  if(l<=K) cout << S << endl;
  else {
    for (int i = 0; i<K; i++) {
      cout << S.at(i);
    }
    cout << "..." << endl;
  }

}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
} 
signed main(){
    fast();
    int n, k;
    cin >> n >> k;
    vector<int> a(n+1);
    for(int i=1; i<=n; i++)  cin >> a[i];
    // vector<int> pro(n+1, 1);
    // int num = 1;
    // for(int i=0; i<k; i++){
    //     pro[k] *= a[k-i];
    // }
    for(int i=k+1; i<=n; i++){
        if(a[i] > a[i-k])   cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    // for(auto i: pro)    
    // for(int i=k+1; i<=n; i++){
    //     if(pro[i] > pro[i-1])   cout << "Yes" << endl;
    //     else cout << "No" << endl;
    // }
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

Measured memory_bytes: 4696
from collections import defaultdict
vertices, edges = map(int, input().split(" "))
connect = defaultdict(set)
for e in range(edges):
    a, b = map(lambda n:n - 1, map(int, input().split(" ")))
    connect[a] |= {b}
    connect[b] |= {a}
queue = [[0, set()]]
answer = 0
while queue:
    next_queue = []
    # print(queue)
    for q in queue:
        here, visited = q
        new_visited = set()
        new_visited |= visited | {here}
        if len(new_visited) == vertices:
            # print(new_visited, here, queue)
            answer += 1
        for conn in connect[here]:
            if conn not in new_visited:
                next_queue.append([conn, new_visited])
    queue = next_queue
print(answer)

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

const int max_n = 5*(int)1e5 + 5;
#define mp make_pair
#define pii pair<int, int>

/* Zero indexed FT */
class FenwickTree
{
	vector<int> ft;
public:
	FenwickTree(int n)
	{
		ft.resize(n + 1);
	}

	int rsq(int b);
	int rsq(int a, int b);
	void adjust(int ind, int to_add);
};

int FenwickTree :: rsq(int b)
{
	int sum = 0;
	for(; b > 0; b -= (b & -b))
		sum += ft[b];

	return sum;
}

int FenwickTree :: rsq(int a, int b)
{
	a++; b++;
	return rsq(b) - (a > 0 ? rsq(a - 1) : 0);
}

void FenwickTree :: adjust(int ind, int to_add)
{
	ind++;
	for(; ind < (int)ft.size(); ind += (ind & -ind)) 
		ft[ind] += to_add;
}

void solve()
{
	int n, q_len;
	cin >> n >> q_len;

	vector<int> a(n);
	for(auto &ele : a)
		cin >> ele;

	vector<pair<pii, int>> queries;
	for(int ind = 0; ind < q_len; ind++)
	{
		int left, right;
		cin >> left >> right;
		left--; right--;
		queries.push_back(mp(mp(right, left), ind));
	}


	vector<int> ans(q_len);
	vector<int> last_occ(max_n, -1);

	FenwickTree ft(n);
	for(int i = 0; i < n; i++)
		ft.adjust(i, 1);

	sort(queries.begin(), queries.end());
	auto itr = queries.begin();

	for(int i = 0; i < n; i++)
	{
		if(last_occ[a[i]] != -1)
			ft.adjust(last_occ[a[i]], -1);

		while(itr != queries.end() and itr->first.first == i)
		{
			int r = (itr->first).first;
			int l = (itr->first).second;
			int q_ind = itr->second;

			ans[q_ind] = ft.rsq(l, r);
			itr++;
		}

		last_occ[a[i]] = i;
	}

	for(auto &ele : ans)
		cout << ele << "\n";
}

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

	solve();
	return 0;
}


Measured memory_bytes: 17392
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#define maxn 300010
#define int long long

using namespace std;

int n, p[maxn];
int odd[maxn], even[maxn];
int cnto, cnte;
struct BIT{
	int c[maxn];
	void clear()
	{
		memset(c, 0, sizeof c);
	}
	
	void add(int x, int d)
	{
		for (; x <= n; x += x & -x) c[x] += d;
	}
	
	int query(int x)
	{
		int ans = 0;
		for (; x; x -= x & -x) ans += c[x];
		return ans;
	}
}bit;

signed main()
{
	cin.tie(0), cout.tie(0);
	
	cin >> n;
	for (int i = 1; i <= n; i ++ ) cin >> p[i];
	for (int i = 1; i <= n; i += 2) odd[++cnto] = p[i];
	for (int i = 2; i <= n; i += 2) even[++cnte] = p[i];
	
	int ansp = 0, anso = 0, anse = 0;
	
	bit.clear();
	for (int i = n; i; i -- )
	{
		ansp += bit.query(p[i] - 1);
		bit.add(p[i], 1);
	}
	
	bit.clear();
	for (int i = cnto; i; i -- )
	{
		anso += bit.query(odd[i] - 1);
		bit.add(odd[i], 1);
	}
	
	bit.clear();
	for (int i = cnte; i; i -- )
	{
		anse += bit.query(even[i] - 1);
		bit.add(even[i], 1);
	}
	
	bool yes = 1;
	if (ansp % 3) yes = 0;//逆序对不为3的倍数，见祖宗 
	if (3 * (anso + anse) != ansp) yes = 0;//奇逆+偶逆!=总逆/3，见祖宗 
	for (int i = 1; i <= cnto; i ++ )
		if (odd[i] % 2 == 0)
		{
			yes = 0;
			break;
		}
	for (int i = 1; i <= cnte; i ++ )
		if (even[i] % 2)
		{
			yes = 0;
			break;
		}
	
	puts(yes ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 9728
open Printf open Scanf
open Array

let count_substr s t =
  let ln = String.length in
  init (ln s - ln t + 1) (fun i ->
    if init (ln t) (fun j -> s.[i+j] = t.[j])
    |> fold_left (&&) true then 1 else 0
  ) |> fold_left (+) 0

let () = scanf " %d" @@ fun n ->
  let arr = init n (fun _ -> scanf " %s" @@ fun s -> s)
  in
  let kba,kbx,kxa,kab = ref 0,ref 0,ref 0,ref 0 in
  iter (fun s ->
    let bx = s.[0] = 'B' in
    let xa = s.[String.length s-1] = 'A' in
    let ba = bx && xa in
    if ba then incr kba
    else if bx then incr kbx
    else if xa then incr kxa;
    kab := !kab + count_substr s "AB"
  ) arr;
  let kba,kbx,kxa,kab = !kba,!kbx,!kxa,!kab in
  print_int @@ kab +
    if kba >= 1 then (
      (* B-A^B-A^...^B-A *)
      let pair_ba = kba - 1 in
      (* B-A^B-A^...^B-A ^ B- *)
      let add,kbx =
        if kbx > 0 then 1,kbx-1 else 0,kbx in
      (* -A ^ B-A^B-A^...^B-A*)
      let add,kxa =
        if kxa > 0 then add+1,kxa-1 else add,kxa in
      pair_ba + add + min kbx kxa
    ) else
      (* -A^B- ... -A^B- *)
      min kbx kxa





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

 int main(){

 int a,b;
 cin>>a>>b;
 long long int sum=0;
for(int i=0;i<b;i++)
{
int x;
cin>>x;
sum+=x;
}
if(sum>=a)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;

    return 0;



 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  // REP(i,0,100){cerr<<i+1<<endl;}
  int X, N;
  cin >> X >> N;
  VEC<int> P(N);
  map<int, int> m;
  REP(i, 0, N) cin >> P[i];
  sort(ALL(P));
  int mi = 300;
  int mii = -1;
  REP(i, 0, N) { m[P[i]]++; }
  REP(i, 0, 102) {
    if (m[i] == 0) {
      if (abs(X - i) < mi) {
        mi = abs(X - i);
        mii = i;
      }
    }
  }
  cout << mii << endl;

  return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <numeric>
#include <vector>
#include <iostream>

using namespace::std;

int main(void)
{

  for(int i = 1; i <= 9; i++)
    {
      for(int j = 1; j <= 9; j++)
	{
	  cout << i << "x" << j << "=" << i * j << endl;
	}
    }

  return 0;
}

Measured memory_bytes: 1116
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include <utility>
#include <algorithm>

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

vector<bool> v(246912);

void sosuu( int n )
{
	for( int  i = 2; i <= n*2; i++)
	{
		if( v[i] ){
			for( int j =2; i*j <= n*2; j++)
				v[i*j] = false;
		}
	}
}
	

int main()
{
	int n;
	rep(i,246912) v[i] = true;

	while( cin >> n, n)
	{
		int ans = 0;
		sosuu(n);

		for( int i = n+1; i <= n*2; i++)
		{
			if( v[i] )
			{
				ans++;
			}
		}

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

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

int main()
{
	int W[10 + 5] = { 0 };
	int K[10 + 5] = { 0 };

	int wp, kp;

	int tmp;

	int i,j;

	for (i = 0; i < 10; i++)
	{
		cin >> W[i];
	}
	for (i = 0; i < 9; i++)
	{
		for (j = i + 1; j < 10; j++)
		{
			if (W[i] < W[j])
			{
				tmp = W[i];
				W[i] = W[j];
				W[j] = tmp;
			}
		}
	}
	wp = W[0] + W[1] + W[2];


	for (i = 0; i < 10; i++)
	{
		cin >> K[i];
	}
	for (i = 0; i < 9; i++)
	{
		for (j = i + 1; j < 10; j++)
		{
			if (K[i] < K[j])
			{
				tmp = K[i];
				K[i] = K[j];
				K[j] = tmp;
			}
		}
	}
	kp = K[0] + K[1] + K[2];

	cout << wp << " " << kp << endl;
	return 0;
}

Measured memory_bytes: 3084
#include <stdio.h>

int main(void)
{
    int A, B, c, d, e, MAX;
    scanf("%d", &A);
    scanf("%d", &B);

    c = A + B;
    d = A - B;
    e = A * B;

    MAX = c;
    if (d > MAX)
        MAX = d;

    if (e > MAX)
        MAX = e;

    printf("%d", MAX);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long arr[1000007];
long long cs[1000007];
long long ps[1000007];

int main()
{
  long long  a,b,c,d;

  cin>>a>>b>>c>>d;

  long long p1 = a*c , p2 = a*d , p3=b*c, p4=b*d;

  long long maxx=max(p1,p2);
  maxx=max(maxx,p3);
  maxx=max(maxx,p4);

  cout<<maxx<<endl;

    return 0;

}












Measured memory_bytes: 3632
#include <cstdio>
#include <vector>
#include <utility>
#include <queue>

using namespace std;
typedef long long ll;

int main() {
	int N; scanf("%d", &N);
	vector<vector<pair<int, ll>>> tree(N, vector<pair<int, ll>>());

	for (int i = 0; i < N - 1; ++i) {
		ll ai, bi, ci; scanf("%lld %lld %lld", &ai, &bi, &ci);
		tree[--ai].emplace_back(--bi, ci);
		tree[bi].emplace_back(ai, ci);
	}

	int Q, K; scanf("%d %d", &Q, &K);
	vector<ll> distFromK(N, -1);
	queue<int> q;

	q.push(--K);
	distFromK[K] = 0;

	while (!q.empty()) {
		int cur = q.front(); q.pop();
		for (auto neighbor : tree[cur]) {
			if (distFromK[neighbor.first] == -1) {
				distFromK[neighbor.first] = distFromK[cur] + neighbor.second;
				q.push(neighbor.first);
			}
		}
	}

	for (int i = 0; i < Q; ++i) {
		int xj, yj; scanf("%d %d", &xj, &yj);
		printf("%lld\n", distFromK[xj - 1] + distFromK[yj - 1]);
	}

	return 0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define MOD2 (lli) 998244353  
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

int n;
vector<int> vec;

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

  cin >> n;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    vec.push_back(a);
  }

  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  long double ans = vec[sz(vec)-1];
  for(int i=sz(vec)-2;i>=0;i--){
    ans = (ans + vec[i])/2;
  }

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

Measured memory_bytes: 256
import fractions
a,b,c,d = map(int,input().split())
cnt = 0
numc = b // c - (a - 1) // c
numd = b // d - (a - 1) // d
com = int(c * d / fractions.gcd(c,d))
numcd = b // com - (a - 1) // com
print(int(b - a + 1 - (numc + numd - numcd)))


Measured memory_bytes: 5176
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, H, A;
    cin>>N>>H>>A;
    
    int best;
    ld dif=INF;
    rep1(i,N){
        int x; cin>>x;
        ld t = 0.006*x;
        ld n = H-t;
        if(dif>abs(1.*A-n)){
            best=i;
            dif = abs(1.*A-n);
        }
    }
    cout1(best);
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define forn(i,a,n) for(int i =a; i < n; i++)
#define fi first
#define se second
#define pb push_back
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef long long int lli;

int main(){__
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vi a(n);
    forn(i,1,n){
    	if(s[i] == 'C' && s[i-1] == 'A') a[i]++;
    }
    forn(i,1,n){
    	a[i]+=a[i-1];
    }
    int l,r;
    forn(i,0,q){
    	cin >> l >> r;
    	l--,r--;
       	cout << a[r] - a[l] << endl;
    }
    
	return 0;
}

Measured memory_bytes: 1488
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////
using pii = vector<pair<int,int>>;

bool find_hw(const pii &targets, const pii &hps, const pii &wps, int M)
{
    int top_h = hps[0].first; 
    int top_w = wps[0].first;

    for (auto ih = hps.begin(); ih->first == top_h; ++ih)
    {
        for (auto iw = wps.begin(); iw->first == top_w; ++iw)
        {
            if (!binary_search(begin(targets), end(targets), make_pair(ih->second, iw->second)))
            {
                return false;
            }
        }
    }

    return true;
}

int main()
{
    int H, W, M;
    io >> H >> W >> M;

    vi hs(H), ws(W);
    vector<pair<int,int>> targets;
    for (int i = 0; i < M; i++)
    {
        int h, w;
        io >> h >> w;
        --h; --w;
        ++hs[h];
        ++ws[w];
        targets.push_back({h,w});
    }

    vector<pair<int,int>> hps(H), wps(W);
    for (int i = 0; i < H; i++)
        hps[i] = {hs[i],i};
    for (int j = 0; j < W; j++)
        wps[j] = {ws[j],j};
    

    using cmp_t = greater<pair<int,int>>;
    sort(begin(hps), end(hps), cmp_t());
    sort(begin(wps), end(wps), cmp_t());
    sort(begin(targets), end(targets));

    int ans = hps[0].first + wps[0].first;
    if (find_hw(targets, hps, wps, M)) ans--; 
    io << ans << BR;
}

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

const int N = 233;
const int INF = 1 << 28;

struct edge {
	int to, cap, next;
	edge(int t = 0, int c = 0, int n = 0):to(t), next(n), cap(c) {}
};
edge G[N * N * 10];
int head[N * N], cur[N * N];
int Gcnt, n, m, S, T, clc, cnt, ans;
char mp[N][N];
int dis[N * N], vis[N * N];
int in[N][N], out[N][N];
int r[N], c[N];
queue<int> Q;

inline void AddEdge(int from, int to, int cap) {
	G[++Gcnt] = edge(to, cap, head[from]); head[from] = Gcnt;
	G[++Gcnt] = edge(from, 0, head[to]); head[to] = Gcnt;
}
inline bool bfs(int S, int T) {
	dis[S] = 0; Q.push(S); vis[S] = ++clc;
	while (!Q.empty()) {
		int u = Q.front(); Q.pop();
		for (int i = head[u]; i; i = G[i].next) {
			edge &e = G[i];
			if (e.cap && vis[e.to] != clc) {
				dis[e.to] = dis[u] + 1;
				vis[e.to] = clc; Q.push(e.to);
			}
		}
	}
	return vis[T] == clc;
}
inline int dfs(int u, int a) {
	int flow = 0, f;
	if (u == T || a == 0) return a;
	for (int &i = cur[u]; i; i = G[i].next) {
		edge &e = G[i];
		if (e.cap && dis[e.to] == dis[u] + 1
				&& (f = dfs(e.to, min(a, e.cap))) > 0) {
			e.cap -= f; flow += f;
			G[i ^ 1].cap += f; a -= f;
			if (a == 0) break;
		}
	}
	return flow;
}
inline int MaxFlow(int S, int T) {
	int flow = 0;
	while (bfs(S, T)) {
		for (int i = 1; i <= cnt; i++) cur[i] = head[i];
		flow += dfs(S, INF);
	}
	return flow;
}

int main(void) {
	Gcnt = 1;
	scanf("%d %d\n", &n, &m);
	S = ++cnt; T = ++cnt;
	for (int i = 1; i <= n; i++) {
		scanf("%s", mp[i] + 1);
		for (int j = 1; j <= m; j++)
			if (mp[i][j] == 'o') {
				in[i][j] = ++cnt;
				out[i][j] = ++cnt;
			}
	}
	for (int i = 1; i <= n; i++) r[i] = ++cnt;
	for (int i = 1; i <= m; i++) c[i] = ++cnt;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if (mp[i][j] == 'S') {
				AddEdge(S, r[i], INF);
				AddEdge(S, c[j], INF);
			} else if (mp[i][j] == 'T') {
				AddEdge(r[i], T, INF);
				AddEdge(c[j], T, INF);
			} else if (mp[i][j] == 'o') {
				AddEdge(r[i], in[i][j], INF);
				AddEdge(c[j], in[i][j], INF);
				AddEdge(in[i][j], out[i][j], 1);
				AddEdge(out[i][j], r[i], INF);
				AddEdge(out[i][j], c[j], INF);
			}
	ans = MaxFlow(S, T);
	if (ans > n * m) ans = -1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) REP(i,0,b)
#define long long int lld
void function(vector<int>,int,int );
int cnt;
int main(void){
	int n_first,n_second;
	vector<int> v;
	cin >> n_first;
	for(int i = 0 ; i < n_first; i++){
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	cin >> n_second;
	for(int i = 0 ; i < n_second; i++){
		int tmp;
		cin >> tmp;
		function(v,tmp,n_first);
	}
	cout << cnt << endl;
	return 0;
}
void function(vector<int> v, int value, int n_first){
	int mid ;
	int right = n_first,left = 0;
	while(left <= right){
		mid = (right + left) / 2;
		int tmp = v[mid];
		if(value == tmp){
			cnt++;
			break;
		}
		else if (value > tmp){
			left = mid + 1;
		}
		else{
			right = mid -1;
		}
	}
}

Measured memory_bytes: 1932