akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 501;
const int mod = 1e9+7;
int arr[3][upperlimit];
int color[upperlimit][upperlimit];
int ans[3][upperlimit];
int main() {
	int n,c;
	int inp;
	sd(n);
	sd(c);
	for(int i = 1; i <= c; i++){
		for(int j = 1; j <= c; j++){
			sd(color[i][j]);
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			sd(inp);
			arr[(i+j)%3][inp]++;
		}
	}
	int a;
	int calc;
	for(int i = 0; i < 3; i++){
		for(int j = 1; j <= c; j++){
			calc=0;
			for(int k = 1;  k <= c; k++){
				calc+=arr[i][k]*color[k][j];
			}
			ans[i][j]=calc;
		}
	}
	int final_ans=INF;
	for(int i = 1; i <= c; i++){
		for(int j = 1; j <= c; j++){
			if(j!=i){
				for(int k = 1; k <= c; k++){
					if((k!=i)&&(k!=j)){
						final_ans=min(final_ans,ans[0][i]+ans[1][j]+ans[2][k]);
					}
				}
			}
		}
	}
	pd(final_ans);
	return 0;
}

Measured memory_bytes: 256
/*---> 03 December 2019 <--- > 01:28:16 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;
int n;
string s;
void add(int &a,int b){
	a+=b;
	if(a>=mod)
		a-=mod;
}
int32_t main(){__
	cin>>s;
	n=s.length();
	vi dp(2,1);
	for(int i=n-1;i>=0;i--){
		vi tdp(2);
		int cur=s[i]-'0';
		if(!cur){
			add(tdp[1],dp[1]);
		}
		else{
			add(tdp[1],dp[0]);
			add(tdp[1],(2*dp[1])%mod);
		}
		add(tdp[0],(3*dp[0])%mod);
		dp=tdp;
	}
	cout<<dp[1]<<"\n";
return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    int a,b,n;
    cin >> n >> a >> b;
    if ((b - a - 1) % 2 == 0)cout << "Borys" << endl;
    else cout << "Alice" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
ll Upper = UPPER / 100000;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	V a(n + 1);
	rep(i, n + 1) {
		cin >> a[i];
	}
	if (n == 0 && a[0] == 1) {
		cout << 1 << endl;
		return 0;
	}
	else if (n == 0 && a[0] != 1) {
		cout << -1 << endl;
		return 0;
	}
	else if (n != 0 && a[0] != 0) {
		cout << -1 << endl;
		return 0;
	}
	/*
	最終的な頂点の数はa[n]である
	そこを超えないようにとる？
	*/
	VL wants(n + 1, 1);
	ll nxt = 1;
	ll maxi = a[n];
	rep1(i, n) {
		ll Nxt = nxt * 2;
		chmin(Nxt, Upper);
		nxt = Nxt;
		nxt -= a[i];
		wants[i] = nxt;
		if (nxt <= 0 && i != n) {
			cout << -1 << endl;
			return 0;
		}
		if (nxt < 0 && i == n) {
			cout << -1 << endl;
			return 0;
		}

	}
	ll ans = a[n];
	for (int i = n - 1; i >= 0; i--) {
		chmin(wants[i], maxi);
		ans += min(maxi, wants[i]) + a[i];
		/*
		最大値は常にa[n]ではなく変化していく
		その頂点の葉っぱの数で変わっていく
		*/
		maxi = min(maxi, wants[i]) + a[i];
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    string s;
    cin >> s;

    switch (s[0])
    {
        case 'S':
            cout << "Cloudy" << endl;
            break;
        case 'C':
            cout << "Rainy" << endl;
            break;
        case 'R':
            cout << "Sunny" << endl;
            break;
    }
    return 0;
}

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

int main() {
  int n,k;
  string s;
  cin >> n >> k >> s;
  k -=1;
  s[k]+=('a'-'A');
  cout << s << endl;
}

Measured memory_bytes: 256
while True:
  a = raw_input()
  if int(a[0]) == 0 and int(a[2]) == 0: break
  b =[]
  hit=0
  blow=0
  for i in range(5,9):
    b.append(a[i])
  for x in range(0,4):
    for y in range(0,4):
      if a[x] == b[y]:
        if x == y:
          hit +=1
        else: blow +=1
  print hit,blow

Measured memory_bytes: 4236
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
main(){
	int data;
	cin>>data;
	for(int r=1;r<=data;++r){
		double x1,x2,x3,y1,y2,y3,d,x,y,r;
		cin>>x1>>y1>>x2>>y2>>x3>>y3;
		d=4*(x3-x2)*(y2-y1)-4*(y3-y2)*(x2-x1);
		x=2*(x3*x3-x2*x2+y3*y3-y2*y2)*(y2-y1)-2*(y3-y2)*(x2*x2-x1*x1+y2*y2-y1*y1);
		y=2*(x3-x2)*(x2*x2-x1*x1+y2*y2-y1*y1)-2*(x3*x3-x2*x2+y3*y3-y2*y2)*(x2-x1);
		x2=x/d;
		y2=y/d;
		r=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
		printf("%.3f %.3f %.3f\n",x2,y2,r);
	}
}

Measured memory_bytes: 1244
#include <iostream>
#include <stdio.h>
#include <string>

#define MAX_N 500'000

typedef long long ll;

using namespace std;

ll A[MAX_N]{};

int main() {
  string S;
  cin >> S;
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == '<') {
      A[i + 1] = A[i] + 1;
    }
  }
  for (int i = S.size() - 1; i >= 0; --i) {
    int a = A[i + 1] + 1;
    if (S[i] == '>' && a > A[i]) {
      A[i] = A[i + 1] + 1;
    }
  }
  ll res = 0;
  for (int i = 0; i <= S.size(); ++i) {
    res += A[i];
  }
  printf("%lld\n", res);
}

Measured memory_bytes: 7416
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define xrep(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define vl vector<long long>
#define vs vector<string>
#define vvl vector<vector<long long>>
#define all(A) A.begin(), A.end()

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

    int sum = 0;
    rep(i,n.size()){
        int add = n[i] - '0';
        sum += add;
        sum %= 9;
    }

    if(sum%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3748
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    set<int> s;
    int n;
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        if(s.count(a)==1)s.erase(a);
        else s.insert(a);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 4864
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        A = [list(map(int, input().split())) for _ in range(2)]

        ans = 0
        for i in range(N):
            ans = max(ans, sum(A[0][:i + 1]) + sum(A[1][i:]))
        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 38512
H,W = map(int,input().split())
S = [input().strip() for _ in range(H)]
X = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    j = 0
    cur = j
    while j<W:
        if S[i][j]==".":
            j += 1
        else:
            for k in range(cur,j):
                X[i][k] = j-cur
            j += 1
            cur = j
    for k in range(cur,W):
        X[i][k] = W-cur
Y = [[0 for _ in range(W)] for _ in range(H)]
for j in range(W):
    i = 0
    cur = i
    while i<H:
        if S[i][j]==".":
            i += 1
        else:
            for k in range(cur,i):
                Y[k][j] = i-cur
            i += 1
            cur = i
    for k in range(cur,H):
        Y[k][j] = H-cur
cmax = 0
for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            cmax = max(cmax,X[i][j]+Y[i][j]-1)
print(cmax)

Measured memory_bytes: 145184
#define _GLIBCXX_DEBUG
#define ll long long
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a,b,x;
    cin >> a >> b;
    if (a>9 || b>9){
        cout << -1 << endl;
    }
    else{
        x = a*b;
        cout << x << endl;
    }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define  rep(i,n) for(li i = 0; i < (n); ++i)
#define  red(i,n) for(li i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    int a,b,c,x,q=0;
    cin>>a>>b>>c>>x;
    rep(i,a+1)rep(j,b+1)rep(k,c+1)q+=(i*500+j*100+k*50==x);
    cout<<q<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M ((ll)(1e9)+7)
#define f first
#define S second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
typedef long long ll;

void solve()
{
    int n,k;
    cin>>n;
    vector<pair<int,int>> v;
    for(int i=1;i<=n;i++)
    {
        cin>>k;
        v.pb({k,i});
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++)
    cout<<v[i].S<<" ";
    cout<<endl;
}
int main()
{
    solve();
}

Measured memory_bytes: 1780
#include <cstdio>
#include <vector>
using namespace std;

int main() {
	vector<int> A;
	int num_query; scanf("%d", &num_query);
	int command, x;
	for (int loop = 0; loop < num_query; loop++) {
		scanf("%d", &command);
		if (command < 2) scanf("%d", &x);
        if (command == 0) A.emplace_back(x);
        if (command == 1) printf("%d\n", A[x]);
        if (command == 2) A.pop_back();
	}
	return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
int mod = 1e9 + 7;

signed main() {
    int N, A, B;
    cin >> N >> A >> B;
    if ((B - A) % 2 == 0) {
        cout << (B - A) / 2 << endl;
    } else {
        int a = (A - 1) + ((B - A - 1) / 2) + 1;
        int b = (N - B) + ((N - (A + N - B) - 1) / 2) + 1;
        // cout << a << " " << b << endl;
        cout << min(min(N - A, B - 1), min(a, b)) << endl;
    }
}


Measured memory_bytes: 256
A = input().split()

S =[0]
def push(x):
    S.append(x)

def pop(S):
    top_id = len(S) - 1
    top = S.pop(top_id)
    return top

for i in range(len(A)):

    if A[i] == '+':
        push(pop(S) + pop(S))
        continue
    
    if A[i] == '-':
        push(-pop(S)+pop(S))
        continue
    
    if A[i] == '*':
        push(pop(S)*pop(S))
        continue
    
    else:
        A[i] = int(A[i])
        push(A[i])

print(pop(S))


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

int main() {
  long n,c,z=0,o=0,t=0,ans=99999999999999999;
  cin >> n >> c;
  vector<vector<long>> d(c,vector<long>(c));
  vector<long> ze(c);
  vector<long> on(c);
  vector<long> tw(c);
  vector<long> z_iwakan(c);
  vector<long> o_iwakan(c);
  vector<long> t_iwakan(c);
  for(long i=0;i<c;i++) for(long j=0;j<c;j++) cin >> d[i][j];
  for(long i=0;i<n;i++) {
    for(long j=0;j<n;j++) {
      long a;
      if((i+j)%3==0) {
        z++;
        cin >> a;
        ze[a-1]++;
      } else if((i+j)%3==1) {
        o++;
        cin >> a;
        on[a-1]++;
      } else {
        t++;
        cin >> a;
        tw[a-1]++;
      }
    }
  }

  for(long i=0;i<c;i++) {
    for(long j=0;j<c;j++) {
      z_iwakan[i]+=d[j][i]*ze[j];
    }
  }
  for(long i=0;i<c;i++) {
    for(long j=0;j<c;j++) {
      o_iwakan[i]+=d[j][i]*on[j];
    }
  }
  for(long i=0;i<c;i++) {
    for(long j=0;j<c;j++) {
      t_iwakan[i]+=d[j][i]*tw[j];
    }
  }

  for(long i=0;i<c;i++) {
    for(long j=0;j<c;j++) {
      for(long k=0;k<c;k++) {
        if((i!=j&&i!=k)&&j!=k) {
          ans=min(ans,z_iwakan[i]+o_iwakan[j]+t_iwakan[k]);
        }
      }
    }
  }
  cout << ans << endl;
}

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

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

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    vector<int> dist(N);
    for (int i = 0; i < N; i++) {
        if (i == N-1) {
            dist.at(i) = (K - A.at(i)) + A.at(0);
        }
        else {
            dist.at(i) = A.at(i+1) - A.at(i);
        }
    }

    int max = *max_element(dist.begin(), dist.end());
    
    cout << K - max << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> E;

llint n, m;
llint a[305][305], b[305][305];
set<llint> S[305];
bool used[305];

int main(void)
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++) b[i][a[i][j]] = j;
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			S[i].insert(j);
		}
	}
	
	llint ans = inf;
	for(int i = 1; i <= m; i++){
		
		llint max_val = -1, max_j;
		for(int j = 1; j <= m; j++){
			if(used[j]) continue;
			llint cnt = 0;
			for(int k = 1; k <= n; k++){
				if(b[k][j] == *S[k].begin()) cnt++;
			}
			if(cnt > max_val){
				max_val = cnt;
				max_j = j;
			}
		}
		ans = min(ans, max_val);
		
		used[max_j] = true;
		for(int k = 1; k <= n; k++) S[k].erase(b[k][max_j]);
	}
	cout << ans << endl;
	
	
	return 0;
}


Measured memory_bytes: 5888
#include<stdio.h>

#define N 100
#define INF 1000000
#define WHITE 0
#define BLACK 1

int n,G[N][N];
int pi[N],d[N];

void prim(){
  int color[n],min,u;
  int i,j,v;

  for(i=0;i<n;i++){
    color[i] = WHITE;
    d[i] = INF;
    pi[i] = 0;
  }
  d[0] = 0;
  pi[0] = -1;

  while(1){
    min = INF;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<min){
        min = d[i];
        u = i;
      }
    }

    if(min == INF) break;
    color[u] = BLACK;

    for(i=0;i<n;i++){
      if(color[i]!=BLACK && G[u][i]!=INF){
        if(d[u]+G[u][i] < d[i]){
          d[i] = d[u] + G[u][i];
          pi[i] = u;
        }
      }
    }
  }

}

int main(){
  int i,j;
  int u,v,k;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
       G[i][j]=INF;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);

    for(j=0;j<k;j++){
      scanf("%d",&v);
      scanf("%d",&G[u][v]);
    }
  }
  
  prim();

  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }

  return 0;
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g(100000);
map<pair<int,int>,int> W;
bool seen[100000];
int color[100000];
int N;

void dfs(int n, int c){
  //cout << n << endl;
  seen[n] = true;
  color[n] = c;
  int cc;
  if(c==0)cc=1;
  else cc=0;
  int w;
  for(auto to : g.at(n)){
    if(seen[to]){}
    else{
      if(n<to)w = W[make_pair(n,to)];
      else w = W[make_pair(to,n)];
   
      if(w%2==0)dfs(to,c);
      else dfs(to,cc);
    }
  }
  return ;
}
int main(){
  cin >> N;
  //memset(g, -1, sizeof(g));
  memset(seen, false, sizeof(seen));
  int u,v,w;
  for(int i=0; i<N; i++){
    cin >> u >> v >> w;
    g.at(u-1).push_back(v-1);
    g.at(v-1).push_back(u-1);
    W[make_pair(u-1,v-1)] = w;
  }
  dfs(0,0);
  for(int i=0; i<N; i++){
    cout << color[i] << endl;
  }
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
using ll = __int128;
const int MM = 2e5+2, MN = 1000;

int n, m, ans;
ll dp[MN];

struct st{
    ll x, y;
} a[MM];

vector<ll> no;

int main(){
    for(int i = 1; i < MN; i++)
        dp[i] = 1e9+1;
    scan(n, m);
    for(int i = 1; i <= n; i++){
        scan(a[i].x, a[i].y);
        if(!a[i].x)
            no.push_back(a[i].y);
    }
    sort(no.begin(), no.end());
    sort(a+1, a+1+n, [](st a, st b){
        return 1.0*(b.x)/(b.y+1) < 1.0*(a.x)/(a.y+1);
    });
    for(int i = 1; i <= n; i++){
        //print(a[i].x, a[i].y);
    }
    for(int i = 1; i <= n; i++){
        if(!a[i].x) continue;
        for(int j = MN-1; j; j--){
            dp[j] = min(dp[j], (dp[j-1]+1)*(a[i].x+1)
            + a[i].y);
        }
    }
    for(int i = 0; i < MN; i++){
        ll rem = m-dp[i];
        int cnt = i;
        for(int j: no){
            j++;
            if(j <= rem){
                rem -= j;
                cnt++;
            }
        }
        if(rem >= 0){
            ans = max(ans, cnt);
        }
    }
    
    print(ans);
    
    return 0;
}
/*
a.y*b.x + b.x + b.y < b.y*a.x + a.x + a.y
(a.y+1)*b.x + b.y < (b.y+1)*a.x + a.y
(a.y+1)*b.x - a.y < (b.y+1)*a.x - b.y
(a.y+1)*(b.x-1) < (b.y+1)*(a.x-1)
(b.x-1)/(b.y+1) < (a.x-1)/(a.y+1)    //no 0 division
 
 */

Measured memory_bytes: 12400
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

long long gcd(long long x, long long y){
    if(y == 0)return x;
    return gcd(y, x % y);
}

bool is_prime(ll x){
    for(ll i = 2; i * i <= x; i++){
        if(x % i == 0) return false;
    }
    return true;
}

int main(){
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    ll ans = 0;
    for(ll i = 1; i * i <= g; i++){
        if(g % i == 0){
            if(is_prime(i)) ans++;
            if(i * i != g && is_prime(g / i)) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define pb push_back
#define mod 1000000007

ll power(ll a,ll b){
    ll res=1ll;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res%mod;
}
ll ncr(ll n,ll k){
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro)%mod;
}

void swap(ll *a,ll *b) {
    ll temp=*a;
    *a=*b;
    *b=temp;
}
vector<ll> prime;
void seive(){
    vector<bool > isprime(1000001,true);
    for(int i=2;i*i<=1000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
vector<ll> parent;
ll find(ll p) {
    if(parent[p]==p) return parent[p];
    return parent[p]=find(parent[p]); 
}
void unun(ll a,ll b) {
    ll r1=find(a);
    ll r2=find(b);
    if(r1!=r2) parent[r2]=r1;
}
vector<ll> visited;
vector<vector<ll>> adj;
int cycle,nodes,last;
vector<ll> xr,cs;
void dfs(ll src) {
    visited[src]=1;
    nodes++;
    last=src;
    xr.pb(src);
    for(auto itr: adj[src]) {
        if(!visited[itr]) {
            dfs(itr);
        }
    }
}
void dfs1(ll src) {
    visited[src]=1;
    cycle++;
    cs.pb(src);
    for(auto itr:adj[src]) {
        if(!visited[itr]) {
            dfs1(itr);
        }
    }
}
void solve() {
    ll n,k;
    cycle=0;
    cin>>n>>k;
    nodes=0;
    visited = vector<ll>(n);
    adj = vector<vector<ll>>(n);
    vector<ll> arr(n);
    for(int i=0;i<n;i++) {
        cin>>arr[i];
        arr[i]--;
    }
    for(int i=0;i<n;i++) {
        adj[i].pb(arr[i]);
    }
    dfs(0);
    for(int i=0;i<n;i++) visited[i]=0;
    dfs1(adj[last][0]);
    if(k<nodes) {
        cout<<xr[k]+1;
        return ;
    }
    k-=(nodes-cycle);
    k%=cycle;
    
    // cout<<k<<endl;
    cout<<cs[k]+1;
}   


int main(void){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        cout<<endl;
    }
    return 0; 

}


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

#define int long long int
#define double long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define inf LLONG_MAX


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

	double d,t,s;
	cin>>d>>t>>s;
	d/s<=t?cout<<"Yes":cout<<"No";
	return 0;
}


Measured memory_bytes: 3740
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int dp[5009][5009], INF = 2017112600; vector<pair<int, int>>x; int n, h[100009], p[100009];
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> h[i] >> p[i];
		x.push_back(make_pair(h[i] + p[i], i));
	}
	sort(x.begin(), x.end());
	for (int i = 0; i < 5009; i++) { for (int j = 0; j < 5009; j++)dp[i][j] = INF; }
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (dp[i][j] == INF)continue;
			if (dp[i][j] <= h[x[i].second]) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + p[x[i].second]);
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
		}
	}
	int ret = 0;
	for (int i = 0; i <= n; i++) { if (dp[n][i] != INF)ret = i; }
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 98432
#include<iostream>
#include<math.h>
#include<iomanip>

using namespace std;

int main(){
	double x1,y1,x2,y2;
	
	cin >> x1 >> y1 >> x2 >> y2;
	
	cout << fixed << setprecision(8) << sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)) << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i)
        cout << "ACL";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3648
/*
    And I know I may end up failing too
*/




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

typedef long long ll;
typedef pair<ll,ll> pll;
#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7
#define pb           push_back
#define pf           push_front
#define pi           acos(-1)
#define all(x)       x.begin(),x.end()
#define fast         ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF          1e18
struct hash_pair
{
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1> {}(p.first);
        auto hash2 = hash<T2> {}(p.second);
        return hash1 ^ hash2;
    }
};




ll t;
ll m=N;
ll arr[100005];
ll cnt[100005];

ll dp(ll i)
{
  if(cnt[i]!=INF)return cnt[i];
  cnt[i]=min(cnt[i],dp(i-2)+abs(arr[i]-arr[i-2]));
  cnt[i]=min(cnt[i],dp(i-1)+abs(arr[i]-arr[i-1]));
  return cnt[i];
}

int main()
{
    ll a,b,c,d,e,f,g,i,j;
    ll n,k,x;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>arr[i];
        cnt[i]=INF;
    }
    cnt[1]=0;
    cnt[2]=abs(arr[2]-arr[1]);
    cout<<dp(n)<<endl;
    return 0;

}


Measured memory_bytes: 3328
#include <stdio.h>

#define N 100

int main(){
	int bubble[N];
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&bubble[i]);
	}
	int j,tmp,count=0;
	for(i=0;i<n-1;i++){
		for(j=n-1;j>i;j--){
			if(bubble[j] < bubble[j-1]){
				tmp=bubble[j];
				bubble[j] = bubble[j-1];
				bubble[j-1] = tmp;
				count++;
			}
		}
	}
	for(i=0;i<n-1;i++){
	printf("%d ",bubble[i]);
	}	
	printf("%d\n%d\n",bubble[i],count);
return 0;
}

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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#pragma GCC target ("avx2")
#pragma GCC optimization ("O2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

int n , m , k;
string str[7];
bool mark[7][7];

void colorRow(int row)
{
    for(int i = 0;i < m;i++)mark[row][i] = 1;
}
void colorCol(int col)
{
    for(int i = 0;i < n;i++)mark[i][col] = 1;
}
int32_t main()
{
    cin >> n >> m >> k;
    for(int i = 0;i < n;i++)cin >> str[i];
    int ans = 0;
    for(int mask1 = 0;mask1 < (1 << n);mask1++){
        for(int mask2 = 0;mask2 < (1 << m);mask2++){
            MEM(mark,0);
            for(int i = 0;i < n;i++){
                if(mask1 & (1 << i))colorRow(i);
            }
            for(int j = 0;j < m;j++){
                if(mask2 & (1 << j))colorCol(j);
            }
            int cnt = 0;
            for(int i = 0;i < n;i++){
                for(int j = 0;j < m;j++){
                    if(mark[i][j] == 0 and str[i][j] == '#')cnt++;
                }
            }
            if(cnt == k)ans++;
        }
    }
    cout << ans << "\n";
}



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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(ll i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

const double one = 1.0;
const double PI = 3.141592653589;

int main() 
{
	ll n,ans = 0;
	cin>>n;
	for(ll i = 1;i<n;i++)
	{
		ans+=(n-1)/i;
	}
	cout<<ans<<Endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main() {
    int n,k;
    cin>>n>>k;
    long long dp[n+100];
    int h[n+100];
    rep(i,n){
        cin>>h[i+1];
    }
    dp[1]=0;
    long long cost;
    for(int i=2;i<n+1;i++){
        cost=1000000000;
        for(int j=1;j<min(k+1,i);j++){
            cost=min(cost,dp[i-j]+abs(h[i-j]-h[i]));
        }
        dp[i]=cost;
    }
    cout<<dp[n]<<endl;

    return 0;
}

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

int main(){
  string s;
  cin >> s;  
  int c, k = 0;
  for ( int i = 0; i < s.size(); i++){
      if ( s.at(i) == 'A' || s.at(i) == 'T' || s.at(i) == 'G' || s.at(i) == 'C'){
      c++;
    }
    else {
      c = 0;
    } 
    if ( c > k ) k = c;
  }
  
  cout << k;
  
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef struct obj_{
    int key;
    struct obj_ *next;
}*obj;

//slobj型の変数のポインタをslist型と定義→いずれリストの先頭・最後尾要素を指す
typedef struct{
    obj head;
    obj tail;
}*queue;

//keyにxをもつキュー要素を作る関数
obj obj_new(int x){
    obj p;
    NEW(p,1);
    p->key=x;
    p->next=NULL;
    return p;
}

//slist型の空リスト1つを作る関数
queue queue_new(void){
    queue Q;
    NEW(Q,1);
    Q->head=NULL;
    Q->tail=NULL;
    return Q;
}

//enqueue(リスト最後尾に挿入)
void enqueue(queue Q,obj p){
    if(Q->head==NULL){
        Q->head=p;
        Q->tail=p;
    }
    else{
        Q->tail->next=p;
        Q->tail=p;
    }
    
    return;
}

obj dequeue(queue Q){
    obj p=Q->head;
    if(p==Q->tail){
        Q->tail=NULL;
        Q->head=NULL;
    }
    else{
        Q->head=p->next;
    }
    return p;
}

int main(void){
    int H,W;
    scanf("%d%d",&H,&W);

    int M[H][W];
    int white=0;
    for(int i=0;i<H;i++){
        char c[W+1];
        scanf("%s",c);
        for(int j=0;j<W;j++){
            if(c[j]=='.'){
                M[i][j]=0;
                white++;
            }
            else M[i][j]=-1; 
        }
    }

    queue Q=queue_new();
    enqueue(Q,obj_new(0));
    while(1){
        obj p=dequeue(Q);
        if(p==NULL) break;

        //これからM[x][y]の話をする(対応はx*W+y)
        int x=(p->key)/W;
        int y=(p->key)%W;
        if(x!=0 && M[x-1][y]==0){
            enqueue(Q,obj_new((x-1)*W+y));
            M[x-1][y]=M[x][y]+1;
        }
        if(x!=H-1 && M[x+1][y]==0){
            enqueue(Q,obj_new((x+1)*W+y));
            M[x+1][y]=M[x][y]+1;
        }
        if(y!=0 && M[x][y-1]==0){
            enqueue(Q,obj_new(x*W+y-1));
            M[x][y-1]=M[x][y]+1;
        }
        if(y!=W-1 && M[x][y+1]==0){
            enqueue(Q,obj_new(x*W+y+1));
            M[x][y+1]=M[x][y]+1;
        }
    }

    int ans;
    if(M[H-1][W-1]==0) ans=-1;
    else ans=white-(M[H-1][W-1]+1);
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 256
a,b,c=(int(i) for i in input().split())

ans=0

if b <= c:
  c=c-b
  ans=2*b
else:
  ans=b+c
  b=0
  c=0
  
if a <= c:
  c=c-a
  ans+=a
else:
  ans=ans+c
  c=0
  
if c > 0:
  ans=ans+1

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<stack>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)


int main(){
  string s;cin>>s;
  string ans="";
  int i=0;
  while(i!=s.size()){
    if(s[i]!='B'){
      ans.push_back(s[i]);
    }else{
      if(ans!=""){
        ans.pop_back();
      }
    }
    i++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
    int a[10],i;
    for(i=0;i<10;i++){
        cin>>a[i];
    }
    sort(a,a+i);
    cout<<a[9]<<endl;
    cout<<a[8]<<endl;
    cout<<a[7]<<endl;
    return 0;
}

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

int main(){
int n;
cin>>n;
if(n<10){
  cout<<n<<endl;
}
else if(10<=n&&n<100){
  cout<<9<<endl;
}
else if(100<=n&&n<1000){
  cout<<n-90<<endl;
}
else if(1000<=n&&n<10000){
  cout<<909<<endl;
}
else if(10000<=n&&n<100000){
  cout<<n-9090<<endl;
}
else if(n=100000){
  cout<<90909<<endl;
}
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n, ma, mb;
  cin >> n >> ma >> mb;
  
  vector<tuple<ll, ll, ll>> yaku(n);
  for (int i = 0; i < n; i++){
    ll a, b, c;
    cin >> a >> b >> c;
    yaku[i] = make_tuple(a, b, c);
  }

  vector<vector<vector<ll>>> dp(41, vector<vector<ll>>(401, vector<ll>(401, INF)));

  dp[0][0][0] = 0;
  for (int i = 1; i < n + 1; i++){
    for (int j = 0; j < 401; j++){
      for (int k = 0; k < 401; k++){
        if (j >= get<0>(yaku[i-1]) && k >= get<1>(yaku[i-1]))
          dp[i][j][k] = min(dp[i-1][j][k], dp[i-1][j-get<0>(yaku[i-1])][k-get<1>(yaku[i-1])] + get<2>(yaku[i-1]));
        else
          dp[i][j][k] = dp[i-1][j][k];
      }
    }
  }

  ll res = INF;
  ll cor = 1;
  while (cor*ma < 401 && cor*mb < 401){
    res = min(res, dp[n][cor*ma][cor*mb]);
    cor++;
  }

  if (res == INF){
    cout << -1 << endl;
  }
  else
    cout << res << endl;

  return 0;
}


Measured memory_bytes: 53504
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    double x;
    cin >> x;
    double yo = 100;
    ll ans = 0;
    while (yo < x)
    {
        yo *= 1.01;
        yo = ll(yo);
        ans++;
    }
    ce(ans);
}

Measured memory_bytes: 3712
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] y = new int[n];
        int ans=0;
        
        for(int i=0; i<n; i++){
            y[i] = sc.nextInt();
        }
        
        Arrays.sort(y);
        for(int i=0; i<k; i++){
            ans+=y[i];
        }
        
        System.out.println(ans);
   }
}


Measured memory_bytes: 38884
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll arr[200005];

int main()
{
	boost
	ll n,i,a;
	double sum=0;
	cin>>n;
	priority_queue<double,vector<double>,greater<double> > pq;
	for(i=0;i<n;i++)
	{
		cin>>a;
		pq.push(a);
	}
	for(i=1;i<n;i++)
	{
		double c=pq.top();
		pq.pop();
		double d=pq.top();
		pq.pop();
		//debug2(c,d);
		sum=(c+d)/2;
		pq.push((c+d)/2);
	}
	cout<<fixed<<setprecision(9);
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1e18
#define int long long
using namespace std;
const int N=1e5+100;
int n,x,ans,tot;
struct node
{
	int b,l,r,v;
}sh[N];
bool cmp(node a,node b){return a.v>b.v;}
signed main()
{
	scanf("%lld%lld",&n,&x);
	for (int i=1;i<=n;i++) scanf("%lld%lld%lld",&sh[i].b,&sh[i].l,&sh[i].r);
	for (int i=1;i<=n;i++) sh[i].v=(x-sh[i].b)*sh[i].r+sh[i].l*sh[i].b;
	for (int i=1;i<=n;i++) tot+=sh[i].l*sh[i].b;
	sort(sh+1,sh+1+n,cmp);
	int wh=0;ans=inf;
	for (int i=1;i<=n;i++)
	{
		if (sh[i].v>=tot)
		{
			ans=i*x;
			wh=i-1;
			break;
		}
		tot-=sh[i].v;
	}
	if (wh==n)
	{
		printf("%lld\n",sh[1].b*n);
		return 0;
	}
	if (tot==0) ans=min(ans,wh*x);
	for (int i=1;i<=n;i++)
	{
		int tmp=tot;
		if (i<=wh) tmp+=sh[i].v-sh[wh+1].v;
		if (tmp<=sh[i].b*sh[i].l)
		{
			int add=0;
			if (tmp%sh[i].l!=0) add=1;
			ans=min(ans,wh*x+tmp/sh[i].l+add); 
		}
		else
		{
			tmp-=sh[i].b*sh[i].l;
			int add=0;
			if (tmp%sh[i].r!=0) add=1;
			ans=min(ans,wh*x+tmp/sh[i].r+add+sh[i].b);
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 6856
<?php
$n = intval(fgets(STDIN));
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));

$plus = [];
$minus = [];
foreach($A as $a){
  if($a >= 0){
    $plus[] = $a;
  }else{
    $minus[] = $a;
  }
}
if($plus && $minus){//両方ある場合
  $sum = 0; 
  foreach($A as $a){
    $sum+=abs($a);
  }
  echo $sum,"\n";
  //マイナスのいずれかでプラスが残り1個になるまでプラスを吸収
  $m = array_shift($minus);
  $c = count($plus);
  while($c > 1){
    $c--;
    $p = array_pop($plus);
    echo "$m $p\n";
    $m-=$p;
  }
  $p = array_shift($plus);
  $c = count($minus);
  while($c>0){
    $c--;
    $m_ = array_pop($minus);
    echo "$p $m_\n";
    $p-=$m_;
  }
  echo $p, " ", $m;
  exit;
}
if(!$plus){//全てマイナス
  $plus = $minus;
  rsort($plus);
  for($i = 1; $i < $n - 1; $i++){
    $line[] = $plus[0]." ".$plus[$i];
    $plus[0]-=$plus[$i];
  }
  $line[] = $plus[0].' '.$plus[$n-1];
  echo ($plus[0]-$plus[$n-1])."\n";
  echo implode("\n", $line);
  exit;
}

if(!$minus){
  sort($plus);
  for($i = 1; $i < $n - 1; $i++){
    $line[] = $plus[0]." ".$plus[$i];
    $plus[0]-=$plus[$i];
  }
  $line[] = $plus[$n-1]." ".$plus[0];
  echo ($plus[$n-1]-$plus[0])."\n";
  echo implode("\n", $line);
  exit;
}




Measured memory_bytes: 31212
import sys
input = sys.stdin.readline

import heapq

Q = int(input())

ans = 0

INF = 10 ** 18

L_pque = []
R_pque = []

heapq.heappush(L_pque, +INF)
heapq.heappush(R_pque, +INF)

for _ in range(Q):
    tmp = tuple(map(str, input().split()))
    if len(tmp) == 1:
        print (-L_pque[0], ans)
    else:
        a = int(tmp[1])
        b = int(tmp[2])

        ans += b

        tmpA = -L_pque[0]
        tmpB = +R_pque[0]
        # print ('区間', tmpA, tmpB)

        if a < tmpA:
            ans += abs(tmpA - a)
        elif tmpB < a:
            ans += abs(a - tmpB)
        
        heapq.heappush(L_pque, -a)
        heapq.heappush(R_pque, +a)

        tmpA = -heapq.heappop(L_pque)
        tmpB = +heapq.heappop(R_pque)

        if tmpA <= tmpB:
            heapq.heappush(L_pque, -tmpA)
            heapq.heappush(R_pque, +tmpB)
        else:
            tmpA, tmpB = tmpB, tmpA
            heapq.heappush(L_pque, -tmpA)
            heapq.heappush(R_pque, +tmpB)
        






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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()

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

const int N = (int)1e5 + 2;
const int LG = 20;
const ll mod = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const ll linf = 1e13;
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

int n, k;
ll a[N], dp[N];
int main ()
{
    scanf ("%d %d", &n, &k);
    for (int i = 1; i <= n; ++i) scanf ("%lld", a + i);
    for (int i = 1; i <= n; ++i) dp[i] = linf;
    dp[1] = 0;
    for (int i = 2; i <= n; ++i)
    {
        for (int j = max(i - k, 1); j <= i - 1; ++j)
        {
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
        }
    }
    printf ("%lld\n", dp[n]);
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  char c;
  for(int i=0;i<26;i++){
    c='a'+i;
    for(int j=0;j<s.length()-2;j++){
      if(s[j]==c){
        if(s[j+1]==c){
          cout << j+1 << " " << j+2 << endl;
          return 0;
        }else if(s[j+2]==c){
          cout << j+1 << " " << j+3 << endl;
          return 0;
        }
      }
    }
  }
  if(s[s.length()-2]==s[s.length()-1]){
      cout << s.length()-1 << " " << s.length() << endl;
      return 0;
  }

  cout << -1 << " " << -1 << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  R s;
  ll ans=0;
  rep(i,s.size()) {
    if(s[i]=='1') ans++;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=2e5+10;
const int mod=1e9+7;
main(){
    int a,b,c,k;
    cin>>a>>b>>c;
    cin>>k;
    int f=1;
    int cnt=0;
    while(b<=a){
        b*=2;
        cnt++;
    }
    while(c<=b){
        c*=2;
        cnt++;
    }
    if(cnt>k)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll int 
#define pi 3.1415926536
using namespace std;
const ll N=55;

void solve()
{ll n,k,m,h,x,y,z,w,mini,maxi=INT_MAX,prev,res;
 cin>>n>>k;
 vector<ll> v(n+1,0);
 for(ll i=0;i<k;i++)
 {
 	cin>>x;
 	for(ll j=0;j<x;j++)
 	{
 		cin>>y;
 		v[y]=1;
	 }
 }
 z=0;
 for(ll i=1;i<=n;i++)
 if(!v[i])
 z++;
 cout<<z;
}
  
int main()
{
  fast
  //for(ll i=0;i<=9;i++)
  //cal(1,3234566667,i);
  //sort(v.begin(),v.end());
  //pre();
ll t=1;
//cin>>t;
//SieveOfEratosthenes();
//cout<<"ok";
while(t--)
{ //cout<<"ok";

solve();
 //cout<<ma<<endl;
}
return 0;}
/*
ll pr(ll a,ll b,ll c)
{
	if(b==0)
	return 1LL;
	ll ans=1;
	while(b>0)
	{
		if(b%2)
		ans=((ans%c)*(a%c))%c;
		a=((a%c)*(a%c))%c;
		b/=2;
		a%=c;
		ans%=c;
	}
	return ans;
}
vector<ll> fact(N+1);
void pre()
{
	fact[0]=1;
	for(ll i=1;i<=N;i++)
	fact[i]=fact[i-1]*i,fact[i]%=hell;
	
}
*/

Measured memory_bytes: 3652
import bisect

n = int(input())
l = sorted(list(map(int, input().split())))
cnt = 0
for i in range(n-1, 1, -1):
    for j in range(i - 1, 0, -1):
        c = l[i] - l[j]
        index = bisect.bisect_right(l, c, 0, j)
        cnt += j - index
print(cnt)

Measured memory_bytes: 3188