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

using namespace std;

typedef long long ll;

const int N = 2e5 + 5;

int n;
ll p[N], s[N];
vector <ll> m, c;
int sz = 0;
ll dp[N];
ll a[N];
ll C;

bool bad(int f1, int f2, int f3) {
  return (c[f1] - c[f2]) * (m[f3] - m[f1]) >= (c[f1] - c[f3]) * (m[f2] - m[f1]);
}

void add(ll m0, ll c0) {
  sz++;
  m.push_back(m0);
  c.push_back(c0);
  while(sz >= 3 and bad(sz - 3, sz - 2, sz - 1)) {
    sz--;
    m.erase(m.end() - 2);
    c.erase(c.end() - 2);
  }
}

ll query(ll x) {
  ll last = m[sz - 1] * x + c[sz - 1];
  ll l = 0, r = sz - 2;
  while(l < r) {
    ll mid = (l + r) / 2LL;
    ll cur = m[mid] * x + c[mid];
    ll after = m[mid + 1] * x + c[mid + 1];
    if(cur > after) l = mid + 1;
    else r = mid;
  }
  return min(last, m[l] * x + c[l]);
}

int main() {
  scanf("%d %lld", &n, &C);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  dp[0] = 0;
  add(-2 * a[0], a[0] * a[0]);
  ll ans = 0;
  for(int i = 1; i < n; i++) {
    dp[i] = a[i] * a[i] + C + query(a[i]);
    add(-2 * a[i], a[i] * a[i] + dp[i]);
  }
  cout << dp[n - 1] << '\n';
}

Measured memory_bytes: 7660
#include <iostream>
#include <vector>
#include <string>
using namespace std;

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

Measured memory_bytes: 1408
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>

//using namespace __gnu_pbds;
using namespace std;

#define sz(x)                 x.size()
#define all(x)                x.begin(), x.end()
#define tr(x, it)             for(auto it = x.begin();it != x.end();it++)
#define fo(i, k, n)           for(int i = k;i < n;i++)
#define Fo(i, k, n)           for(int i = k;i >= n;i--)
#define el                    "\n"
#define ff                    first
#define ss                    second
#define ll                    long long
#define pb                    push_back
#define mp                    make_pair
#define pii                   pair<int, int>
#define vi                    vector<int>
#define mii                   map<int, int>
//#define pqb                   priority_queue<int>
//#define pqs                   priority_queue<int, vi, greater<int>>
//#define pc(x)                 putchar(x);
//#define setbits(x)            __builtin_popcountll(x)
//#define zrobits(x)            __builtin_ctzll(x)
#define mod                   1000000007
#define inf                   1e18
#define deb(x)                cout<<#x<< " = "<< x<<"\n";
//#define ps(x, y)              fixed<<setprecision(y)<<x
//#define mk(arr, n, type)      type *arr = new type[n];
//#define w(x)                  int x; cin>>x; while(x--)

void solve(){
	int n, x, ans = 0;
	cin>>n;
	fo(i, 1, n+1){
		cin>>x;
		if(i%2 == 1 && x%2 == 1){
			ans++;
		}
	}
	cout<<ans;
}

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


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int h,w;
	cin >> h >> w;
	int c[10][10];
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++)	cin >> c[i][j];
	}
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			for(int k=0;k<=9;k++){
				if(c[i][k] + c[j][i] < c[j][k]){
					c[j][k] = c[i][k] + c[j][i];
				}
			}
		}
	}
	ll sum = 0;
	int x;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> x;
			if(x!= -1) sum+=c[x][1];
		}
	}
	cout << sum <<'\n';
	return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))

l=[]
for i in range(n):
  s=0
  for j in range(i,n):
    s+=a[j]
    l.append(s)
t=0
for i in range(40,-1,-1):
  t+=2**i
  c=0
  for j in l:
    if t==j&t:
      c+=1
  if c<k:
    t-=2**i
print(t)

Measured memory_bytes: 104896
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long 
#define F first
#define end 1000000000
#define S second
#define pb push_back
#define mp make_pair
using namespace std;

int main()
{
  ll a,b,k;
  cin >> a >> b >> k;ll kak=0;ll aok=0;
  if(k<a)
  {
    kak=a-k;
    aok=b;
  }
  else
  {
      kak=0;
      aok=b-(k-a);
      if(aok<0)
      aok=0;
      
  }
  cout << kak << " " << aok << endl;
 
  
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int escolhem[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
int main(){
	int read, mini, maxi, n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> read;
		int atu = read/400;
		if(atu > 8) atu = 8;
		escolhem[atu]++;
	}
	mini = 0;
	for(int i = 0; i < 8; ++i){
		if(escolhem[i]) mini++;
	}
	maxi = mini + escolhem[8];
	if(mini == 0 && escolhem[8] > 0) mini = 1;
	cout << mini << ' ' << maxi << endl;
}

Measured memory_bytes: 256
N = int(input())
W = [0] * N
for i in range(N):
    W[i] = input()
if len(set(W)) != N:
    print('No')
    exit()
for i in range(N - 1):
    w1 = W[i]
    w2 = W[i+1]
    if w1[-1] != w2[0]:
        print('No')
        exit()
print('Yes')

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

int main() {
  string S,T;
  cin>>S>>T;
  int cnt=0;
  REP(i,0,S.length()){
    if(S[i]!=T[i])cnt++;

  }
  cout<<cnt<<endl;

  return 0;
}


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

int main(){
  ll n,y;
  cin >> n >> y;
  y /= 1000;
  if( 10*n < y ){
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
  }
  rep(i,n){
    rep(j,n){
      if( i+j > n ) break;
      rep(k,n){
        if( i+j+k > n ) break;
        if( 10*i + 5*j + k == y && i+j+k == n ){
          cout << i << " " << j << " " << k << endl;
          return 0;
        }
      }
    }
  }
  
  cout << -1 << " " << -1 << " " << -1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;

int main(void){
    ll n;
    cin>>n;
    if(n%1000==0) cout<<0<<endl;
    else cout<<1000-n%1000<<endl;
}

Measured memory_bytes: 3620
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        l: [i64; n],
    }
    let mut res = 0;
    for c in l.iter().combinations(3) {
        let mut c = c.clone();
        c.sort();

        if c[0] != c[1] && c[1] != c[2] && c[0] + c[1] > *c[2] {
            res += 1;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 2168
n = int(input())
ans = {}
for i in range(n):
    s = input()
    t = []
    for i in range(len(s)):
        t.append(s[i])
    t.sort()
    k = "".join(t)
    if k in ans:
        ans[k] = ans[k]+1
    else:
        ans[k] = 0
answer = 0
for i in ans:
    j = ans[i]
    answer += j*(j+1)//2
print(answer)

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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int solve() {
    int n, m, k;
    vector<string> W;
    cin >> n >> m >> k;
    W.resize(n);
    for (int i = 0; i < n; i++)
        cin >> W[i];
    // cout << "W: " << W << endl;
    int ans = 0;
    for (int i = 0; i < (1<<n); i++) {
        for (int j = 0; j < (1<<m); j++) {
            // cout << "i: " << i << ", j: " << j << endl;
            int cnt = 0;
            for (int x = 0; x < n; x++) {
                for (int y = 0; y < m; y++) {
                    // cout << "x: " << x << ", y: " << y << endl;
                    if ((i & (1<<x)) && (j & (1<<y)) && W[x][y] == '#') {
                        cnt++;
                    }
                }
            }
            // cout << "cnt: " << cnt << endl;
            if (cnt == k)
                ans++;
        }
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i) 
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
#define dis distance
#define so sort
#define rev reverse
#define pub push_back
#define sec second
#define fir first


typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int EPS = 1e-9;
const int MOD = 1e9+7;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> V;
  REP(i,n){
    int a;
    cin >> a;
    V.pub(a);
  }
  so(ALL(V));
  rev(ALL(V));
  ll ans = 0;
  int pre = 0;
  REP(i,n){
    if(pre == V[i]){
      if(ans == 0){
	ans = V[i];
      }else{
	ans *= V[i];
	cout << ans << endl;
	return 0;
      }
      pre = 0;
    }else{
      pre = V[i];
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 892
import copy
n = int(input())
a = input().split()
a_bubble = a
a_selection = copy.deepcopy(a)
flag = 1
k = 0
while flag == 1:
    flag = 0
    for i in range(n-1,k,-1):
        if int(a_bubble[i-1][1]) > int(a_bubble[i][1]):
            a_bubble[i],a_bubble[i-1] = a_bubble[i-1],a_bubble[i]
            flag = 1
    k += 1
print(" ".join(a_bubble))
print("Stable")
for i in range(n):
    minj = i
    for j in range(i,n):
        if int(a_selection[j][1]) < int(a_selection[minj][1]):
            minj = j
    a_selection[i],a_selection[minj] = a_selection[minj],a_selection[i]
print(" ".join(a_selection))
if a_selection == a_bubble:
    print("Stable")
else:
    print("Not stable")


Measured memory_bytes: 6344
prediction = gets() #prediction=”CSS”
true_weather = gets() #true_weather=”CSR”

answer = 0
(0...3).each do |i| #2
    if(prediction[i]==true_weather[i]) #prediction[i]=’S’ ,true_weather[i]=’R’ , false
        answer = answer + 1 #answer = 2
    end
end

puts answer #2


Measured memory_bytes: 1788
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
if n < 3:
    print(0)
else:
    for i in range(n-2):
        for j in range(i+1,n-1):
            for k in range(j+1,n):
              if a[i] + a[j] > a[k] and len(set([a[i],a[j],a[k]])) == 3:
                    ans += 1
    print(ans)

Measured memory_bytes: 9096
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	int l,r,lma=-1,rmi=1000000;
	for(int i=0;i<m;i++){
		cin>>l>>r;
		lma=max(l,lma);
		rmi=min(r,rmi);
	}
	cout<<max(rmi-lma+1,0)<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, A[11234];
map<ll, ll> p[11234];
ll mod = 1000000007;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int main() {

	cin >> N;
	rep(i, N) cin >> A[i];
	rep(i, N) {
		ll a = A[i];
		for (ll ppp = 2; ppp * ppp <= a; ++ppp) {
			if (a % ppp == 0) {
				p[i][ppp]++;
				a /= ppp;
				ppp = 1;
			}
		}
		p[i][a]++;
	}
	map<ll, ll> lcm;
	rep(i, N) {
		for (auto pp : p[i]) {
			lcm[pp.first] = max(lcm[pp.first], pp.second);
		}
	}
	ll lcm_mod = 1;
	for (auto l : lcm) {
		rep(i, l.second) {
			lcm_mod *= l.first;
			lcm_mod %= mod;
		}
	}

	ll ans = 0;
	rep(i, N) {
		ans += lcm_mod * modinv(A[i], mod);
		ans %= mod;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3968
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


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

	int H, W;
	cin >> H >> W;
	int num = 0;
	rep(i, H) {
		string s;
		cin >> s;
		rep(j, W) {
			if (s[j] == '#')num++;
		}
	}
	if (num == H + W - 1)cout << "Possible" << endl;
	else cout << "Impossible" << endl;

	return 0;
}

Measured memory_bytes: 256
# coding:utf-8

n = int(input())

p = list(map(int, input().split()))

cnt = n - 2

for i in range(1,len(p)-1):
    if (p[i] > p[i-1] and p[i] > p[i+1]) or (p[i] < p[i-1] and p[i] < p[i+1]):
        cnt -= 1

print(cnt)




Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int a[200010],n;
	cin >> n;
	for (int i = 0; i < n;i++) {
		cin >> a[i];
	}
	sort(a,a+n);
	for (int i = 0; i < n - 1;i++) {
		if (a[i]==a[i+1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<double, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int  r, d;
	ll x;
	cin >> r >> d >> x;
	int q = 10;
	while (q--) {
		x = r * x - d;
		cout << x << endl;
	}

}

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

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

    char map[102][10002];
    int array[10002];

    int temp = 0;
    for(int i = 0; i < m; i++){
        for(int j = 0; j < n; j++){
            char input; cin >> input;
            map[i][j] = input;
            if(input == 'W') temp++;
        }
    }
    array[0] = temp;
    int min = temp;
    int min_j = 0;
    for(int j = 0; j < n; j++){
        for(int i = 0; i < m; i++){
            if(map[i][j] == 'W') temp--;
            else temp++;
        }
        array[j+1] = temp;
        if(min > temp){
            min = temp;
            min_j = j + 1;
        }
    }

    cout << min_j << " " << min_j + 1 << endl;
    return 0;
}

Measured memory_bytes: 4072
// Template begins
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue> 
#include <string.h>
#include <string>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<b;i++)
#define all(v) (v).begin(),(v).end()
#define sort0(v) sort(all(v))
#define lbb(a,b,arr,x) lower_bound(arr+a,arr+b+1,x)-arr
#define ubb(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-arr
#define freq(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-lower_bound(arr+a,arr+b+1,x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define printp(x) cout << x.ff << " " << x.ss << endl
 
const ll mod=998244353;
#define inf 9999999999999
#define MAXN   100001 
  
// stores smallest prime factor for every number 
ll inv(ll i){if(i==1) return 1;return (mod-((mod/i)*inv(mod%i))%mod)%mod;}
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b,b%a);}
inline void fastio(){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
// Template ends
const int MN = 2e5+7;
 

 

int main() 
{ 
    ll n; cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    ll ans=0;
    for(int i=1;i<n;i++){
        if(arr[i]-arr[i-1]<0){
            ans+=abs(arr[i]-arr[i-1]);
            arr[i]=arr[i-1];
        }
    }
    cout<<ans<<endl;
    return 0; 
}

Measured memory_bytes: 4760
def main():
    N = int(input())
    V = [int(v) for v in input().split()]
    C = [int(v) for v in input().split()]

    def search(i, select, value, cost):
        if i == N:
            return value - cost
        ans1 = search(i + 1, select, value, cost)
        ans2 = search(i + 1, select | (1 << i), value + V[i], cost + C[i])
        return max(ans1, ans2)

    ans = search(0, 0, 0, 0)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VII;
typedef pair<int,int> PII;


int main(){
  int A,B;
  cin>>A>>B;
  rep(i,2*A-1){
    if(i) cout<<" ";
    cout<<B-A+1+i;
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll a, b;
    cin >> a >> b;
    if(a == b)
        cout << "1\n";
    else if((a + b) % 2 == 0)
        cout << (a + b) / 2 << endl;
    else
        cout << "IMPOSSIBLE\n";
    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++)

int main(){
  int w, h, m, s;
  cin >> w;
  h = w / 3600;
  m = (w % 3600) / 60;
  s = (w % 3600) % 60;

  cout << h << ":" << m << ":" << s << endl;
  
}



Measured memory_bytes: 3092
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    double r;
    cin >> r;

    double ans = 2.0 * r * PI;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define rep(i, n) for (long long int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
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;
}
const long long INF = 1LL << 60;
int cnt = 0;
int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 3636
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
d = 0
for i in range(n):
    a = list(map(int, input().split()))
    e = []
    for j in range(m):
        e.append(a[j] * b[j])
    e.append(c)
    if sum(e) > 0:
        d += 1
print(d)

Measured memory_bytes: 9192
import sys

s = input()
s = s[::-1]

if len(s) == 0:
    print('YES')
    sys.exit()

words = ['maerd', 'remaerd', 'esare', 'resare']
can = True

while can:
    can = False
    for word in words:
        if s.startswith(word):
            s = s[len(word):]
            can = True

if len(s) == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
int main(){
  int N,K;
  string S;
  cin>>N>>S>>K;
  char k = S[K-1];
  for (int i(0);i<N;i++){
    if (S[i] == k) continue;
    S[i] = '*';
  }
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
int main(){
  ll n,d;
  cin>>n>>d;
  vector<ll>x(n);
  vector<ll>y(n);
  d=d*d;
  for(int i=0;i<n;i++)cin>>x[i]>>y[i];
  int ans=0;
  for(int i=0;i<n;i++){
    if(x[i]*x[i]+y[i]*y[i]<=d)ans++;}
  cout<<ans<<endl;
    
    
  return 0;
}


Measured memory_bytes: 6420
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mod 1000000007

int modInverse(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 
int main()
{
	//#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    //freopen("input.txt", "r", stdin);
    // for writing output to output.txt
   // freopen("output.txt", "w", stdout);
   // freopen("error.txt","w",stderr);
    // #endif
    
	string s;
	cin>>s;
	int q;
	cin>>q;
	int x=0;
	string s1,s2;
	while(q--)
	{
		int t,f;
		string c;
		cin>>t;
		if(t==1)
		{
			x=(x+1)%2;
		}
		if(t==2)
		{
			cin>>f;
			cin>>c;
			if(f==1)
			{
				if(x==0)
				{
					s1=s1+c;
				}
				else
					s2=s2+c;
			}
			if(f==2)
			{
				if(x==0)
					s2=s2+c;
				else
					s1=s1+c;
			}
		}

	}
	if(x==0)
	{
		reverse(s1.begin(), s1.end()); 
		cout<<s1<<s<<s2<<endl;
	}	
	if(x==1)
	{
		reverse(s2.begin(),s2.end());
		reverse(s.begin(),s.end());
		cout<<s2<<s<<s1<<endl;
	}
}

Measured memory_bytes: 1456
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

vector<int> Z_algorithm(string S){
    int c=0,n=S.size();
    vector<int> Z(n,0);
    for(int i=1; i<n; i++){
        int l = i-c;
        if(i+Z[l] < c+Z[c]){
            Z[i] = Z[l];
        }else{
            int j = max(0, c+Z[c]-i);
            while(i+j<n && S[j]==S[i+j]) j++;
            Z[i] = j;
            c = i;
        }
    }
    Z[0] = n;
    return Z;
}



int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    vector<int> Z = Z_algorithm(S);
    int N = S.size();
    // ABを入れる
    string ans = "-";
    for(int i=N-1; i>=1; i--){
        // 後ろがAになるか判定
        if(Z[i] == N-i){
            // Bの文字列の長さ
            // これB*2の長さ
            int B = (i-1)-Z[i]+1-Z[i];
            if(B <= 0) continue;
            if(B%2 == 0){
                // Bの長さ
                B /= 2;
                if(Z[Z[i]+B] >= Z[i]+B){
                    // 条件満たす
                    // cout << i << " " << Z[i]+B << "\n";
                    if(ans == "-"){
                        ans = S.substr(0,Z[i]+B);
                    }else{
                        if(ans.size() > Z[i]+B){
                            ans = S.substr(0,Z[i]+B);
                        }
                    }
                }
            }
        }
    }
    if(ans == "-"){
        cout << "mitomerarenaiWA" << "\n";
    }else{
        cout << "Love " << ans << "!" << "\n";
    }
    return 0;
}


Measured memory_bytes: 8940
n = int(input())
l = list(map(int,input().split()))
d = {}
for i in l:
    if d.get(i):
        d[i] +=1
    else:
        d[i] = 1
for i in range(1,n+1):
    if d.get(i):
        print(d[i])
    else:
        print(0)

Measured memory_bytes: 112136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  bool flag = true;
  for(int k=0;k<s.size();k++){
      if(s[s.size()-1-k]!=s[k]) flag = false;
  }
  for(int k=0;k<s.size()/2;k++){
      if(s[k]!=s[s.size()/2-1-k]) flag = false;
  }
  for(int k=s.size()/2+2;k<s.size();k++){
      if(s[k]!=s[s.size()-1-k]) flag = false;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N; cin >> N;
  vector<char> P(N); for(auto& p : P) cin >> p;
  vector<char> Q(N); for(auto& q : Q) cin >> q;

  vector<char> vc{};
  for (int i = 1; i <= N; ++i) {
    vc.push_back('0' + i);
  }

  int a{}, b{};
  int i = 1;
  do {
    if (vc == P) {
      a = i;
    }
    if (vc == Q) {
      b = i;
    }
    ++i;
  } while (std::next_permutation(vc.begin(), vc.end()));
  auto ans = std::abs(a - b);

  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
first = set()
second = set()
for _ in range(M):
  a, b = map(int, input().split())
  if a == 1:
    first.add(b)
  elif b == N:
    second.add(a)

ans = 0
for i in first:
  if i in second:
    ans = 1
    break
if ans:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 19024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
int main(){
	int n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	ll suf[n];
	suf[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--){
		suf[i]=(suf[i+1]+a[i])%mod;
	}
	ll ans=0;
	for(int i=0;i+1<n;i++){
		ans=(ans+a[i]*suf[i+1])%mod;
	}
	cout<<ans;
}


Measured memory_bytes: 6804
#include <stdio.h>

int power_2(int n){
    int i = 1;
    i <<= n;
    return i;
}

int main(void){
    int n,n2,m,k;
    int s[10][10];
    int p[10],onpat[10] = {};
    int i,j,on,bp;
    int count = 0;
    
    scanf("%d %d", &n, &m);
    n2 = power_2(n);
    for(i = 0; i < m; i++){
        scanf("%d", &k);
        for(j = 0; j < k; j++){
            scanf("%d", &s[i][j]);
            onpat[i] += (1 << (s[i][j] - 1));
        }
    }

    for(i = 0; i < m; i++){
        scanf("%d", &p[i]);
    }
    
    for(i = 0; i < n2; i++){
        k = 0;
        for(j = 0; j < m; j++){
            bp = onpat[j] & i;
            on = 0;
            while(bp){
                on += (bp % 2);
                bp >>= 1;
            }
            if(on % 2 == p[j]){
                k++;
            }else{
                break;
            }
        }
        if(k == m){
            count++;
        }
    }

    printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <functional>

using namespace std;

int par[10016], rank[10016];

void init(int x)
{
	int i;
	for (i = 0; i < x; i++)
	{
		par[i] = i;
		rank[i] = 0;
	}
}

int find(int x)
{
	if (par[x] == x)
		return x;
	return par[x] = find(par[x]);
}

void unit(int x, int y)
{
	x = find(x);
	y = find(y);
	if (x == y)
		return;
	if (rank[x] < rank[y])
		par[x] = y;
	else
	{
		par[y] = x;
		if (rank[x] == rank[y])
			rank[x]++;
	}
}

int same(int x, int y)
{
	return find(x) == find(y);
}

typedef struct
{
	int u, v;
	double d;
}EDG;
typedef struct
{
	int x, y;
}P;

P p[10016];
EDG e, G[200320];
int n, m;
double res = 0;

inline int doub(int x)
{
	return x * x;
}

int mycmp(EDG e1, EDG e2)
{
	return e1.d > e2.d;
}

void krus()
{
	int i;
	sort(G, G + m, mycmp);
	init(n);
	for (i = 0; i < m; i++)
	{
		e = G[i];
		if (!same(e.u, e.v))
		{
			unit(e.u, e.v);
			res += e.d;
		}
	}
}

int main()
{
	int i, j, x, y;
	double sum = 0;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++)
		scanf("%d%d", &p[i].x, &p[i].y);
	for (i = 0; i < m; i++)
	{
		scanf("%d%d", &x, &y);
		e.d = sqrt(1.0 * doub(p[x].x - p[y].x) + doub(p[x].y - p[y].y));
		sum += e.d;
		e.u = x; e.v = y;
		G[i] = e;
	}
	krus();
	printf("%.3lf\n", sum - res);
	return 0;
}

Measured memory_bytes: 1836
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007
    #define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
    #define GCD(m,n) __gcd(m,n)
    #define LCM(m,n) m*(n/GCD(m,n))
    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    #define REVERSE(v) reverse(ALL(v))
    #define display(x) trav(a,x) cout<<a<<" ";cout<<endl
    #define debug cerr<<"bhau"<<endl
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        std::cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}
    void amax(int &a,int b){a=max(a,b)%M; }
    void amin(int &a,int b){ a=min(a,b)%M;}
    void inc(int &a,int b){a=(a+b)%M;}
    void dec(int &a,int b){a=(a-b+M)%M;}


    
     int solve()
     {  
        int n;cin>>n;
        vector<pii> v;
        rep0(n){
          int t;cin>>t;
          v.pb({t,i+1});
        }
        sort(all(v));
        rep0(n) cout<<v[i].ss<<" ";

        r0   
     }
    signed main()
    {   
        asdf
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 2544
#include<stdio.h>
int main(){
  int x,y,ans1;
  scanf("%d%d",&x,&y);
  if(x<=0||y<=0||x>1000000001||y>1000000001){
    return 0;
  }
  int a,b;
  a=x;
  b=y;
  if(y>x){
    a=y;
    b=x;
  }
  else if(a==b){
    printf("%d\n",a);
    return 0;
  }
  while(1){
    ans1=a%b;
    if(ans1==0)break;
    else{
      a=b;
      b=ans1;
    }}
  printf("%d\n",b);
  return 0;
}



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

int main()
{
    vector<vector<vector<int> > >a(4,vector<vector<int> >(3,vector<int>(10,0)));
    int n;
    cin>>n;
    REP(i,n)
    {
        int b,f,r,v;
        cin>>b>>f>>r>>v;
        a.at(b-1).at(f-1).at(r-1)+=v;
    }
    REP(i,4)
    {
        REP(j,3)
        {
            REP(k,10)
            {
                cout<<" "<<a.at(i).at(j).at(k);
            }
            cout<<endl;
        }
        if(i==3)break;
        cout<<"####################"<<endl;
    }
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N,M;
	float sum=0;
	cin>>N>>M;
	int A[N];
	for(int y=0;y<N;y++){
		cin>>A[y];
		sum+=A[y];
	}
	sum/=4*M;
	int i=0;
	for(int y=0;y<N;y++){
		if(A[y]>=sum)
		++i;
		if(i==M){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cfenv>
#include <cmath>

using namespace std;

int main() {

  long long x;
  cin>>x;
  double ans = 100;
  double tmp;
  int an = 0;
  while(ans<x){
    ans*=1.01;
    ans = floor(ans);
      an++;
  }

    cout<<an<<endl;

  return 0;
}

Measured memory_bytes: 3596
N = int(input())
a = map(int, raw_input().split())
x = a[0]
y = sum(a) - a[0]
min = abs(x - y)
for i in range (1,N-1):
    y -= a[i]
    x += a[i]
    dummy = abs(x - y)
    if min > dummy:
        min = dummy
print min


Measured memory_bytes: 18440
N = int(input())

def make_divisors(n):
    import math
    divisors = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0: #割り切れるとき
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

ans = 0
lst = make_divisors(N)
for X in lst:
    m = N // X - 1
    if m > X:
        ans += N // X - 1

print (ans)
# print (lst)

Measured memory_bytes: 3272
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

signed main() {
 
	crap;

	int n;
	cin >> n;
	double heads[n], tails[n];
	for (int i = 0; i < n; ++i) {
		cin >> heads[i];
		tails[i] = 1 - heads[i];
	}

	double dp[n + 1][n + 1];

	for (int i = 0; i < n + 1; ++i) {
		for (int j = 0; j < n + 1; ++j) {
			if (i == 0 and j == 0)
				dp[i][j] = 1.0;
			else if (i == 0)
				dp[i][j] = 0.0;
			else if (j == 0)
				dp[i][j] = dp[i - 1][j] * tails[i - 1];
			else {
				dp[i][j] = dp[i - 1][j] * tails[i - 1] + dp[i - 1][j - 1] * heads[i - 1];
			}
		}
	}

	double ans = 0.0;
	int coins = n;

	for (int j = 0; j < n + 1; ++j) {
		int heads = j;
		int tails = coins - heads;

		if (heads > tails and tails >= 0 and heads >= 0)
			ans += dp[n][j];
	}

	cout << fixed << showpoint << setprecision(12) << ans << endl;
	return 0;
}

Measured memory_bytes: 140928
parseInt(x) = parse(Int, x)

function nrtgt(a, s, f)
	k = 0
	while s+f*k<a
		k += 1
	end
	return(s+f*(k))
end

function main()
	n = parseInt(readline())
	csf = Array{Int}(3, n-1)
	for i in 1:n-1
		csf[:,i] = map(parseInt, split(readline()))
	end
	for i in 1:n-2
		tim = csf[2,i]
		for j in i+1:n-1
			tim = nrtgt(tim+csf[1,j-1], csf[2,j], csf[3,j])
		end
		tim += csf[1, n-1]
		println(tim)
	end
	println(csf[1,n-1]+csf[2,n-1])
	println(0)
end

main()

Measured memory_bytes: 114264
from queue import deque

k=int(input())
que=deque()
for i in range(1,10):
  que.append(i)
for i in range(k):
  now=que.popleft()
  too=now%10

  if too!=0:
    que.append(now*10+too-1)

  que.append(now*10+too)

  if too!=9:
    que.append(now*10+too+1)

print(now)

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

int main(){
  int n,a,b;
  cin >>n >>a >>b;
  int cnt1=0, cnt2=0, cnt3=0;
  rep(i,n){
    int p;
    cin >>p;
    if(p<=a) cnt1++;
    else if(p>=a+1 && p<=b) cnt2++;
    else if(p>=b+1) cnt3++;
  }
  cout << min(min(cnt1, cnt2), cnt3) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

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

    ll N; cin >> N;
    ll cur = 1, ans = 0;
    rep(i, N) {
        ll a; cin >> a;
        if(a == cur) cur++;
        else ans++;
    }
    if(ans == N) ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 256
n = gets.to_i
ar = gets.split.map(&:to_i)
ans = 0
for i in 1..n-2
  if (ar[i-1] <= ar[i] && ar[i] < ar[i+1]) || (ar[i-1] > ar[i] && ar[i] >= ar[i+1])
    ans += 1
  end
end
puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

long long gcd(long long a, long long b)
{
    if(a < b){
        swap(a, b);
    }
    if(a % b == 0){
        return b;
    }
    return gcd(b, a % b);
}

int main() {
    //cout.precision(10);
    int t;
    cin >> t;
    for(int time = 0; time < t; time++){
        long long a, b, c, d;
        cin >> a >> b >> c >> d;
        if((d < b) || (a < b)){
            cout << "No" << endl;
            continue;
        }
        long long e = gcd(b, d);
        long long l = (a - c - 1) / e;
        if(e * l > a - b){
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const int MAXN = 100005;
const int INF = 1 << 30;

int res = INF;

int n, k, x[MAXN];

int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++)
		scanf("%d", &x[i]);
	for (int i = 1; i <= n - k + 1; i++)
	{
		int cur;
		int l = x[i], r = x[i + k - 1];
		if (l <= 0 && r <= 0)
			cur = -l;
		else if (l <= 0 && r > 0)
			cur = r - l + min(-l, r);
		else
			cur = r;
		res = min(res, cur);
	}
	printf("%d\n", res);
	return 0;	
}


Measured memory_bytes: 640