akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}
template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    long long N,T;
    long long ans=0;

    cin >> N >> T;
    vector<long long>time(N);

    rep(i,N){
        cin >> time[i];
    }

    for(int i=1; i<N; i++){
        ans+=min(T,time[i]-time[i-1]);
    }
    ans+=T;

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



Measured memory_bytes: 1792
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: -1 * x, A))

import heapq

heapq.heapify(A)

for _ in range(M):
    a = heapq.heappop(A)
    heapq.heappush(A, -(-1 * a // 2))
    # print(A)

print(-sum(A))


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

using namespace std;

class SegTreeRMQ{
public:
    SegTreeRMQ(int N){
        init(N);
    }
    void init(int N){
        int s = 1;
        while(s < N){
            s*=2;
        }
        dat = std::vector<int>(s * 2,2147483647);
        n = s;
    }
    void update(int i,int x){
        i += n - 1;
        dat[i]= x;
        while(i > 0){
            i = (i-1) / 2;
            dat[i] = min(dat[i * 2 + 1],dat[i * 2 + 2]);
        }
    }
    //使う時は変数名.query(a,b,k,l,変数名getSize())
    int query(int a,int b,int k,int l,int r){
      //  cout<<k<<endl;
        if(r <= a || b<= l)return 2147483647;
        if(a <= l && r <= b)return dat[k];
        else{
            int vl = query(a,b,k * 2 + 1,l,(l+r)/2);
            int vr = query(a,b,k * 2 + 2,(l+r)/2,r);
            return min(vl,vr);
        }
    }
    int getSize(){
        return n;
    }
    void show(){
        for(int a = 0;a < n;a++){
            cout<<dat[a]<<" ";
        }
        cout<<endl;
        return;
    }
private:
    int n;
    std::vector<int> dat;
};

int main()
{
    int n;cin >> n;
    int q;cin >> q;
    SegTreeRMQ Seg(n);
    for(int a = 0;a < q;a++){
        int x,y,z;cin >> x >> y >> z;
        if(x == 0){
            Seg.update(y,z);
        }else{
            cout<<Seg.query(y,z+1,0,0,Seg.getSize())<<endl;
        }
    }
   // Seg.show();
    return 0;
}



Measured memory_bytes: 3892
s = gets.chomp.to_s

l = s.size

if l == 1
  p 0
else

  if l.even?
    s_front = s[0..l/2-1]
    s_back = s[l/2..l].reverse
  else
    s_front = s[0..l/2-1]
    s_back = s[l/2+1..l].reverse
  end

  count = 0
  s_front.split("").each.with_index do |v,i|
    count += 1 if s_front[i] != s_back[i]
  end
  p count
end


Measured memory_bytes: 1916
N = int(input())
A = list(map(int, input().split()))
out = {}

for x in range(len(A)):
    out[x + 1] = A[x]

outlist = []
for k, v in sorted(out.items(), key=lambda x: x[1]):
    outlist.append(str(k))

print(" ".join(outlist))


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

using namespace std;

long long int dp[100001];
long long int MOD = 1e9 + 7;
bool isdanger[100001];

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

	int n,m,t;

	cin >> n >> m;

	for(int i=0;i<m;i++)
	{
		cin >> t;
		isdanger[t] = true;
	}

	dp[0] = 1;
	for(int i=0;i<=n;i++)
	{
		if(isdanger[i])
		{
			continue;
		}

		if(i+1<=n)
		{
			if(isdanger[i+1]!=true)
			{
				dp[i+1] = ((dp[i]%MOD) + (dp[i+1]%MOD))%MOD;
				dp[i+1]%=MOD;
			}
		}
		if(i+2<=n)
		{
			if(isdanger[i+2]!=true)
			{
				dp[i+2] = ((dp[i]%MOD) + (dp[i+2]%MOD))%MOD;
				dp[i+2]%=MOD;
			}
		}
	}

	cout << dp[n] << '\n';

	return 0;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  vector<vector<int>> vv(h, vector<int> (w));
  vector<vector<int>> vv2(h, vector<int> (w));
  for (int i = 0; i < h; i++) {
    cin >> v[i];
    for (int j = 0; j < w; j++) {
      if(v[i][j] == '#') {
        vv[i][j] = -1;
        vv2[i][j] = -1;
      }
      else{
        vv[i][j] = 1;
        vv2[i][j] = 1;
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 1; j < w; j++) {
      if(vv[i][j-1] != -1 && vv[i][j] != -1) vv[i][j] += vv[i][j-1];
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = w-2; j >= 0; j--) {
      if(vv[i][j+1] != -1 && vv[i][j] != -1){
        vv[i][j] = vv[i][j+1];
      }
    }
  }

  for (int i = 0; i < w; i++) {
    for (int j = 1; j < h; j++) {
      if(vv2[j-1][i] != -1 && vv2[j][i] != -1) vv2[j][i] += vv2[j-1][i];
    }
  }
  for (int i = 0; i < w; i++) {
    for (int j = h-2; j >= 0; j--) {
      if(vv2[j+1][i] != -1 && vv2[j][i] != -1){
        vv2[j][i] = vv2[j+1][i];
      }
    }
  }

  int res = -1;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      res = max(res, vv[i][j] + vv2[i][j] - 1);
    }
  }
  cout << res << endl;

}


Measured memory_bytes: 38016
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll B;
ll C;
ll N;
ll M;
ll K;

/*
max 448,000,000
map<string,ll> count_map;
count_map['0']=0;
for(auto x : count_map) {
    string key = x.first;
    ll value = x.second;
}
*/

map<ll,ll> count_map;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    bool flag = true;

    rep(ni,N){
        cin >> ltmp;
        if(count_map.count(ltmp)>0){
            flag = false;
            break;
        }else{
            count_map[ltmp]=10;
        }
        
    }
    if(flag){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 12800
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimize("Os")
#pragma GCC target("avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Os")
*/
 
#include <bits/stdc++.h>
//#include <windows.h>
 
#define ll long long
#define X first
#define Y second
#define MP make_pair
 
using namespace std;
 
    
const int MAX_MEM = 1e8;
int mpos=0;
char mem[MAX_MEM];
inline void * operator new(size_t n){
	char *res = mem + mpos;
	mpos += n;
	assert(mpos <= MAX_MEM);
	return (void *)res;
}
 
inline void operator delete(void *){}
    

const int N = 2e5 + 123;
const ll mod = 1e9 + 7;

int n, res;
ll a[N];
unordered_map<ll, bool> mp;

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
		mp[a[i]] = (i & 1);
	}

	sort(a + 1, a + n + 1);

	for(int i = 1;i <= n;i++){
		if(mp[a[i]] != i % 2 && i % 2 == 0){
			res++;
		}
	}

	cout << res;

	return 0;
}

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

typedef long long ll;
#define int ll
#define pb push_back
// const int INF = 1e18;
const int inf = 1e9;

signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);


	#ifndef ONLINE_JUDGE
		time_t t1 = clock(), t2;
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
		// freopen("err.txt", "w", stderr);
	#endif


	int n,k;
	cin>>n>>k;
	int arr[n+1];
	for(int i=1;i<=n;i++)
		cin>>arr[i];

	vector<int> vis(n+1,0);
	vector<int> path;
	map<int,int> occ;
	int cur = 1;
	while(true){
		if (vis[cur])
			break;
		vis[cur] = 1;
		path.pb(cur);
		occ[cur] = path.size()-1;
		cur = arr[cur];
	}

	if (k <= occ[cur]){
		cout<<path[k];
		return 0;
	}
	
	int len = path.size() - occ[cur];
	k -= occ[cur];
	k%= len;
	cout<<path[occ[cur]+k];

	return 0;
}

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

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

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

  for (int i = 0; i < n; i++){
    int v = a.at(i);
    int j = i - 1;

    while (j >= 0 && a.at(j) > v){
      a.at(j+1) = a.at(j);
      j--;
    }
    a.at(j+1) = v;

    for (int k = 0; k < n; k++){
      cout << a.at(k);
      if (k < n - 1){
        cout << ' ';
      }else {
        cout << endl;
      }
    }
  }


  return 0;
}


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

int l[205];
int main(){
//	freopen("in.txt","r",stdin);
	int n;cin>>n;
	for(int i=0;i<n+n;i++)cin>>l[i];
	sort(l,l+n+n);
	int ans=0;
	for(int i=0;i<n+n;i+=2)
		ans+=l[i];
	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using ll=long long;
using namespace std;
const long MOD=1e9+7;
template<class T>
T lcm(T a,T b){
    return a/__gcd(a,b)*b;
}

int main(){
    char c;cin >> c;
  	map<char,char> m;
  	m['A']='T';
  	m['T']='A';
  	m['C']='G';
  	m['G']='C';
  	cout << m[c];
    return 0;
}

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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  double l;
  cin>>l;
  double a;
  a=double((l*(1.0))/(3*1.0));
  a=a*a*a;
  cout<<setprecision(14)<<fixed<<a;
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}

Measured memory_bytes: 256
def my_swap(ary, b, e, t):
    k = 0
    while k < (e - b):
        temp = ary[b+k]
        ary[b+k] = ary[t+k]
        ary[t+k] = temp
        k += 1
    return ary


def main():
    input()
    ary = [int(x) for x in input().split(' ')]
    q = int(input())
    for i in range(q):
        b, e, t = [int(x) for x in input().split(' ')]
        ary = my_swap(ary, b, e, t)
    print(' '.join([str(x) for x in ary]))


if __name__ == '__main__':
    main()



Measured memory_bytes: 5720
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

template<typename T>
class SegmentTree
{
    int n;
    function<T(T,T)> op;
    vector<T> V;

    T q(int l, int r)
    {
        if (l >= r)
            return V[0];
        T a = q((l+1)/2, r/2);
        if (l%2 != 0)
            a = op(a, V[l]);
        if (r%2 != 0)
            a = op(a, V[r-1]);
        return a;
    }

public:
    SegmentTree(int n_, function<T(T,T)> op, T init):
        op(op)
    {
        n = 1;
        while (n < n_)
            n *= 2;
        V = vector<T>(2*n, init);
        for (int i=n-1; i>0; i--)
            V[i] = op(V[i*2], V[i*2+1]);
    }

    T get(int p) const
    {
        return V[p+n];
    }

    void set(int p, T v)
    {
        p += n;
        V[p] = v;
        for (p/=2; p>0; p/=2)
            V[p] = op(V[p*2], V[p*2+1]);
    }

    //  init OP v[l] OP v[l+1] OP ... OP v[r-1]
    T query(int l, int r)
    {
        return q(l+n, r+n);
    }
};

int main()
{
    int N;
    cin>>N;
    vector<int> h(N);
    for (int &t: h)
        cin>>t, t--;
    vector<long long> a(N);
    for (long long &t: a)
        cin>>t;

    SegmentTree<long long> ST(N, [](long long a, long long b){return max(a, b);}, 0LL);
    long long ans = 0;
    for (int i=0; i<N; i++)
    {
        long long t = ST.query(0, h[i]) + a[i];
        ST.set(h[i], t);
        ans = max(ans, t);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6656
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main() {
	int n = 0;
	cin >> n;

	string str;
	set<string> s;

	for (int i = 0; i < n; i++) {
		cin >> str;
		s.insert(str);
	}

	cout << s.size() << endl;

	//system("PAUSE");
	return 0;
}

Measured memory_bytes: 19144
import heapq
class PriorityQueue:
	def __init__(self,num_list=None,reverse=False):
		self.reverse = reverse
		self.heap = []
		if num_list != None :
			for num in num_list:
				self.push(num)

	def push(self,num):
		heapq.heappush(self.heap,-num if self.reverse else num)

	def pop(self):
		num = heapq.heappop(self.heap)
		return -num if self.reverse else num
	
	def get_heap(self):
		return map(lambda x: x*(-1),self.heap)

n,m = map(int,input().split())
items = list(map(int,input().split()))
pq = PriorityQueue(num_list=items,reverse=True)

while m>0:
	item = pq.pop()
	pq.push(int(item/2))
	m -= 1
print(sum(pq.get_heap()))

Measured memory_bytes: 14380
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> R[i];
  int maxv = -2000000000;
  int minv = R[0];
  for (int i = 1; i < n; ++i) {
    maxv = max(maxv, R[i]- minv);
    minv = min(minv, R[i]);
  }

  std::cout << maxv << std::endl;
}

Measured memory_bytes: 3864
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<deque>
#include<map>
#include<iostream>
using namespace std;
const int maxn = 200001;
int a[maxn];

int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
	}
	int f = a[1];
	for (int i = 2; i <= n; ++i)
	{
		f = (f^a[i]);
	}
	if (f == 0)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
}

Measured memory_bytes: 640
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll n,m,c,ans,temp;
void solve()
{
   cin>>n;ll ar[n];
   for(int i=0;i<n;i++)
   {
       cin>>ar[i];
   }
   ans=1;ll chk=ar[0];
   for(int i=1;i<n;i++)
   {
       if(max(ar[0],chk)<=ar[i])
        ans++;
        chk=max(chk,ar[i]);
   }
   cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
X, N = map(int,input().split())
if N == 0:
  P = []
else:
  P = list(map(int, input().split()))
  P = sorted(P)
assert len(P) == N
cands = []
# 下側検索
x = X
while True:
  if x not in P:
    cands.append(x)
    break
  x -= 1
# 上側検索
x = X
while True:
  if x not in P:
    cands.append(x)
    break
  x += 1
a,b = cands
if abs(a - X) > abs(b - X):
  print(b)
else:
  print(a)

Measured memory_bytes: 9220
#include <iostream>
using namespace std;
long long a[2001]; 
int main()
{
    int n,i,j;
    a[3]=1;
    a[4]=1;
    a[5]=1;
    cin>>n;
    if(n>=1 and n<=5)
        cout<<a[n];
    else
    {
    for(i=6;i<=n;i++)
    {
        a[i]++;
        for(j=3;j<=i-3;j++)
            a[i]=(a[j]+a[i])%1000000007;
    }
    cout<<a[n]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
//abc054.cpp
//Sat Oct 27 17:24:58 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	string a[n],b[m];
	for (int i=0;i<n;i++){
		cin >> a[i];
	}
	for (int i=0;i<m;i++){
		cin >> b[i];
	}

	int flag = 0;
	for (int i=0;i<n-m+1;i++){
		for (int j=0;j<n-m+1;j++){
			string temp = a[i].substr(j,m);
			if (temp == b[0]){
				flag = 1;
				int bcount = 0;
				for (int k=i;k<i+m;k++){
					if (a[k].substr(j,m) != b[bcount]){
						flag = 0;
						break;
					}
					bcount++;
				}
				if (flag == 1){
					cout << "Yes" << endl;
				}
			}
			if (flag == 1){
				break;
			}
		}
		if (flag == 1){
			break;
		}
	}
	if (flag == 0){
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

// int main(){
// 	ll a;
// 	double b;
// 	cin >> a >> b;
// 	cout << ll(a * b) << endl;


// 	return 0;
// }

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 1;
	ll m = 1e18;
	rep(i,n){
		if(a[i] == 0){
			cout << 0 << endl;
			return 0;
		}
	}
	rep(i, n)
	{
		if (a[i] == 0)
		{
			cout << 0 << endl;
			return 0;
		}
		else if (ans > m / a[i]){
			cout << -1 << endl;
			return 0;
		} else {
			ans *= a[i];
		}
	}
	cout << ans << endl;
	return 0;
}

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

X = dict()
ans = 0
for i in range(N):
    L = i + A[i]
    if L not in X:
        X[L] = 1
    else:
        X[L] += 1

for i in range(N):
    R = i - A[i]
    if R in X:
        ans += X[R]
        
print(ans)


Measured memory_bytes: 40344
#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,bo,bt;
	char deci;
	cin >> a >> bo >> deci >> bt;
	bo *= 100;
	bo += bt;
	a *= bo;
	cout << a / 100;
	return 0;
}




Measured memory_bytes: 3648
S,T = input(),input()
ans = len(T)

for i in range(len(S)-len(T)+1):
    sum = 0
    for j in range(len(T)):
        if S[i+j] == T[j]:sum+=1
        # print(i,j,sum,S[i+j],T[i])
    ans = min(ans,len(T)-sum)
print(ans)

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

int main(){
  int k;
  int a,b;
  cin >> k;
  cin >> a >> b;
  if(a <= b/k*k){
    cout << "OK" << endl;
  }
  else{
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3592
N, K = map(int, raw_input().split())
S = str(raw_input())
if K == 1:
    s_idx = 0
else:
    s_idx = K-1



if S[K-1] == 'A':
    S = S[:s_idx] + 'a' + S[K:]
elif S[K-1] == 'B':
    S = S[:s_idx] + 'b' + S[K:]
elif S[K-1] == 'C':
    S = S[:s_idx] + 'c' + S[K:]
print S

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll a[60],b[60];
ll ans=0;

void dfs(int n,ll x){
	if(x<=0)return;
	if(a[n]<=x){
		ans+=b[n];
		return;
	}
	if(a[n-1]+2<=x)ans++;
	dfs(n-1,x-1);
	dfs(n-1,x-a[n-1]-2);
}
signed main(){
	int n;ll x;cin>>n>>x;
	a[0]=1;b[0]=1;
	for(int i=1;i<=n;i++)a[i]=a[i-1]*2+3;
	for(int i=1;i<=n;i++)b[i]=b[i-1]*2+1;
	dfs(n,x);
	cout<<ans<<endl;
}

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

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    int ans_1 = 100;
    int ans_2 = 0;
    double conc_max = -1;
    for (int i=0; i<=30; i++) {
        for (int j=0; j<=30; j++) {
            for (int k=0; k<=100; k++) {
                for (int l=0; l<=100; l++){
                    int water = 100 * A * i + 100 * B * j;
                    int sugar = C * k + D * l;
                    int sum = water + sugar;
                    if (water == 0) continue;
                    double conc = (100 * sugar) / (double)sum;
                    double Threshold = (double)(E * water) / 100;
                    if (sum > F) continue;
                    if (sugar > Threshold) continue;
                    if (conc > conc_max) {
                            ans_1 = sum;
                            ans_2 = sugar;
                            conc_max = conc;
                    } 
                }
            }
        }
    }
    cout << ans_1 << " " << ans_2 << endl;
}


Measured memory_bytes: 256
S = input()

def solve(T) :
    while 1:
        for i in ("dream", "dreamer", "erase", "eraser"):
            if T.endswith(i):
                T = T[: -len(i)]
                break
        
        else:
            print("NO")
            break
        
        if not T:
            print("YES")
            break

solve(S)

Measured memory_bytes: 9016
n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = [list(map(int,input().split())) for i in range(m)]
bc.sort(key=lambda x:x[1], reverse=True)
  
for b,c in bc:
  a.extend([c]*b)
  if len(a) > n*2:
    break
a.sort(reverse=True)
print(sum(a[:n]))

Measured memory_bytes: 34760
#include <stdio.h>
#include <string.h>
int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  int k;
  scanf("%d",&k);

  for(int i=0;i<k;i++){
    if(a>=b){
      b=2*b;
    }else{
      if(b>=c){
        c=2*c;
      }
    }
  }
  if(c>b&&b>a){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1728
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		Console.WriteLine("{0}",n*n*n);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 13268
use std::io;

fn main() {
    let (n, mut values) = input();
    values.reverse();

    for (k ,v) in values.iter().enumerate() {
        if k as i32 + 1 == n {
            println!("{}", v);
        } else {
            print!("{} ", v);
        }
    }
}

fn input() -> (i32, Vec<i32>) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");

    let n: i32 = s.trim().parse().unwrap();
    
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();

    let mut v: Vec<i32> = vec![];
    for _ in 0..n {
        v.push(iter.next().unwrap().parse().unwrap());
    }

    (n, v)
}



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

using namespace std;

using ll = long long;
using ld = long double;

ll xor_sum(ll x)
{
	//cout << x << endl;
	if (x == 0)
		return 0;
	if (x == 1)
		return 1;
	if (x == 2)
		return 3;
	if (x == 3)
		return 0;
	ll a = 1;
	while (a <= x)
	{
		a <<= 1;
	}
	a >>= 1;
	if ((x - a + 1) & 1)
	{
		return a + xor_sum(x - a);
	}
	else
	{
		return xor_sum(x - a);
	}
}

int main()
{
	ll n, m;
	cin >> n >> m;
	if (n == 0)
	{
		cout << m << endl;
		return 0;
	}
	ll ans = xor_sum(m) ^ xor_sum(n - 1);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#define N 1000000
using namespace std;

int n;
int r,c,q;
int r1,c1,r2,c2;
int grid[N];
vector<int> seg[1000];

void init(int num,int n_){
  for(int i=0;i<2*n_-1;i++)seg[num].push_back( (1<<31)-1 );
}

void update(int x,int k, int a){
  k += n-1;
  seg[x][k] = a;
  while(k>0){
    k = (k-1) / 2;
    seg[x][k] = min(seg[x][k*2+1], seg[x][k*2+2]);
  }
}

int query(int x, int a, int b, int k, int l, int r){
  if(r<=a || b<=l)return (1<<31) - 1;
  if(a<=l && r<=b)return seg[x][k];
  else{
    return min(query(x,a,b,2*k+1,l,(l+r)/2),query(x,a,b,2*k+2,(l+r)/2,r));
  }
}

int main(){
  while(1){
    cin >> r >> c >> q;
    if(!r && !c && !q)break;

    for(int i=0;i<r;i++){
      for(int j=0;j<c;j++)cin >> grid[i*c+j];
    }

    if(r>=c){
      n = 1;
      while(n<r)n *= 2;
      for(int i=0;i<c;i++)init(i,n);
      for(int i=0;i<c;i++){
	for(int j=0;j<r;j++)update(i,j,grid[j*c+i]);
      }
      while(q--){
	cin >> r1 >> c1 >> r2 >> c2;
	int ans = (1<<31) - 1;
	for(int i=c1;i<=c2;i++)ans = min(ans,query(i,r1,r2+1,0,0,n));
	cout << ans << endl;
      }
    }else{
      n = 1;
      while(n<c)n *= 2;
      for(int i=0;i<r;i++)init(i,n);
      for(int i=0;i<r;i++){
	for(int j=0;j<c;j++)update(i,j,grid[i*c+j]);
      }
      while(q--){
	cin >> r1 >> c1 >> r2 >> c2;
	int ans = (1<<31) - 1;
	for(int i=r1;i<=r2;i++)ans = min(ans,query(i,c1,c2+1,0,0,n));
	cout << ans << endl;
      }
    }
  }
}

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

int main() {
  int N ;
  cin >>N;
  vector<int> d(N);
  for (int i = 0;i < N;i++){
    cin >> d.at(i);
  }
  int sum=0;
  for ( int i = 0;i < N; i++){
    for (int j= 0;j<N;j++){
      if ( i ==j){
        continue;
      }
      
        
      
      
      sum +=d.at(i)*d.at(j);
      
    }
  }
  cout << sum/2 << endl;
}


Measured memory_bytes: 256
N, maxW = map(int, input().split())
WV = [[0 for i in range(maxW+1)] for j in range(N+1)]
W = [0 for i in range(N+1)]
V = [0 for i in range(N+1)]
for i in range(1, N+1):
    W[i], V[i] = map(int, input().split())

for i in range(1, N+1):
    for w in range(maxW+1):
        WV[i][w] = max(WV[i-1][w], WV[i][w])
        nw = w + W[i]
        if nw <= maxW:
            WV[i][nw] = WV[i-1][w] + V[i]

print(max(WV[-1]))

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

#define ll   long long int
#define PI 3.14159265358979
#define zig ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;


int main()
{
    zig
    int n, k, x, y, first;
    cin>>n>>k>>x>>y;
    first=min(n, k);
    int ans=first*x+(n-first)*y;
    cout<<ans<<'\n';
    return 0;
}


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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	double r;

	cin >> r;

	printf("%.10lf %.10lf\n", PI * r * r, 2 * PI * r);

	return 0;
}



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

using bellman_cost = int;
template<class V, class E>
struct Graph
{
	int sz;
	vector<V> v;
	vector<vector<E>> e;
	Graph(int n) : sz(n), v(n), e(n) {}
	template<class... Args>
	inline void assign_vertex(int pos, Args... args) {
		v[pos] = V(args...);
	}
	template<class... Args>
	inline void add_edge(int pos, Args... args) {
		e[pos].emplace_back(args...);
	}
	inline int size() {
		return sz;
	}
};

template<class T>
struct Vertex_Cost
{
	T cost;
	bool valid = false;
	Vertex_Cost(T v1) : cost(v1) {}
	Vertex_Cost() {}
};
using vertex = Vertex_Cost<bellman_cost>;

template<class T>
struct Edge_Cost
{
	int to;
	T cost;
	Edge_Cost(int t, T c) : to(t), cost(c) {}
	Edge_Cost() {}
};
using edge = Edge_Cost<bellman_cost>;
using graph = Graph<vertex, edge>;

template<class T, class V, class E>
void Bellmanford(Graph<V, E>& G, int s, T INF_COST)
{
	auto &v = G.v;
	auto &e = G.e;
	for (auto& vv : v) vv.cost = INF_COST;
	v[s].cost = 0;
	v[s].valid = true;
	for (int i = 0; i + 1 < (int) v.size(); i++) {
		for (int j = 0; j < (int) v.size(); j++) {
			for (auto& x: e[j]) {
				if (v[j].cost == INF_COST) continue;
				v[x.to].cost = min(v[x.to].cost, v[j].cost + x.cost);
				v[x.to].valid = true;
			}
		}
	}
	vector<int> not_valid;
	for (int i = 0; i < (int) v.size(); i++) {
		for (auto& x: e[i]) {
			if (v[i].cost == INF_COST) continue;
			if (v[x.to].cost > v[i].cost + x.cost) {
				not_valid.emplace_back(x.to);
			}
		}
	}
	for (auto& x: not_valid) {
		auto dfs = [&](auto f, int pos) {
			if (!v[pos].valid) return;
			v[pos].valid = false;
			for (auto& y: e[pos]) {
				f(f, y.to);
			}
		};
		dfs(dfs, x);
	}
}


void solve(long long N, long long M, long long P, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C) {
	graph g(N);
	for (int i = 0; i < M; i++) {
		g.add_edge(A[i]-1, B[i]-1, -(C[i] - P));
	}
	Bellmanford(g, 0, INT_MAX);
	if (!g.v[N-1].valid) cout << -1 << endl;
	else cout << max(-g.v[N-1].cost , 0) << endl;
}

signed main() {
	long long N;
	scanf("%lld",&N);
	long long M;
	scanf("%lld",&M);
	long long P;
	scanf("%lld",&P);
	std::vector<long long> A(M);
	std::vector<long long> B(M);
	std::vector<long long> C(M);
	for(int i = 0 ; i < M ; i++){
		scanf("%lld",&A[i]);
		scanf("%lld",&B[i]);
		scanf("%lld",&C[i]);
	}
	solve(N, M, P, std::move(A), std::move(B), std::move(C));
	return 0;
}


Measured memory_bytes: 640
// #pragma GCC optimize("Ofast")

// #pragma GCC optimize("no-stack-protector")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>

using namespace std;

template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}

template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define left left228
#define right right228
#define ld long double
#define list list228
// #define prev prev228
#define mp make_pair
#define list list228
#define all(v) v.begin(), v.end()

int x[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    cout << x[k - 1] << endl;
    return 0;
}

/*
3
1 1 2
2 2 2
3 3 2
2 1 1
3 2 1


2 2
1 1 2
2 2 2
1 2 3
2 1 1

2
2 1 2 2 3
2 2 2 1 1

5
1 2
2 3
3 4
3 5
1
2 3
1 2
4 3
2 3 5

*/



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

using namespace std;

typedef long long ll;

const int N = 501;

ll dp[N][N][2];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    ll s, x, ans = 0;
    cin >> n >> s;
    vector<ll> w(n), v(n);
    for (int i = 0; i < n; ++i) {
        cin >> w[i] >> v[i];
        if (!i) {
            x = w[0];
        }
        w[i] -= x;
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            dp[i][j][0] = -1;
        }
    }
    dp[0][0][0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                dp[i][j][1] = dp[i][j][0];
            }
        }
        for (int j = 0; j < n; ++j) {
            for (int k = 0; k + w[i] < N; ++k) {
                if (dp[j][k][0] == -1) {
                    continue;
                }
                if (k + w[i] <= s - x * (j + 1)) {
                    dp[j + 1][k + w[i]][1] = max(dp[j + 1][k + w[i]][1], dp[j][k][0] + v[i]);
                }
            }
        }
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                dp[i][j][0] = dp[i][j][1];
                ans = max(ans, dp[i][j][0]);
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,count=1;
  cin>>n>>k;
  for(int i=0; i<n; i++){
    if(count*2>=count+k){
      count+=k;
    }else{
      count=count*2;
    }
  }
  cout<<count<<'\n';
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define ll long long
 
int main()
{
    FASTIO
    int n;
    ll k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i,0,n)
    {
        cin >> v[i];
        v[i]--;
    }
    set<int> nodes;
    int pos = 0;
    nodes.insert(pos);
    int n_c = 0;
    while(true)
    {
        if(nodes.find(v[pos]) == nodes.end())
        {
            nodes.insert(v[pos]);
            pos = v[pos];
        }
        else
        {
            n_c = v[pos];
            break;
        }
    }
    pos = 0;
    int steps = 0, cycle = 0;
    while(pos != n_c)
    {
        steps++;
        pos = v[pos];
    }
    pos = v[pos];
    cycle++;
    while(pos != n_c)
    {
        pos = v[pos];
        cycle++;
    }
    pos = 0;
    if(k >= steps)
    {
    	k -= steps;
    	k %= cycle;
    	pos = n_c;
    }
    while(k--)
    {
        pos = v[pos];
    }
    cout << pos + 1 << "\n";
 
    return 0;
}

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

using namespace std;
int main() {
	int N;
	int min = 2;
	long long int ans = 0;
	int a;
	cin >> N ;
	cin >> a;
	ans += a - 1;
	for (int i = 1; i < N; i++) {
		cin >> a;
		if (a == min) {
			min++;
		}
		else {
			if (a%min == 0) {
				ans += (a / min) - 1;
			}
			else {
				ans += a / min;
			}
		}
	}
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
using namespace std;

#define ll long long

ll n,a,b;
ll h[100005],t[100005];

bool check(ll m){
	ll cost=0;
	
	for(int i=0;i<n;i++){
		if(h[i]-b*m>0){
			cost+=(h[i]-b*m+(a-b-1))/(a-b);
		}
	}
	
	return cost<=m;
}
int main(){
	cin>>n>>a>>b;
	for(ll i=0;i<n;i++) 
		cin>>h[i];
	ll l=1,r=10000000000;
	while(l<=r){
		ll m=(l+r)/2;
		if(check(m)){
			r=m-1;
		}else{
			l=m+1;
		}
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 1024
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto xs = readints;
    int a = xs[0], b = xs[1], c = xs[2], d = xs[3];

    if (a + b  > c + d) writeln("Left");
    else if (a + b == c + d) writeln("Balanced");
    else writeln("Right");
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

signed main() {
  SS(string,s);
  if(s[s.length()-1]=='2'||s[s.length()-1]=='4'||s[s.length()-1]=='5'||s[s.length()-1]=='7'||s[s.length()-1]=='9'){
    p("hon");
  }
  if(s[s.length()-1]=='0'||s[s.length()-1]=='1'||s[s.length()-1]=='6'||s[s.length()-1]=='8')p("pon");
  if(s[s.length()-1]=='3')p("bon");
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include<algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
    long long n,h; cin>>n;
    h = (n/500)*1000;
    n = n%500;
    h = h+ (n/5)*5;
    cout<<h;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long n,k,s=1;
    cin>>n>>k;
    for(int i=0;;i++)
    {
        s*=k;
        if(s>n)
        {
            cout<<i+1;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
int main(){
    
    int n,x,a[111];
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<n;i++){
        x-=a[i];
        if(x<0)break;
        else{
            if(!(i==n-1 && x!=0))ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = sc.nextInt();
        int ar[] = new int[n];
        for(int i = 0; i < n; i++) {
            ar[i] = sc.nextInt();
        }
        long dp[][] = new long[n][n];
        for(int L = 1; L <= n; L++) {
            for(int i = 0; i + L - 1 < n; i++) {
                int j = i + L - 1;
                if(L == 1) {
                    dp[i][j] = ar[i];
                    continue;
                }
                dp[i][j] = Math.max(ar[i] - dp[i + 1][j], -dp[i][j - 1] + ar[j]);
            }
        }
        System.out.println(dp[0][n - 1]);
    }
}


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

int main() {
    int n; cin >> n;
    int X[n]; for (int i = 0; i < n; i++) cin >> X[i];
    int m; cin >> m;
    int A[m]; for (int j = 0; j < m; j++) cin >> A[j];

    for (int j = 0; j < m; j++) {
        const int piece_idx = A[j] - 1;
        const int piece_loc = X[piece_idx];
        bool is_next_blank = true;
        for (int i = 0; i < n; i++)
            if (X[i] == piece_loc + 1) is_next_blank = false;
        if (piece_loc != 2019 && is_next_blank) X[piece_idx]++;
    }

    for (int i = 0; i < n; i++) cout << X[i] << endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> v(n + 1, 0);
    for (int i = 1; i <= 100; i++) {
    	for (int j = 1; j <= 100; j++) {
    		for (int k = 1; k <= 100; k++) {
    			int t = i * i + j * j + k * k + i * j + j * k + i * k;
    			if (t <= n) {
    				v[t]++;
    			}
    		}
    	}
    }
    for (int i = 1; i <= n; i++) {
    	cout << v[i] << endl;
    }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int s,t,v,l;
    scanf("%d %d %d",&s,&t,&v);
    l = v * t;
    if( l >= s){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 3680
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (int)1e5 + 3;

int n, a[N], res[N];

signed main() {
  init_ios();
  cin >> n;
  int sum = 0;
  int sum2 = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    a[i] *= 2;
    sum += a[i];
    if ((i&1) && i < n)
      sum2 += a[i];
  }
  sum /= 2;
  res[n] = sum-sum2;
  for (int i = n-1; i >= 1; --i)
    res[i] = a[i]-res[i+1];
  for (int i = 1; i <= n; ++i)
    cout<<res[i]<<" ";
  cout<<"\n";
}

Measured memory_bytes: 2944
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
using namespace std;
  
#define int long long int 
typedef vector<int> vi;
typedef vector<pair<int, int>> vpi;
typedef vector<vi> vvi;
const int mod = 1e9 + 7; 

#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define debug(...) cerr << "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define size(v) (int)v.size() 
#define endl "\n"
#define UMO unordered_map
#define USO unordered_set
#define TC int t; cin >> t; while (t--) 

void Panda() {
    string n;
    cin >> n;
    int cnt = 0, ind = 0;
    while(ind < size(n)) {
        cnt += n[ind++] - '0';
    }
    cout << (cnt % 9 == 0 ? "Yes" : "No") << endl;
}
  
int32_t main() {
 
    FAST;

    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout); 
    
    Panda();

    return 0; 
} 

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

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

typedef long long ll;

int main() {
  int r, d;
  vector<ll> xi(10);
  cin >> r >> d >> xi[0];

  for(int i=1; i<11; i++){
    xi[i] = r * xi[i-1] - d;
    cout << xi[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256