akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

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

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int main(int argc, const char * argv[]) {
    //提出時、消す----//
 
    //--------------//


    // input
    cout << fixed << setprecision(10);

    ll ans = 0;
    string str;
    cin >> str;
    bool ok = true;
    bool h = false;
    if(str.size() %2 == 0){
        rep(i, str.size()/2){
            if(str[i*2] == 'h' && str[i*2+1] == 'i'){

            }else{
                ok =false;
            }
        }
    }
    else{
        ok = false;
    }
    
    yesno(ok);
    
    
    return 0;
}


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

int main(){
  int N; cin >> N;
  long a[N];
  
  int four,odd; four=0; odd=0;
  for(int i=0; i<N; i++){
    cin >> a[i];
    if(a[i]%2==1){odd++;}
    else if(a[i]%4==0){four++;}
  }
  
  if(four>=odd){cout << "Yes";}
  else if(N%2==1 && odd==N/2+1 && four==N/2){cout << "Yes";}
  else{cout << "No";}
  
  return 0;
}

Measured memory_bytes: 1024
def dfs(startx, starty):
    dxdy = [[1, 0], [-1, 0], [0, 1], [0, -1], [1, 1], [1, -1], [-1, 1], [-1, -1]]
    stack = [(startx, starty)]
    reached = set()
    while stack:
        d = stack.pop()
        reached.add(d)
        for a in dxdy:
            x = d[0] + a[0]
            y = d[1] + a[1]
            if (x, y) not in reached and 0 <= x < W and 0 <= y < H and maze[y][x] != '0':
                stack.append((x, y))
    return reached


while True:
    W, H = map(int, input().split())
    if H == W == 0:
        break
    maze = [input().split()for _ in range(H)]
    ans = 0
    l = set()
    for i in range(H):
        for j in range(W):
            if (j, i) not in l and maze[i][j] == '1':
                l = l | dfs(j, i)
                ans += 1
    print(ans)


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

using namespace std;

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

#define INF 2<<29
#define F first
#define S second

P tree[1000005];
int time_[1000005];

int n,r,l;
int now=1;
int temp=1;
int before_t=0;
int ans=1;

void add(int d,int x){
  tree[d+temp].S+=x;
  int j=d+temp;
  do{
    j=(j-1)/2;
    if(tree[2*j+1].S>tree[2*j+2].S){ 
      tree[j]=tree[2*j+1];
    }else if(tree[2*j+1].S<tree[2*j+2].S){
      tree[j]=tree[2*j+2];
    }else{
      tree[j]=tree[2*j+1];
    }
  }while(j>0);

  return; 
} 

int main(){
  int d,t,x;
  
  scanf("%d %d %d",&n,&r,&l);
  while(temp<n){
    temp*=2;
  }
  temp--;

  for(int i=0;i<n;i++){
    tree[i+temp].F=i+1;
  }
  
  for(int i=0;i<r;i++){
    scanf("%d %d %d",&d,&t,&x);
    time_[now]+=t-before_t;
    before_t=t;

    add(d-1,x);
    now=tree[0].F;
  }
  time_[now]+=l-before_t;

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

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



Measured memory_bytes: 11332
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n,p,num[10005],now,tmp,pw;
typedef long long LL;
char s[N];
LL ans;
int f(char a){
    return a-'0';
}
int main(){
    cin>>n>>p;
    scanf("%s",s+1);
    num[0]=1;pw=1;
    if(p==2||p==5){
        for(int i=1;i<=n;++i)
            if((s[i]-'0')%p==0) ans+=(i);
        cout<<ans<<endl;
        return 0;
    }
    for(int i=n;i>0;i--){
        tmp=(now+pw*f(s[i]))%p;
        ans+=num[tmp];num[tmp]++;
        now=tmp;
        pw*=10;pw%=p;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fr(i,n) for(int i=0;i<(n);++i)
#define foor(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,n) for(int i=(n);i--;)
#define roof(i,b,a) for(int i=(b);i>=(a);--i)
#define all(x) x.begin(),x.end()
#define Sort(x) sort(all(x))
#define Reverse(x) reverse(all(x))
#define PQ priority_queue
#define print(x) cout<<(x)<<endl
using namespace std;            typedef vector<int>  vi;
typedef long long ll;           typedef vector< ll>  vl;
typedef unsigned long long ull; typedef vector<ull>  vu;
typedef double dbl;             typedef vector<dbl>  vd;
typedef pair<int,int>pii;       typedef vector<pii>vpii; typedef map<int,int>mii;
typedef pair< ll, ll>pll;       typedef vector<pll>vpll; typedef map< ll, ll>mll;
typedef pair<dbl,dbl>pdd;       typedef vector<pdd>vpdd; typedef map<dbl,dbl>mdd;
typedef pair< ll,int>pli;       typedef vector<pli>vpli; typedef map< ll,int>mli;
typedef pair<dbl,int>pdi;       typedef vector<pdi>vpdi; typedef map<dbl,int>mdi;
template<typename T>vector<T>&operator<<(vector<T>&v,const T t){v.push_back(t);return v;}
template<typename T>multiset<T>&operator<<(multiset<T>&m,const T t){m.insert(t);return m;}
template<typename T>set<T>&operator<<(set<T>&s,const T t){s.insert(t);return s;}
template<typename T,typename U>PQ<T,vector<T>,U>&operator<<(PQ<T,vector<T>,U>&q,const T t){q.push(t);return q;}
template<typename T,typename U>istream&operator>>(istream&s,pair<T,U>&p){return s>>p.first>>p.second;}
template<typename T>istream&operator>>(istream&s,vector<T>&v){fr(i,v.size()){s>>v[i];}return s;}
template<typename T,typename U>ostream&operator<<(ostream&s,const pair<T,U>p){return s<<p.first<<" "<<p.second;}
template<typename T>ostream&operator<<(ostream&s,const vector<T>v){for(auto a:v){s<<a<<endl;}return s;}
const int MD=1e9+7;
vpli dijkstra(const int N,const vpli E[],const int s,const ll inf){vpli d;fr(i,N)d<<pli{inf,i};d[s].first=0;PQ<pli,vpli,greater<pli>>pq;pq<<(d[s]=pli{0,s});while(pq.size()){pli a=pq.top();pq.pop();int v=a.second;if(d[v].first>=a.first){for(pli e:E[v]){if(d[v].first+e.first<d[e.second].first){d[e.second]=pli{d[v].first+e.first,v};pq<<pli{d[v].first+e.first,e.second};}}}}return d;}
ll gcd(const ll a,const ll b){return a?gcd(b%a,a):b;}
ll pow(const ll a,const ll n,const int m){ll t;return n?(n&1?a>=0?a%m:~-m+~a%m:1)*(t=pow(a,n>>1,m),t*t%m)%m:1;}
ll C2(const int n){return(ll)n*~-n/2;}

main(){cin.tie(0);ios::sync_with_stdio(false);
	using P=pair<ll,double>;
	set<P>s;
	ll k=0,p=1;
	for(ll j=0;j<=13;++j){
		for(ll i=1;i<=100000;++i){
			ll t=i*p+k;
			ll a=9*j;
			for(ll u=i;u;u/=10){
				a+=u%10;
			}
			s<<P{t,(double)t/a};
		}
		k=k*10+9;
		p*=10;
	}
	vector<P>v;
	for(P a:s){
		v<<a;
	}
	Reverse(v);
	vl z;
	double m=1e18;
	for(P a:v){
		if(a.second<=m){
			z<<a.first;
			m=a.second;
		}
	}
	Reverse(z);
	int K;
	cin>>K;
	fr(i,K){
		print(z[i]);
	}
}


Measured memory_bytes: 113640
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
using namespace std;
 
typedef long long ll;
 
int main(){
  int a,b;
  cin >> a>> b;
  vector<int> c;
  for(int i=ceil(a/0.08); i<ceil((a+1)/0.08); i++){
  	if(i/10==b){
    	cout <<i<< endl;
        return 0;
    }
  }
  cout << -1 <<endl;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            N = cin.ReadInt;
            var u = cin.ReadInt - 1;
            var v = cin.ReadInt - 1;
            to = new List<int>[N];
            for (int i = 0; i < N; i++)
            {
                to[i] = new List<int>();
            }
            for (int i = 0; i < N - 1; i++)
            {
                var A = cin.ReadInt - 1;
                var B = cin.ReadInt - 1;
                to[A].Add(B);
                to[B].Add(A);
            }
            var distU = CalcDist(u);
            var distV = CalcDist(v);

            var mx = 0;
            for (int i = 0; i < N; i++)
            {
                if (distU[i] < distV[i])
                {
                    mx = Max(mx, distV[i]);
                }
            }
            var ans = mx - 1;
            Console.WriteLine(ans);
        }

        int N;
        List<int>[] to;

        int[] CalcDist(int p)
        {
            var dist = new int[N];
            dfs(ref dist, p, 0, -1);
            return dist;
        }

        void dfs(ref int[] dist, int p, int d, int pp)
        {
            dist[p] = d;
            foreach (var next in to[p])
            {
                if (next != pp)
                {
                    dfs(ref dist, next, d + 1, p);
                }
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 35720
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int u=0;
    string s;
    cin >> s;
    for (int i=0;i<s.size();i++){
        if (s.at(i)=='x') u++;
    }
    if (u<8) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	int a[11][11];
	int i, j;
	
	while (scanf("%d", &n), n != 0){
		for (i = 0; i < 11; i++){
			for (j = 0; j < 11; j++){
				a[i][j] = 0;
			}
		}
		
		for (i = 0; i < n; i++){
			for (j = 0; j < n; j++){
				scanf("%d", &a[i][j]);
				a[i][n] += a[i][j];
				a[n][j] += a[i][j];
			}
			a[n][n] += a[i][n];
		}
		
		for (i = 0; i <= n; i++){
			for (j = 0; j <= n; j++){
				printf("%5d", a[i][j]);
			}
			printf("\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 616
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const s: string[] = input[0].split('');
const ss: string[] = s.slice().reverse();

let ans: number = 0;
const len: number = Math.floor(s.length/2)
for(let i = 0; i < len; i++){
    if(s[i] !== ss[i]){
        ans++
    }
}
console.log(ans);

Measured memory_bytes: 7372
#include <stdio.h>

int main() {
    int n, suits[4][13], i, j, number;
    char suit;
    for (i = 0; i < 4; i++) {
        for (j = 0; j < 13; j++) {
            suits[i][j] = 0;
        }
    }
    scanf("%d", &n);
    getchar();
    for (i = 0; i < n; i++) {
        scanf("%c %d", &suit, &number);
        getchar();
        switch (suit) {
            case 'S':
                suits[0][number - 1] = 1;
                break;
            case 'H':
                suits[1][number - 1] = 1;
                break;
            case 'C':
                suits[2][number - 1] = 1;
                break;
            case 'D':
                suits[3][number - 1] = 1;
                break;
        }
    }
    for (i = 0; i < 4; i++) {
        switch (i) {
            case 0:
                suit = 'S';
                break;
            case 1:
                suit = 'H';
                break;
            case 2:
                suit = 'C';
                break;
            case 3:
                suit = 'D';
                break;
        }
        for (j = 0; j < 13; j++) {
            if (!suits[i][j]) {
                printf("%c %d\n", suit, j + 1);
            }
        }
    }
    return 0;
}

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

public class P
{
    public int p { get; set; }
    public List<int> c { get; set; }
}

public class Q
{
    public int d { get; set; }
    public int id { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var d = new Dictionary<int, P>();
        for (int i = 0; i < n; i++) d[i + 1] = new P { c = new List<int>() };
        var dn = new string[n + 1];
        Console.ReadLine();
        dn[1] = Console.ReadLine().Trim();
        for (int i = 2; i <= n; i++)
        {
            var k = int.Parse(Console.ReadLine().Trim());
            var m = Console.ReadLine().Trim();
            dn[i] = m;
            d[k].c.Add(i);
            d[i].p = k;
        }
        print(d, dn);
    }
    static void print (Dictionary<int,P> d, string[] dn)
    {
        var sb = new StringBuilder();
        var st = new Stack<Q>();
        st.Push(new Q { d = 0, id = 1 });
        while (st.Count() > 0)
        {
            var w = st.Pop();
            var d2 = new string('.', w.d);
            sb.Append(d2 + dn[w.id] + "\n");
            var dc = d[w.id].c.Count();
            if (dc > 0)
            {
                d[w.id].c.Reverse();
                foreach (var x in d[w.id].c)
                    st.Push(new Q { d = w.d + 1, id = x });
            }
        }
        Console.Write(sb);
    }
}


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

using namespace std;

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

double dp[301][301][301];
int n;

double solve(int a, int b, int c) {
  if(a+b+c==0) return 0;
  if(dp[a][b][c]) return dp[a][b][c];
  // dp[a][b][c] = 1 + (a/n) * f(a-1, b, c) + (b/n) * f(a, b-1, c) + (c/n) * f(a, b, c-1) + (n-a-b-c)/n * dp[a][b][c]
  // dp[a][b][c] (1 - (n-a-b-c)/n) == 1 + ...
  // dp[a][b][c] (a+b+c)/n == 1 + ...
  if(a) dp[a][b][c] += a*(solve(a-1, b, c))/n;
  if(b) dp[a][b][c] += b*(solve(a+1, b-1, c))/n;
  if(c) dp[a][b][c] += c*(solve(a, b+1, c-1))/n;
  dp[a][b][c]++;
  dp[a][b][c] *= n;
  dp[a][b][c] /= (a+b+c);
  return dp[a][b][c];
}

void solve() {
  int a=0, b=0, c=0;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    int t;
    cin >> t;
    (t == 1 ? a : (t == 2 ? b : c))++;
  }
  cout << fixed << setprecision(10) << solve(a, b, c) << endl;
}

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


Measured memory_bytes: 213248
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int ppc(int s){
    int ans = 0;
    rep(i,30) if (s>>i&1) ans++;
    return s % ans;
}

int main() {
    int n; cin >> n;
    string x; cin >> x;
    vector<int> ar(n+3,0);
    repp(i,n+3,1){
        ar[i] = ar[ppc(i)] + 1;
    }
    int c = 0;
    rep(i,n) if (x[i] == '1') c++;
    vector<int> cp(n+1,0);
    vector<int> cm(n+1,0);
    cp[0] = 1 % (c+1);
    if (c-1 > 0) cm[0] = 1 % (c-1);
    rep(i,n){
        cp[i+1] = cp[i] * 2 % (c+1);
    }
    if (c-1 > 0){
        rep(i,n){
            cm[i+1] = cm[i] * 2 % (c-1);
        }
    }
    int ap = 0;
    int am = 0;
    rep(i,n){
        if (x[n-1-i] == '1'){
            ap += cp[i];
            ap %= c+1;
        }
    }
    if (c-1 > 0){
        rep(i,n){
            if (x[n-1-i] == '1'){
                am += cm[i];
                am %= c-1;
            }
        }
    }
    for (int i = 0; i < n ; i++) {
        //cout << i << " ";
        int ans = 0;
        if (x[i] == '1' && c-1 > 0){
            ans = am + c-1;
            ans -= cm[n-1-i];
            ans %= c-1; //cout << "! ";
            cout << ar[ans] + 1 << endl;
        }
        else if (x[i] == '1' && c-1 == 0){
            cout << 0 << endl;
        }
        else {
            ans = ap;
            ans += cp[n-1-i];
            ans %= c+1; //cout << "!! ";
            cout << ar[ans] + 1 << endl;
        }
    }
    //printvec(ar);
    //printvec(cp); printvec(cm); cout << c << endl;
    //cout << ap << " " << am << endl;
    //string y = "abc"; cout << y[0] << y[1] << endl;
}

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

const int N = 305, djq = 998244353;

int n, f[N][N][N], ans;
char s[N];
bool is[N][N][N], can[N][N][N];

int main()
{
	scanf("%s", s + 1); n = strlen(s + 1);
	f[0][0][0] = 1;
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= i; j++)
			for (int k = 0; j + k <= i; k++)
			{
				f[i + 1][j + 1][k] = (f[i + 1][j + 1][k] + f[i][j][k]) % djq;
				f[i + 1][j][k + s[n - j] - '0'] =
					(f[i + 1][j][k + s[n - j] - '0'] + f[i][j][k]) % djq;
			}
	is[0][0][0] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 0; j <= i; j++)
			for (int k = 0; k <= i; k++)
			{
				if (i > 1)
				{
					if (j && (s[i] == '0' || s[i - 1] == '0'))
						is[i][j][k] |= is[i - 2][j - 1][k];
					if (k && (s[i] == '1' || s[i - 1] == '1'))
						is[i][j][k] |= is[i - 2][j][k - 1];
				}
				if (s[i] == '0' && j) is[i][j][k] |= is[i - 1][j - 1][k + 1];
				if (s[i] == '1' && k) is[i][j][k] |= is[i - 1][j + 1][k - 1];
				is[i][j][k] |= is[i - 1][j][k];
			}
	for (int i = 1; i <= n; i++) is[i][0][0] = 0;
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= i; j++)
			for (int k = 0; j + k <= i; k++)
				can[i][j][k] = is[n - j][k][i - j - k] ||
					(j && can[i][j - 1][k + (s[n - j + 1] == '0')]);
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= i; j++)
			for (int k = 0; j + k <= i; k++)
				if (can[i][j][k]) ans = (ans + f[i][j][k]) % djq;
	return std::cout << ans << std::endl, 0;
}

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


 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  long long a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  long long balance=1000;
  for(int i=0;i<n-1;i++){
    long long int stock=balance/a[i];
    long long int t=0;
    balance+=max(a[i+1]-a[i],t)*stock;
  }
  cout<<balance<<endl;





}

Measured memory_bytes: 3664
n,p=map(int,input().split())
a=list(map(int,input().split()))
dp=[0]*(n+1)
if a[0]%2==1:
  dp[1]=1
elif a[0]%2==0 and p==1:
  dp[1]=0
else:
  dp[1]=2
for i in range(1,n):
  if a[i]%2==1:
    dp[i+1]=2**(i)
  else:
    dp[i+1]=2*dp[i]
print(dp[n])

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String args[]){
		Scanner cin = new Scanner(System.in);

		int a = cin.nextInt();
		int b = cin.nextInt();
		int x = cin.nextInt();
		int y = cin.nextInt();

		int len_x=Math.abs(x-a);
		int len_y=Math.abs(y-b);
		char hor,ver,hor_,ver_,hor_1,hor_2,ver_1,ver_2;
		if(a<x){
			hor_1 = 'R';
			hor_2 = 'L';
		}else{
			hor_1 = 'L';
			hor_2 = 'R';
		}

		if(b<y){
			ver_1='U';
			ver_2='D';
		}else{
			ver_1='D';
			ver_2='U';
		}

		for(int i=0;i<=3;i++){
			if(i%2==0){
				hor = hor_1;
				hor_ = hor_2;
				ver = ver_1;
				ver_ = ver_2;

			}else{
				hor = hor_2;
				hor_ = hor_1;
				ver = ver_2;
				ver_ = ver_1;
			}
			for(int o1=0;o1<i/2;o1++){
				System.out.print(ver_);
			}
			for(int j=1;j<=len_x+(i/2);j++){
				System.out.print(hor);
			}
			for(int k=1;k<=len_y+(i/2);k++){
				System.out.print(ver);
			}
			for(int o2=0;o2<i/2;o2++){
				System.out.print(hor_);
			}
		}
		System.out.println("");
	}
}


Measured memory_bytes: 26372
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MOD 998244353

int f[10010][10010];

char A[11111];
char B[11111];
int n, cnta, cntb;
int ans;

int S[11111];
int invs[11111];

int Pow(int a, int b){
	int tmp = 1;
	for(; b; b >>= 1, a = 1ll * a * a % MOD)
		(b & 1) && (tmp = 1ll * tmp * a % MOD);
	return tmp;
}

int C(int a, int b){
	return 1ll * S[a] * invs[b] % MOD * invs[a - b] % MOD;
}

int main(){
	scanf("%s %s", A, B);
	n = strlen(A);
	for(int i = 0; i < n; i++)
		if(A[i] == '1') (B[i] == '1') ? cnta++ : cntb++;
	S[0] = 1;
	for(int i = 1; i <= n; i++)
		S[i] = 1ll * S[i - 1] * i % MOD;
	invs[n] = Pow(S[n], MOD - 2);
	for(int i = n - 1; i >= 0; i--)
		invs[i] = 1ll * invs[i + 1] * (i + 1) % MOD;
	f[0][0] = 1;
	for(int i = 0; i <= cnta; i++){
		for(int j = 1; j <= cntb; j++){
			i && (f[i][j] = 1ll * f[i - 1][j] * i * j % MOD);
			f[i][j] = (f[i][j] + 1ll * f[i][j - 1] * j * j) % MOD;
		}
	}
	for(int i = 0; i <= cnta; i++)
		ans = (ans + 1ll * f[i][cntb] * C(cnta, i) % MOD * S[cnta - i] % MOD * S[cnta - i] % MOD * C(cnta + cntb, cnta - i)) % MOD;
	return !printf("%d\n", ans);
}

Measured memory_bytes: 389632
#include<stdio.h>
#include<string.h>

#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b){
  return a < b ? a : b;
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;

  scanf("%d %d", &n, &q);

  for(i = 1 ; i <= n ; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n + 1;

  while(head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }

  return 0;
}



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

typedef long long int ll;
typedef long long unsigned int ull;
typedef long double ld;
typedef vector<int> vr;
typedef pair<int, int> pr;
#define pb push_back
#define ff first
#define ss second
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
#define endl "\n" 
//cout << fixed << setprecision(2);


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE 
           freopen("input.txt", "r", stdin); 
           freopen("output.txt", "w", stdout); 
    #endif 
    ll n, d;
    cin >> n >> d;
    ll cnt = 0;
    while(n--){
        ll x, y;
        cin >> x >> y;
     //   cout << sqrt(pow(x, 2) + pow(y, 2)) << endl;
        if(pow(x, 2) + pow(y, 2) <= d * d){
            cnt++;
          }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int[][] c = new int[3][3];
        for(int i=0; i<3; i++) {
            for(int j=0; j<3; j++) {
                c[i][j] = sc.nextInt();
            }
        }

        int[] x = new int[3];
        int[] y = new int[3];
        x[0] = 0;
        for(int i=0; i<3; i++) {
            y[i] = c[0][i] - x[0];
        }
        for(int i=0; i<3; i++) {
            x[i] = c[i][0] - y[0];
        }

        for(int i=0; i<3; i++) {
            for(int j=0; j<3; j++) {
                if(c[i][j] != x[i]+y[j]) {
                    System.out.println("No");
                    System.exit(0);
                }
            }
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 35704
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

bool decline(map<ll,int> &mp , ll x){
  if(!mp.count(x))return false;
  --mp[x];
  if(mp[x] == 0) mp.erase(x);
  return true;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<ll> v(N);
  map<ll,int> mp;
  rep(i,N){
    cin >> v[i];
    ++mp[v[i]];
  }

  sort(all(v),greater<ll>());
  int ans = 0;
  ll n=1;
  while(n<=v[0]) n<<=1;
  rep(i,N){
    if(!decline(mp,v[i]))continue;
    while((n>>1)>v[i])n>>=1;
    if(decline(mp,n-v[i])) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  vector<int> s(a);
  vector<vector<int>> search(110,vector<int>(0));
  for(int i = 0;i<a;i++){
    int b;
    cin >> b;
    search.at(b).push_back(b);
  }
  int count = 0;
  for(int i = 0;i< 110;i++){
    if(search.at(i).size() != 0)
      count++;
  }
  cout << count << endl;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const unsigned long MAX = 1000000000000000000;
signed main()
{   
  gearup;
  int n; cin >> n;
  vl a(n);
  bool is_ze = false;
  rep(i,n){
    cin >> a[i];
    if(a[i] == 0)is_ze = true;
  }
  ll now = a[0];
  ll ma = a[0];
  if(is_ze){
    out(0);
    return 0;
  }
  rep1(i,n){
    now *= a[i];
    ma = max(now,ma);
    if(ma > now || now > MAX){
      out(-1);
      return 0;
    }
  }
  out(now);
}

Measured memory_bytes: 3988
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int k = scan.nextInt();
		int max = 0;

		if (k <= a) {
			max = k;
		} else if (k <= (a + b)) {
			max = a;
		} else {
//			max = a - (k - a - b);
			k = k - a;
			k = k - b;
			max = a - k;
		}

//		if (0 < max) {
			System.out.print(max);
//		} else {
//			System.out.print(0);
//		}

	}
}

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

using namespace std;
using namespace __gnu_pbds;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

template <class T> using Tree = tree <T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(bool a) {
    return a ? "T" : "F";
}

string to_string(const char* s) {
    return to_string((string) s);
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define X first
#define Y second

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

const int N = 1e5 + 10;

int n;
int l[N], r[N];
set < pair <int, int> > st[2], mem[2];

pair <int, int> get0(int p) {
    if (st[0].empty()) return make_pair(0, -1);
    auto it = --st[0].end();
    if (it->X > p) return *it;
    return make_pair(0, -1);
}

pair <int, int> get1(int p) {
    if (st[1].empty()) return make_pair(0, -1);
    auto it = st[1].begin();
    if (it->X < p) return *it;
    return make_pair(0, -1);
}

pair <int, int> (*get[2])(int) = {get0, get1};

void run() {
    scanf("%d", &n);
    
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d", l + i, r + i);
        mem[0].emplace(l[i], i);
        mem[1].emplace(r[i], i);
    }

    for (int i = 1; i <= n; ++i) debug(l[i], r[i], i);

    ll ans = 0;
    for (int _ = 0; _ < 2; ++_) {
        st[0] = mem[0];
        st[1] = mem[1];
        int nw = _;
        ll tmp = 0;
        int pos = 0;
        while (1) {
            auto p = ::get[nw](pos);
            debug(p, pos, nw, st[0], st[1]);
            if (p == make_pair(0, -1))
                break;
            st[nw].erase(p);
            st[1 - nw].erase(make_pair((nw == 0 ? r : l)[p.Y], p.Y));
            tmp += abs(p.X - pos);
            pos = p.X;
            nw = 1 - nw;
        }
        tmp += abs(pos);
        maxi(ans, tmp);
    }
    printf("%lld\n", ans);
}

int main() {
    run();

    return 0;
}


Measured memory_bytes: 19840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;
typedef pair<int,int> P;
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,m,N) for(int i=m;i<N;i++)
#define mm(n,m) memset(n,m,sizeof(n))

int main(){
  int h,w,k;
  cin>>h>>w>>k;
  char s[h][w];
  rep(i,h){
    rep(j,w){
      cin>>s[i][j];
    }
  }
  int ans[h][w];
  mm(ans,0);
  int cnt = 1;
  bool flag= false;
  bool isN = false;
  for(int i = 0; i < h; i++){
    if(!flag){
      rep(x,w){
        ans[i-1][x]=0;
      }
    }
    if(i!=0 && flag)cnt++;
    flag=false;
    if(i%2==0){
      for(int j = 0; j < w; j++){
        if(s[i][j]=='#'){
          if(flag){
            cnt++;
          }
          ans[i][j]=cnt;
          flag = true;
        }else{
          ans[i][j]=cnt;
        }
      }
    }else{
      for(int j = w-1; j >=0; j--){
        if(s[i][j]=='#'){
          if(flag){
            cnt++;
          }
          ans[i][j]=cnt;
          flag = true;
        }else{
          ans[i][j]=cnt;
        }
      }
    }
  }
  if(!flag){
    rep(x,w){
      ans[h-1][x]=0;
    }
  }
  rep(i,h){
    rep(j,w){
      if(ans[i][j]==0){
        int k = 0;
        if(i<h-1){
          while(1){
            if(i+k>=h)break;
            ans[i][j]=ans[i+k][j];
            if(ans[i][j]!=0)break;
            k++;
          }
        }
        else{
          while(1){
            if(i-k<0)break;
            ans[i][j]=ans[i-k][j];
            if(ans[i][j]!=0)break;
            k++;
          }
        }
      }
    }
  }
    rep(i,h){
    rep(j,w){
      if(ans[i][j]==0){
        int k = 0;
        if(i<h-1){
          while(1){
            if(i+k>=h)break;
            ans[i][j]=ans[i+k][j];
            if(ans[i][j]!=0)break;
            k++;
          }
        }
        else{
          while(1){
            if(i-k<0)break;
            ans[i][j]=ans[i-k][j];
            if(ans[i][j]!=0)break;
            k++;
          }
        }
      }
    }
  }

  rep(i,h){
    rep(j,w){
      cout<<ans[i][j]<<" ";
    }
    cout<<endl;
  }
}


Measured memory_bytes: 1152
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　   ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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;
}

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

    string s;
    cin >> s;
    Yes(s[2] == s[3] && s[4] == s[5]);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int main()
{
  int N, x;
  cin >> N >> x;
  int a[110];
  for (int i = 0; i < N; i++)
  {
    cin >> a[i];
  }
  
  sort(a, a + N);
  int NumChild = 0;
  for (int i = 0; i < N; i++)
  {
    if (x >= a[i])
    {
      x -= a[i];
      NumChild++;
    }
  }
  if (x > 0 && NumChild == N) 
    NumChild--;
  cout << NumChild << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define M_PI 3.141592653589793
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll r;

    cin >> r;

    cout << M_PI * 2 * r << endl;
}

Measured memory_bytes: 3784
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <cmath>
#include <complex>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair

typedef complex<double> P;
typedef long long ll;


int main(){
  int n,x,y,sx,sy;
	char c;
	int field[810][810];
	const int dx[] = {1,1,-1,-1};
	const int dy[] = {1,-1,-1,1};
	
  while(cin>>n,n!=-1){
		memset(field,0,sizeof(field));
		rep(i,n){
			cin>>c>>x>>y;
			x*=100; y*=100;
			
			if( c=='x' ){
				REP(k,x,x+101)field[y][k]=1;
			}else{
				REP(k,y,y+101)field[k][x]=1;
			}
		}

		sx = 75, sy = 25;
		int k = 0;
		for(;;){
			int tx = sx + dx[k];
			int ty = sy + dy[k];
			if( tx<0 || ty<0 || tx>=801 || ty>=801 )break;
			if( tx==75 && ty==25 ){ sx=tx; sy=ty; break; }
			sx = tx;
			sy = ty;
			//printf("%d %d  :%d\n",sx,sy,field[ty][tx]);
			if( field[ty][tx] && field[ty+1][tx] && field[ty-1][tx] ){
				if     ( k==0 ) k=3;
				else if( k==1 ) k=2;
				else if( k==2 ) k=1;
				else if( k==3 ) k=0;
			}else if( field[ty][tx] && field[ty][tx+1] && field[ty][tx-1] ){
				if     ( k==0 ) k=1;
				else if( k==1 ) k=0;
				else if( k==2 ) k=3;
				else if( k==3 ) k=2;
			}
		}
		printf("%d %d\n",sx,sy);
	}
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

bool Is_Prime(ll n){
	for(int i=2;i*i<=n;i++){
		if(n%i==0) return 0;
	}
	return n!=1;
}

int n;
vi a,b;

int main(){
	cin>>n;
	a=b=vi(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[i]=Is_Prime(a[i]);
	}
	vi dp0(n),dp1(n);
	if(b[0]) dp0[0]++;
	if(n>=2&&b[0]) dp1[1]++;
	for(int i=1;i<n;i++){
		if(b[i]){
			if(i-2>=0&&b[i-2]&&a[i-2]<a[i]) (dp0[i]+=dp1[i-1])%=mod;
			if(b[i-1]&&a[i-1]<a[i]) (dp0[i]+=dp0[i-1])%=mod;
		}
		if(b[i-1]){
			if(i-2>=0&&b[i-2]&&a[i-2]<a[i-1]) (dp1[i]+=dp0[i-2])%=mod;
			if(i-3>=0&&b[i-3]&&a[i-3]<a[i-1]) (dp1[i]+=dp1[i-2])%=mod;
		}
	}
	cout<<(dp0[n-1]+dp1[n-1])%mod<<endl;
}


Measured memory_bytes: 4464
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work
ll divisor[INIT]={0};
int main()
{
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READAR(A,N);
    FORI(i,0,N)
    {
        ll x=A[i];
        for (ll j = 2; j*j <= A[i]; j++)
        {
            ll d=0;
            while (x%j==0)
            {
                x=x/j;
                d++;
            }
            divisor[j]=max(divisor[j],d);
        }
        if(x!=1)
        divisor[x]=max(divisor[x],1LL);
    }
    ll lcm=1;
    FORI(i,2,INIT)
    {
        lcm=(lcm*power(i,divisor[i]))%MOD;
    }
    ll ans=0;
    FORI(i,0,N)
    {
        ll b=(lcm*modInverse(A[i]))%MOD;
        ans=(ans+b)%MOD;
    }
    cout<<ans<<endl;

//-----------------------------------------------------------------------------------------------------------//


    
    return 0;
}

Measured memory_bytes: 6656
#include <stdio.h>

int main(void){
  int a, b, c, i, n;

  scanf("%d%d%d", &a, &b, &c);

  n = 0;
  for (i = a; i <= b; i++) {
    if (c % i == 0) {
      n++;
    }
  }

  printf("%d\n", n);

  return 0;
}


Measured memory_bytes: 2140
#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);
  sort(a.begin(),a.end(),greater<int>());
  int Alice=0;
  int Bob=0;
  for(int i=0;i<N;i++){
    if(!(i%2)){
      Alice+=a.at(i);
    }else{
      Bob+=a.at(i);
    }
  }
  cout<<Alice-Bob<<endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"container/heap"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

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

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n,m := scanInt(), scanInt()

	h := &intHeap{}
	heap.Init(h)

	for i := 0; i < n; i++ {
		heap.Push(h,scanInt())
	}

	for i := 0; i < m; i++ {
		ma := heap.Pop(h).(int)
		heap.Push(h,ma/2)
	}

	a := *h

	ans := int64(0)
	for _, e := range a {
		ans += int64(e)
	}
	fmt.Println(ans)

}

type intHeap []int

func (a intHeap) Len() int           { return len(a) }
func (a intHeap) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a intHeap) Less(i, j int) bool { return a[i] > a[j] }

func (a *intHeap) Push(x interface{}) {
	*a = append(*a, x.(int))
}

func (a *intHeap) Pop() interface{} {
	old := *a
	n := len(old)
	x := old[n-1]
	*a = old[0:n-1]

	return x
}


Measured memory_bytes: 6528
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
int main()
{
    int a,b,sum=0;
    cin>>a>>b;
    int ara[a];
    for(int i=0;i<a;i++){
        cin>>ara[i];
        sum+=ara[i];
    }
    int count=0;
    double q=(sum*.25)/b;
    vector<int>v(ara,ara+a);
    sort(v.begin(),v.end());
    for(int i=a-1;i>=0;i--){
        if(q>v[i])break;
        else count++;
    }
    if(count>=b)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>
#include<numeric>

using namespace std;


int main()
{
  long long K, N;

  cin >> K >> N;

  vector<long long> A(N);
  vector<long long> subA(N-1);

  long long maxd = 0;

  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  for(int i=0; i<N-1; i++){
    subA[i] = A[i+1] - A[i];
    maxd = max(maxd,subA[i]);
  }

  long long ans = accumulate(subA.begin(), subA.end(),0);

  if(maxd > (K-A[N-1] + A[0])){
    cout << ans - maxd + (K-A[N-1] + A[0]) << endl;
  }
  else{
    cout << ans << endl;
  }


  return 0;
}


Measured memory_bytes: 3328
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int ans = 0;
            for (int i = 0; i < n; i++) {
                int h = in.nextInt();
                if (h >= k)
                    ans++;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 30688
using System;


namespace tst
{
    class Program
    {
        public static void Main()
        {
            string[] In= Console.ReadLine().Split(' ');
            int a = int.Parse(In[0]);
            int b = int.Parse(In[1]);
            //最小公倍数をユークリッドの互除法で求める
            //long x = a * b;//ダメ、オーバーフローしちゃう
            long x = (long)a * (long)b;
            //a>bにする
            if (a < b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            Console.WriteLine(x/b);
        }

    }
}

Measured memory_bytes: 13140