akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;

struct mint {
  ll x;
  mint(ll x = 0): x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
  mint& operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct cominit {
  vector<mint> fact, ifact;
  cominit(int n): fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; i--) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int r) {
    if (n < r or r < 0) return 0;
    return fact[n] * ifact[r] * ifact[n - r];
  }
};

int main() {
  int n, b, r;
  cin >> n >> b;
  r = n - b;
  cominit nCr(2005);
  for (int i = 1; i <= b; i++) {
    mint ans = nCr(r + 1, i) * nCr(b - 1, i - 1);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

bool judge(int t, int A, int B, const vector<int> &h) {
	int rest = t;
	int diff = A - B;
	for(int i = 0; i < h.size(); ++i) {
		if(t * B < h[i]) {
			rest -= (h[i] - t * B + diff - 1) / diff;
		}
	}
	return rest >= 0;
}

signed main(){
	int N, A, B;
	cin >> N >> A >> B;
	vector<int> h(N);
	for(int i = 0; i < N; ++i) {
		cin >> h[i];
	}
	int l = 0, u = (int)1e9 + 10;
	while(u - l > 1) {
		int c = (u + l) / 2;
		if(judge(c, A, B, h)) {
			u = c;
		} else {
			l = c;
		}
	}
	cout << u << endl;
	return 0;
}


Measured memory_bytes: 1024
N = input()
rates = [int(x) for x in input().split()]
colors = [0,0,0,0,0,0,0,0]
target = 0

for rate in rates:
	if rate < 400:
		colors[0] = 1
	elif 400 <= rate < 800:
		colors[1] = 1
	elif 800 <= rate < 1200:
		colors[2] = 1
	elif 1200 <= rate < 1600:
		colors[3] = 1
	elif 1600 <= rate < 2000:
		colors[4] = 1
	elif 2000 <= rate < 2400:
		colors[5] = 1
	elif 2400 <= rate < 2800:
		colors[6] = 1
	elif 2800 <= rate < 3200:
		colors[7] = 1
	else:
		target += 1

non_target = sum(colors)
MAX = non_target + target

if non_target == 0:
	MIN = 1
else:
	MIN = non_target

print(MIN,MAX)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if((a + b == c) || (a + c == b) || (b + c == a)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
# include <iostream>
using namespace std;
const int N=106,M=10006;
int a[N][N],b[M];
int n,m,p;
void work (void)
{
	int i,j,k,t,f;
	f=1;
	i=1;
	j=1;
	k=1;
	t=b[1];
	while (k<=p)
	if (f==1)
	{
		a[i][j]=k;
		t--;
		if (t==0)
		{
			k++;
			t=b[k];
		}
		j++;
		if (j==m+1)
		{
			i++;
			j--;
			f=-1;
		}
	}
else
    {
    	a[i][j]=k;
    	t--;
    	if (t==0)
		{
			k++;
			t=b[k];
		}
		j--;
    	if (j==0)
    	{
    		i++;
    		j++;
    		f=1;
    	}
    }
    for (i=1;i<=n;i++)
    {
    	for (j=1;j<=m;j++)
    	cout<<a[i][j]<<" ";
    	cout<<endl;
    }
}
int main (void)
{
	int i;
	cin>>n>>m;
	cin>>p;
	for (i=1;i<=p;i++)
	cin>>b[i];
	work ();
	return 0;
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  ll ans = infll;
  for(int i = -100; i <= 100; i++) {
    ll tmp = 0;
    rep(j,n) {
      tmp += (a[j]-i) * (a[j]-i);
    }
    chmin(ans, tmp);
  }
  cout << ans << endl;
}

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

int main(){
	int N;
	cin >> N;
	int a[N];
	ll sum = 0;
	for(int i=0; i<N; i++){
		cin >> a[i];
		a[i]--;
		sum += a[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#define pll pair<long long, long long>
// #pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define isSquare(x) (sqrt(x)*sqrt(x) == x)
template<class T>bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
    for(T &in : v) is >> in;
    return is;
}

const int MAX = 3e7 + 10;
ll dp[MAX]; // dp[i] := ドングリをi個使った時に,得られるドングリの数

ll calc(vector<ll>& pre, vector<ll>& will, ll M){
    memset(dp, 0, sizeof dp);
    rep(i, 0, (int)pre.size()){
        for(int v = 0; v + pre[i] <= M; v++){
            chmax(dp[v + pre[i]], dp[v] + will[i]);
        }
    }
    ll res = M;
    rep(v, 0, M + 1) chmax(res, dp[v] + M - v);
    return res;
}

int main(){
    ll N; cin >> N;
    vector<ll> a(3), b(3);
    cin >> a >> b;
    N = calc(a, b, N);
    N = calc(b, a, N);
    cout << N << endl;
    
    return 0;
}

Measured memory_bytes: 234624
#include <bits/stdc++.h>
using namespace std;
const int N=1e9+7;
#define ll long long
#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
ll printNcR(ll n, ll r)
{

    // p holds the value of n*(n-1)*(n-2)...,
    // k holds the value of r*(r-1)...
    long long p = 1, k = 1;

    // C(n, r) == C(n, n-r),
    // choosing the smaller value
    if (n - r < r)
        r = n - r;

    if (r != 0) {
        while (r) {
            p = (((p%N)*(n%N))%N);
            k = ((k%N)*(r%N)%N);
            p=p%N;
            k=k%N;
            // gcd of p, k
            long long m = __gcd(p, k);

            // dividing by gcd, to simplify product
            // division by their gcd saves from the overflow
            p /= m;
            k /= m;

            n--;
            r--;
        }

        // k should be simplified to 1
        // as C(n, r) is a natural number
        // (denominator should be 1 ) .
    }

    else
        p = 1;

    // if our approach is correct p = ans and k =1
    return p%N;
}

class comp {

public:
    bool operator()(pair<int, int> a,
                    pair<int, int> b)
    {
        if(a.first!=b.first)
        return a.first>b.first;
    }
};
ll power(ll x, ll y, ll p)
{
    ll res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return (res%p);
}
int main()
{

    ll n;
    cin>>n;
    ll p=1e9+7;
    if(n==1)
        cout<<0<<endl;
  	
    else
    {
      ll a=power(10,n,p)%p;
      ll b=(2*(power(9,n,p)%p)%p);
      ll c=power(8,n,p)%p;
       cout<<((a+c-b+p)%p)<<endl;
    }

   // getch();
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100005

struct Info{
	bool operator<(const struct Info &arg) const{

		return C > arg.C;
	}
	ll B,C;
};

ll N,M;
ll A[SIZE];
Info info[SIZE];

int main(){

	scanf("%lld %lld",&N,&M);

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

		scanf("%lld",&A[i]);
	}
	sort(A,A+N);

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

		scanf("%lld %lld",&info[i].B,&info[i].C);
	}
	sort(info,info+M);

	bool FLG;
	int index = 0;

	for(int i = 0; i < M && index < N; i++){

		if(info[i].C <= A[index])break;

		for(int k = 0; k < info[i].B && index < N; k++){

			if(info[i].C > A[index]){

				A[index++] = info[i].C;

			}else{

				break;
			}
		}
	}

	ll ans = 0;
	for(int i = 0; i < N; i++){

		ans += A[i];
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 2560
N = int(input())
if 1 <= N and N < 2:
    print(1)
elif 2 <= N and N < 4:
    print(2)
elif 4 <= N and N < 8:
    print(4)
elif 8 <= N and N < 16:
    print(8)
elif 16 <= N and N < 32:
    print(16)
elif 32 <= N and N < 64:
    print(32)
else:
    print(64)



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 X, K, D;
  cin >> X >> K >> D;
  X = abs(X);
  int64 t = X/D;
  X -= min(t, K) * D;
  K -= min(t, K);
  if (K%2 == 0) {
    cout << X << endl;
  } else {
    cout << abs(X-D) << endl;
  }
}

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

int main()
{
  string S;
  int ans = 0;

  cin >> S;

  for (int i = 0; i < 4; i++) {
    if (S[i] == '+') {
      ans++;
    } else {
      ans--;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
using namespace std;
using ll = long long int;
int main()
{
    ll n;
    cin >> n;

    vector<ll> a(3 * n);
    for (size_t i = 0; i < n * 3; i++)
    {
        ll ai;
        cin >> ai;
        a[i] = ai;
    }
    
    sort(a.begin(), a.end(), greater<ll>());
    // 下位 n 人は切り捨て
    a.erase(a.begin() + 2 * n, a.begin() + 3 * n);
    
    ll ans = 0;
    for (size_t i = 0; i < 2 * n; i++)
    {
        if (i % 2 == 1) {
            ans += a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<long long>a(n);
	boost::multiprecision::cpp_int sum = 1;
	for (auto& i : a)
	{
		cin >> i;
		if (i == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		sum *= a[i];
		if (sum > 1000000000000000000) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 4100
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  if (N == M)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
s=list(input())
t=list(input())

switch=0
for i in range(-len(t),-len(s)-1,-1):
    ss=s[i:]
    cnt=0
    for j in range(len(t)):
        if ss[j]==t[j] or ss[j]=='?':
            cnt+=1
    if cnt==len(t):
        switch=1
        s=s[:i]+t+ss[len(t):]
        break
for k in range(len(s)):
    if s[k]=='?':
        s[k]='a'
if switch==1:
    print(''.join(s))
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
int main(void){
  int n,x,y,b,c,i,j,k[2003],a[200][200];
  scanf("%d %d %d",&n,&x,&y);
  for(i=1;i<n;i++){
    k[i]=0;
  }
  for(i=1;i<n;i++){
    for(j=i+1;j<n+1;j++){
      if(j<=x||i>=y||(i<=x&&j<=(y-x)/2+x)||(i>=(y-x)/2+x&&j>=y)||(i>x&&j<y&&j-i<=1+i-x+y-j)){
	a[i][j]=j-i;
      k[j-i]++;
	}else if((i<=x&&j>=y)||(i<=x&&j>=(y-x)/2+x)||(i>=x&&i<(y-x)/2+x&&j>=y)||(i>x&&i<(y-x)/2+x&&j>(y-x)/2+x&&y>j&&j-i>1+i-x+y-j)){
	a[i][j]=abs(x-i)+1+abs(j-y);
	k[abs(x-i)+1+abs(j-y)]++;
	}
      /*printf("%d\t",a[i][j]);*/
	}
    }
  /*printf("\n");*/
    for(i=1;i<n;i++){
	printf("%d\n",k[i]);
    }
    return 0;
  }


Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	int cnt[333333] = { 0 }, sum[333333] = { 0 };
	cin >> N;
	VI res;
	REP(i, N) {
		int a;
		cin >> a;
		a--;
		sum[cnt[a]]++;
		cnt[a]++;
	}
	/*eREP(i, N)cout << cnt[i] << " ";
	cout << endl;
	eREP(i, 5)cout << sum[i] << " ";
	cout << endl;*/


	int i = N, tmp = N;
	FOR(j, 1, N + 1) {
		while (tmp < i*j) {
			i--;
			tmp -= sum[i];
			//cout << tmp << " ";
		}
		cout << i << endl;
	}
	

	return 0;
}



Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}

ll lcm(ll a, ll b){
    ll temp = __gcd(a, b);
    return temp ? (a / temp * b) : 0;
}
int main(){
  fastIO();
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll x = lcm(c,d);
  ll limA1 = (a/c), limA2 = (b/c);
  ll limB1 = (a/d), limB2 = (b/d);
  ll limC1 = (a/x), limC2 = (b/x);
  ll k = (limA2-limA1)+(limB2-limB1)-(limC2-limC1);
  if(a%c==0){	
  	k++;
  }else if(a%d==0){
  	k++;
  }
  cout<<max(((b-a)+1)-k,0LL)<<endl;
}  




Measured memory_bytes: 256
#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<<"Left"<<endl;
  if(a+b<c+d)cout<<"Right"<<endl;
  if(a+b==c+d)cout<<"Balanced"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    #define ll long long
    //pair<int, int> *p=new pair<int, int>[n];
    //std::vector<pair<int,int>> vp;
    //v.push_back(make_pair(x,y))
    //pair<int, int> p[1001];
    //string *s=new string [n];
     
    //int freq[e];
    //freq[a[i]-'a']++; freq[a[i]]++;
    using namespace std;  
        ll t,n,c1,c2,c3,sum,m,mn,k,pos=0;
     //   set<double>v,v2,v3;
double cum[100000001];
    int main(void)
    {
        double mx=-1;
      //  ll sum=0;
       // dobl su=0;
        
        SpeeD;  
   
 cin >> n >> k;
  double *a = new double [n+1];
  a[0]=0;
  cum[0]=0;
  for (int i=1;i<=n;i++)
  {
  cin>>a[i];
 if ((int)a[i]%2==0)
     a[i]=((int)(a[i]/2)) + 0.5;
     else 
       a[i]=((int)(a[i]/2)) + 1;
  
      
   // cout<<a[i];
    
    
cum[i]=cum[i-1] + a[i] ;
//cout<<cum[i];
           
  }
  
    
  
	for (int i=k;i<=n;i++)
		mx = max(cum[i]-cum[i-k],mx);
 cout<<fixed<<setprecision(9)<<mx;
	}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n,k;
 cin>>n>>k;
 double a[n];
 double s[n];
 int i;
 for(i=0;i<n;i++)
 {
  cin>>a[i];
  a[i]=(a[i]+1)/2.0;
  if(i==0)
  s[i]=a[i];
  else
  s[i]=s[i-1]+a[i];
 }
 double ans=0;
 for(i=k-1;i<n;i++)
 {
 	ans=max(ans,s[i]-(i==(k-1)?0:s[i-k]));
 }
 cout.precision(12);
 cout<<ans<<endl;
 return 0;
}


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

int main(){
	long long  n,m;
	cin>>n>>m;
	vector<long long>h(n);
	vector<long long>hantei(n,-1); 
	for(int i=0;i<n;i++){
      cin>>h[i];
    }
	for(int i=0;i<m;i++){
		long long a,b;
		cin>>a>>b;
		if(h[a-1]<h[b-1]){
			hantei[a-1]=0;
			if(hantei[b-1]==0){
				hantei[b-1]=0;
			}else{
				hantei[b-1]=1;
			}
		}else if(h[a-1]>h[b-1]){
			if(hantei[a-1]==0){
				hantei[a-1]=0;
			}else{
				hantei[a-1]=1;
			}
			hantei[b-1]=0;
		}else if(h[a-1]==h[b-1]){
          hantei[a-1]=0;
          hantei[b-1]=0;
        }
	}
	long long count=0;
	rep(i,n){
		//cout<<hantei[i]<<endl;
		if(hantei[i]==1||hantei[i]==-1)count++;
	}
	cout<<count<<endl;
	return 0;
}

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

b2=0
b4=0
bb=0
for a in A:
  if a%4==0:
    b4+=1
  if a%2==0:
    b2+=1
bb=N-b2
b2-=b4
#print(b4,b2,bb)

if b2==0:
  if b4+1>=bb:
    print("Yes")
  else:
    print("No")
else:
  if b4>=bb:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 14252
package main

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

// template start
var sc = bufio.NewScanner(os.Stdin)

func input2int() int{
	sc.Scan()
	num , _ := strconv.Atoi(sc.Text())
	return num
}

func input2intarr(n int) []int{
	sc.Scan()
	in := strings.Split(sc.Text(), " ")
	out := make([]int, n)
	for i:=0; i<n; i++{
		out[i], _ = strconv.Atoi(in[i])
	}
	return out
}
// template end

func main(){
	var n = input2int()
	a := n/100
	b := (n-100*a)/10
	c := n-(100*a+10*b)
	if a > b{
		fmt.Println(a*111)
	} else if a < b{
		fmt.Println((a+1)*111)
	} else {
		if a >= c {
			fmt.Println(a*111)
		} else {
			fmt.Println((a+1)*111)
		}
	}
}

Measured memory_bytes: 640
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let s = read1::<String>().chars().collect::<Vec<char>>();
    let mut ans = -1;
    if s.len() == 2 {
        if s[0] == s[1] {
            println!("1 2");
        } else {
            println!("-1 -1");
        }
        return;
    }
    for l in 0..s.len()-2 {
        if s[l] == s[l+1] || s[l] == s[l+2] || s[l+1] == s[l+2] {
            ans = l as isize;
            break;
        }
    }
    if ans >= 0 {
        println!("{} {}", ans+1, ans+3);
    } else {
        println!("-1 -1");
    }
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main{
    public static void main(String[]arg){
        Scanner sc = new Scanner(System.in);
            while(true){
              int H = sc.nextInt();
              int W = sc.nextInt();
              if(H==0 && W==0) break;
                 for(int i=0;i<H;i++){
                 for(int j=0;j<W;j++){
                        if((i+j)%2==0){
                         System.out.print("#");
                        }else{
                             System.out.print(".");
                          }
                        }
                 System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
}


Measured memory_bytes: 38032
N = int(input())
SP = []

for i in range(N):
  s,p = input().split()
  SP.append([i+1,s,int(p)])

SP.sort(reverse = True, key = lambda x: x[2])
SP.sort(key = lambda x: x[1])

for num,_,_ in SP:
  print(num)

Measured memory_bytes: 3060
n = int(input())
cost_list = [ int(v) for v in input().split() ]
if n == 1:
	ans = 0
elif n == 2:
	ans = abs(cost_list[0]-cost_list[1])
else:
	ans_list =  [0, abs(cost_list[0]-cost_list[1])] + [ 10**9+1 for i in range(n-2) ]
	for i in range(2,n):
		ans_list[i] = min(ans_list[i-2]+abs(cost_list[i-2]-cost_list[i]),ans_list[i-1]+abs(cost_list[i-1]-cost_list[i])) 
	ans = ans_list[-1]

print(ans)

Measured memory_bytes: 53616
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long dp[][] = new long[n][n];
		for ( int i = 0; i < n; i++ ) {
			dp[i][i] = in.nextInt();
		}
		in.close();

		for ( int col = 1; col < n; col++ ) {
			int r = 0, c = col;
			while ( c < n ) {
				dp[r][c] = Math.max(dp[r][r] - dp[r + 1][c], dp[c][c] - dp[r][c - 1]);
				r++;
				c++;
			}
		}
		System.out.println(dp[0][n - 1]);
	}
}

Measured memory_bytes: 132080
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int A, B, C, D, N;
  cin >> A >> B >> C >> D >> N;

  chmin(B, A*2);
  chmin(C, B*2);
  chmin(D, C*2);

  cout << D*(N/2)+(N%2)*C << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

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

using namespace std;

typedef long long ll;

// is_prime[i] が true なら i は素数
bool prime_table[1000006];

void sieve_of_era(int n) {
  for (int i = 0; i <= n; i++) { prime_table[i] = true; }

  prime_table[0] = false;
  prime_table[1] = false;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  sieve_of_era(1000005);

  int a, d, n;
  while ( cin >> a >> d >> n ) {
    if (a == 0 && d == 0 && n == 0) {
      break;
    }
    for (int x = a; ; x += d) {
      if ( prime_table[x] ) { n--; }
      if (n == 0) {
        cout << x << endl;
        break;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 4096
def main():
    N, M = list(map(int, input().split()))

    pref = []
    for _ in range(M):
        P, Y = list(map(int, input().split()))
        pref.append((P, Y))

    pref_sorted = sorted(enumerate(pref), key=lambda x: x[1])

    idx = [1 for _ in range(N)]
    res = ['' for _ in range(M)]
    for j, (p, y) in pref_sorted:
        res[j] = str(p).zfill(6) + str(idx[p - 1]).zfill(6)
        idx[p - 1] += 1
    for r in res:
        print(r)


if __name__ == '__main__':
    main()


Measured memory_bytes: 36716
#include <bits/stdc++.h>
using namespace std;
int n;
int a[2000005];
int x=0;
long long ans=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=2;i<=n;i++)
	{
		if(a[i]<a[i-1])
		{
			ans+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 4544
/*
* @Author: 王文宇
* @Date:   2017-11-18 22:07:07
* @Last Modified by:   王文宇
* @Last Modified time: 2017-11-18 22:09:28
*/
#include <iostream>
using namespace std;
int n;
long long a[87];
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	a[0]=2;
	a[1]=1;
	for(int i=2;i<=86;i++)
	{
		a[i]=a[i-1]+a[i-2];
	}
	cin>>n;
	cout<<a[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll i,j,n;
  cin>>n;
  string s;
  cin>>s;
  ll ans = 0;
  for(i=1;i<n;i++)
  {
    if(s[i]!=s[i-1]) ans++;
  }
  cout<<ans+1;
  return 0;
}

Measured memory_bytes: 512
m=0
a=0
r=0
c=0
h=0

N=int(input())
for i in range(N):
  S=input()
  if S[0]=='M':
    m+=1
  if S[0]=='A':
    a+=1
  if S[0]=='R':
    r+=1
  if S[0]=='C':
    c+=1
  if S[0]=='H':
    h+=1
    
nums=[m, a, r, c, h]

counter=0
for i in range(3):
  for j in range(i+1, 4):
    for k in range(j+1, 5):
      counter+=nums[i]*nums[j]*nums[k]
      
print(counter)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;
void swap(int &a, int &b);

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

	// Rowデータ格納
	char *fig = new char[number];
	int *rank = new int[number];

	// 01判定用
	bool Card[4][13] = { };
	
	for (int i = 0; i < number; ++i)
	{
		cin >> fig[i] >> rank[i];

		int tempID = rank[i] - 1;
		switch (fig[i])
		{
		case 'S':
			Card[0][tempID] = true;
			break;
		case 'H':
			Card[1][tempID] = true;
			break;
		case 'C':
			Card[2][tempID] = true;
			break;
		case 'D':
			Card[3][tempID] = true;
			break;
		default:
			cout << "エラー" << endl;
			return 0;
		}

	}
		
	char Fig[4] = { 'S','H','C','D' };

	for (int i = 0; i < 4; ++i)
	{
		for (int j = 0; j < 13; ++j)
		{
			if (Card[i][j] == false)
			{
				cout << Fig[i] << " " << j + 1 << endl;
			}

		}
	}

	return 0;
}




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

int main() {
	int A, B, C;
	cin >> A>>B;
	cout << max(A+B,max(A-B,A*B));
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N;
  char arr[100];
  bool ck=false;
  scanf("%d",&N);
  for (size_t i = 0; i < N; i++) {
    scanf("%c\n",&arr[i]);
  }
  for (size_t i = 0; i < N; i++) {
    if(arr[i]=='Y') ck=true;
  }
  if(ck) printf("Four");
  else printf("Three");
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] antenas = {
            sc.nextInt(),
            sc.nextInt(),
            sc.nextInt(),
            sc.nextInt(),
            sc.nextInt()
        };
        int dist = sc.nextInt();
        boolean res = true;
        for (int i = 0;i < antenas.length - 1;i++) {
            for (int j = i; j + i < antenas.length - 1; j++) {
                if (antenas[j+1] - antenas[i] > dist) {
                    res = false;
                    break;
                }
            }
            if (!res) break;
        }
        
        System.out.println(res ? "Yay!" : ":(");
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int A[N]={0};
  int x=0;
  for(int i=0;i<N-1;i++){
    cin>>x;
    A[x-1]+=1;
  }
  for(int i=0;i<N;i++){
  cout<<A[i]<<endl;
  }
 
 return 0; 
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)

int main(){
   vector<vector<int>> c(3,vector<int>(3));
   rep(i,3){
      rep(j,3){
         cin >> c.at(i).at(j);
      }
   }
   int i1,i2,i3,i4,i5,i6;
   i1=c.at(1).at(0)-c.at(0).at(0);
   i2=c.at(1).at(1)-c.at(0).at(1);
   i3=c.at(1).at(2)-c.at(0).at(2);
   i4=c.at(2).at(0)-c.at(1).at(0);
   i5=c.at(2).at(1)-c.at(1).at(1);
   i6=c.at(2).at(2)-c.at(1).at(2);
   int j1,j2,j3,j4,j5,j6;
   j1=c.at(0).at(1)-c.at(0).at(0);
   j2=c.at(1).at(1)-c.at(1).at(0);
   j3=c.at(2).at(1)-c.at(2).at(0);
   j4=c.at(0).at(2)-c.at(0).at(1);
   j5=c.at(1).at(2)-c.at(1).at(1);
   j6=c.at(2).at(2)-c.at(2).at(1);
   if (i1==i2&&i2==i3&&i4==i5&&i5==i6&&j1==j2&&j2==j3&&j4==j5&&j5==j6)
      cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
a = [int(_) for _ in list(input().split())]
a.append(0)
diff = []
for i in range(len(a)-1):
  diff.append(a[i]-a[i+1])
# print(diff)

#if all():
#  print(1000)
#  sys.exit
flag = 'buy'
money = 1000
stock = 0
for i in range(n):
  # print(flag, diff[i], money, stock)
  if (flag=='buy') & (diff[i]<0):
    stock = money//a[i]
    money -= money//a[i]*a[i]
    flag = 'sell'
    continue
  elif (flag=='sell') & (diff[i]>0):
    money += stock*a[i]
    stock = 0
    flag = 'buy'
    continue
  else:
    continue
print(money)

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,i,j;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
      cin>>a[i];
    vector<int>T(n,0);
    T[1]=abs(a[1]-a[0]);
    int ans=-1;
    if(n<=2){
      if(n<=1)
        cout<<0;
      else
      cout<<T[1];
    }
  else{
    for(i=2;i<n;i++){
        T[i]=min(T[i-1]+abs(a[i]-a[i-1]),
                 T[i-2]+abs(a[i]-a[i-2]));
      
    }
    cout<<T[n-1];
  }
  return 0;
  }


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int A,B; cin >> A >> B;
	if(A <= 5){
		cout << 0 << endl;
	}else if(A >= 13){
		cout << B << endl;
	}else{
		cout << B/2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 

*/
//================== INPUT ========================
int N;
//=================================================
void input()
{
    cin>>N;

}
//=================================================
void solve()
{
    for (int i = N; i<= 999; ++i){
        if (i % 111 == 0) {
            cout<<i<<endl;
            return;
        }
    }

}

//=================================================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int dp[2][1000000];
int v[1000];
int main()
{
	int n;
	for (int j = 0; j < 1000000; j++)
	{
		dp[0][j] = 999999;
		dp[1][j] = 999999;
	}
	dp[0][0] = 0;
	dp[1][0] = 0;
	for (int i = 1;i < 1000; i++)
	{
		int k = i * (i + 1) * (i + 2) / 6;
		if (k >= 1000000)break;
		v[i - 1] = k;
	}
	for (int i = 0; i < 1000000; i++)
	{
		for (int j = 0;j < 1000; j++)
		{
			if (i + v[j] >= 1000000)break;
			dp[0][i + v[j]] = min(dp[0][i + v[j]], dp[0][i] + 1);
			if (v[j] % 2 == 0)continue;
			dp[1][i + v[j]] = min(dp[1][i + v[j]], dp[1][i] + 1);
		}
	}
	while (cin >> n && n != 0)
	{
		cout << dp[0][n] << " " << dp[1][n] << endl;
	}
	return 0;
}

Measured memory_bytes: 8976
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

int kane;
int oturi[6]={500,100,50,10,5,1};
int mai;

int main(){
	while(1){
		mai=0;
		cin>>kane;
		if(kane==0) break;
		kane=1000-kane;
		for(int i=0;i<6;i++){
			mai+=(kane/oturi[i]);
			kane%=oturi[i];
		}
		cout<<mai<<endl;
	}
		
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;

typedef long long int ll;
const int MOD = 1e9 + 7;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  auto x = vector<ll>(N);
  auto y = vector<ll>(N);
  auto x2 = vector<ll>(N);
  auto y2 = vector<ll>(N);
  REP(i, N) {
    cin >> x[i] >> y[i];
    x2[i] = x[i];
    y2[i] = y[i];
  }
  sort(ALL(x2));
  sort(ALL(y2));

  ll ans = INF;
  REP(lx, N) for(int rx = lx + 1; rx < N; rx++) REP(ly, N) for(int ry = ly + 1; ry < N; ry++) {
    int cnt = 0;
    REP(i, N) {
      if(x2[lx] <= x[i] && x[i] <= x2[rx] && y2[ly] <= y[i] && y[i] <= y2[ry]) {
        cnt++;
      }
    }
    if(K <= cnt) {
      ll s = (x2[rx] - x2[lx]) * (y2[ry] - y2[ly]);
      ans = min(ans, s);
    }
  }
  cout << ans << endl;
}


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

int main() {
  string s; cin >>s;
  string ans = "AC";
  if (s.at(0)!='A') ans = "WA";
  if (s.at(1)<'a' || s.at(s.size()-1)<'a') ans = "WA";
  int cnt = 0;
  for (int i=2; i<s.size()-1; i++){
    if (s.at(i) == 'C') cnt++;
    else if (s.at(i) < 'a') ans = "WA";
  }
  if (cnt!=1) ans = "WA";
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let abk = readn::<usize>(" ");
    let mut a = abk[0];
    let mut b = abk[1];
    let k = abk[2];

    for i in 0..k {
        if i % 2 == 0 {
            a /= 2;
            b += a;
        } else {
            b /= 2;
            a += b;
        }
    }

    println!("{} {}", a, b);
}

Measured memory_bytes: 4352
import sys
 
counter = 0
block = []
for line in sys.stdin:
  if line == "\n":
    counter = -1
    block = []
  else:
    counter += 1
    for i in line:
      if i == "1":
        block.append([counter,line.index(i)])
  if counter == 7:
    if block[0][0] == block[1][0]:
      if block[1][0] == block[2][0]:
        print("C")
      elif block[0][1] == block[2][1]:
        print("A")
      elif block[0][1] < block[2][1]:
        print("E")
      else:
        print("G")
    else:
      if block[0][1] == block[3][1]:
        print("B")
      elif block[0][1] < block[3][1]:
        print("F")
      else:
        print("D")


Measured memory_bytes: 5572
/******************************************
*    AUTHOR:         julianferres         *
******************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
const ll INF = 1<<30 ;
const int N = 100005;

const int K = 100005;
vector<int> loss(K,-1);
int n; vector<int> a(N);

int fill(int k){
	if(loss[k]!=-1) return loss[k];
	bool win = 0;
	forn(i,n){
		if(k-a[i]>=0) win |= (fill(k-a[i]));
	}

	loss[k] = 1-win;
	return loss[k];
}

int main(){
    FIN;
    int k; cin >> n >> k;
    forn(i,n) cin >> a[i];
    int m = INF;
    forn(i,n) m = min(m,a[i]);

    forn(i,m) loss[i] = 1;
    // forn(i,k+1) cout << loss[i] << " \n"[i==k];
    fill(k);
    // forn(i,k+1) cout << loss[i] << " \n"[i==k];
    cout << (loss[k] ? "Second" : "First") << endl;

    return 0;
}



Measured memory_bytes: 5760
a ,b ,c ,d ,e ,f = map(int,input().split())
water = set()
sugar = set()
cou = 0
co = 0

for i in range(f//b):
    cou = 0
    while 100 * b * i + 100 * a * cou <= f:
        water.add(100 * b * i + 100 * a * cou)
        cou += 1
water = sorted(water)


for i in range(f//d):
    cow = 0
    while d * i + c * cow <= f:
        sugar.add(d * i + c * cow)
        cow += 1
sugar = sorted(sugar)




ans = [0,0,0]

for wat in water:
    for sug in sugar:
        if wat or sug:
            if wat + sug <= f and e / (100 + e) >= sug/(wat+sug):
                if ans[0] <= sug/(wat+sug):
                    ans = [sug/(wat+sug), wat+sug, sug]
print(ans[1],ans[2])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,t;cin >> n >> t;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	int ans = t;
	rep(i,n - 1){
		ans += min(a.at(i + 1) - a.at(i), t);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var n = inputs[0];
        var k = inputs[1];
        var pk = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        var targetExpectedValues = new double[n];

        var sum = 0;
        var expectedValues = new double[1001];
        // すべての種類のサイコロの期待値を事前計算 (pi <= 1000)
        for(int i = 1; i < 1001; i++)
        {
            sum += i;
            expectedValues[i] = (double)sum / i;
        }

        // 与えられた期待値入れる
        for(int i = 0; i < n; i++)
        {
            targetExpectedValues[i] = expectedValues[pk[i]];
        }

        // 累積和
        var cSum = new CumulativeSum(targetExpectedValues);

        // 探す
        double answer = 0;
        for(int i = 0; i <= n - k; i++)
        {
            var s = cSum.GetSum(i, i + k);
            if (answer < s) answer = s;
        }

        Console.WriteLine(answer);
    }
}

/// <summary>
/// 累積和
/// </summary>
public class CumulativeSum
{
    public double[] Array { get; }

    public CumulativeSum(float[] array) : this(array.Select(t => (double)t).ToArray()) { }

    public CumulativeSum(double[] array)
    {
        var length = array.Length;
        Array = new double[length + 1];

        for (int i = 0; i < length; i++)
        {
            Array[i + 1] = array[i] + Array[i];
        }
    }

    /// <summary>
    /// left以上right未満の総和
    /// </summary>
    /// <param name="left">以上</param>
    /// <param name="right">未満</param>
    public double GetSum(int left, int right)
    {
        if (left >= right) return 0;

        return Array[right] - Array[left];
    }
}

Measured memory_bytes: 35548
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n, k;
    cin >> n >> k;
    if(n == 2){
        if(k == 0){
            cout << 1 << endl;
            cout << 1 << " " << 2 << endl;
            return 0;
        }
        cout << -1 << endl;
        return 0;
    }

    if(nCr(n - 1, 2) < k){
        cout << -1 << endl;
        return 0;
    }



    cout << n - 1 + nCr(n - 1, 2) - k << endl;

    for(int i = 2; i <= n; i++){
        cout << 1 << " " << i << endl;
    }

    int cnt = 0;
    int rest = nCr(n - 1, 2) - k;

    for(int i = 2; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(cnt == rest) return 0;
            if(i >= j) continue;
            cout << i << " " << j << endl;
            cnt++;
        }
    }

}

Measured memory_bytes: 256
import bisect
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    score = {}

    for i in range(n):
        s = a[i] + i + 1
        if s not in score:
            score[s] = [i]
        else:
            score[s].append(i)
    ans = 0
    for j in range(n):
        s = (j + 1) - a[j]
        if s in score:
            size = len(score[s])
            if size > 0:
                tmp = bisect.bisect_left(score[s], j)
                ans += tmp
    print(ans)

Measured memory_bytes: 113948
def main():
    N = int(input())
    L = [0] * (N + 1)
    L[0], L[1] = 2, 1
    for i in range(2, N + 1):
        L[i] = L[i - 2] + L[i - 1]
    print(L[-1])


if __name__ == '__main__':
    main()


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

using namespace std;

const int mxN=1e5+10;

//vector< vector< int > > adj(mxN,vector<int> ());
vector <int> adj[mxN];
int vis[mxN],a[mxN],dp[mxN];

int dfs(int v)
{
	if(vis[v]) return dp[v];

	vis[v]=1;
	int mx=0;
	for(int u:adj[v])
	{
		mx=max(mx,dfs(u)+1);
	}

	return dp[v]=mx;
}

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

	for(int i=0;i<m;i++)
	{
		int u,v;
		cin>>u>>v;

		adj[u].push_back(v);
		
	}
	int best=0;
	for(int i=1;i<=n;i++)
	{
		best=max(best,dfs(i));
	}

	cout<<best<<"\n";
}

Measured memory_bytes: 8576
N,K = map(int, input().split())
MOD = 10**9 + 7
es = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = map(int, input().split())
    es[a-1].append(b-1)
    es[b-1].append(a-1)


MAXN = K+5
fac = [1,1] + [0]*MAXN
finv = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD
 
def nPr(n,r):
    if n < r:
        return 0
    return fac[n] * finv[n-r]
"""
curr とその親prevの色が決まっているときに、currの子nxtの色の塗り方の場合の数は
nPr(K-2, len(es[curr]) - 1)
Kのうちprevとcurrで２色使っていて、currにつながっているもののうち一つはprevだから、１引いたものが子供の数。
で、一番初めのノードoriginについて考えると、親はないのでノードorigin自体はK個の塗り方があり、その子には、nPr(K-1, len(es[origin]))の塗り方がある
あとはDFS的に子供の塗り方を決めていく

"""

checked = [False] * N
ans = K * nPr(K-1, len(es[0]))
checked[0] = True

stack = []
for nxt in es[0]:
    stack.append(nxt)

while stack:
    curr = stack.pop()
    checked[curr] = True
    ans *= nPr(K-2, len(es[curr]) - 1)
    if ans >= MOD: ans %= MOD
    for nxt in es[curr]:
        if not checked[nxt]:
            stack.append(nxt)

print(ans % MOD)

Measured memory_bytes: 35384
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

// ARC-075-E

//セグメント木
// ref:https://ei1333.github.io/luzhiled/snippets/structure/segment-tree.html
template <typename Mnd>
struct segment_tree {
    int sz;
    vector<Mnd> data;
    function<Mnd(Mnd, Mnd)> f;
    Mnd e;
    //サイズだけ指定して初期化
    segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
        sz = 1;
        while (sz < _sz) sz <<= 1;
        data.assign(sz * 2, e);
    }
    //参照渡しなので代入とかもできる
    Mnd& operator[](const int& k) {
        return data[k + sz];
    }
    //木を構築 O(n)
    void build() {
        for (int i = sz - 1; i > 0; i--)
            data[i] = f(data[2 * i], data[2 * i + 1]);
    }
    //更新しつつ木を再構築 O(log n)
    void update(int k, Mnd x) {
        data[k += sz] = x;
        while (k >>= 1) data[k] = f(data[2 * k], data[2 * k + 1]);
    }
    //[a,b)でのクエリに答える　O(log n)
    Mnd query(int a, int b) const {
        Mnd l = e, r = e;
        for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if (a & 1) l = f(l, data[a++]);
            if (b & 1) r = f(r, data[--b]);
        }
        return f(l, r);
    }
};

// 各項の順序を保ったまま最小値0,最大値size()-1以下にする
template <typename T>
vector<T> simplify(vector<T>& a) {
    int n = a.size();
    vector<T> b = a;
    sort(b.begin(), b.end());
    vector<T> res(n);
    for (int i = 0; i < n; i++)
        res[i] = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
    return res;
}
// 転倒数を計算
// depend:segment_tree
template <typename T>
long long inversion_number(vector<T>& a) {
    using lint = long long int;
    int n = a.size();
    vector<T> b = simplify(a);
    segment_tree<lint> count(
        n, [](lint a, lint b) { return a + b; }, 0);
    lint res = 0;
    for (int i = 0; i < n; i++) {
        res += count.query(b[i] + 1, n);
        count.update(b[i], count[b[i]] + 1);
    }
    return res;
}

// 累積和
struct cumulative_sum {
    using lint = long long int;
    int sz;
    // data[i]:元の数列
    vector<lint> data;
    // cum[i]:[0,i)の和
    vector<lint> sum;
    // 要素数を指定して初期化
    cumulative_sum(const int _sz) : sz(_sz) {
        data.assign(sz, 0);
        sum.assign(sz + 1, 0);
    }
    lint& operator[](const int k) {
        return data[k];
    }
    // dataに基づいてsumを構築
    void build() {
        for (int i = 0; i < sz; i++) sum[i + 1] = sum[i] + data[i];
    }
    // [a,b)の和を求める
    lint query(const int a, const int b) {
        return sum[b] - sum[a];
    }
};

int main() {
    lint n, k;
    cin >> n >> k;
    cumulative_sum a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= k;
    }
    a.build();
    cout << n * (n + 1) / 2 - inversion_number(a.sum) << endl;
}

Measured memory_bytes: 9060