akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 3e5;
const int mod = 1e9 + 7;
char s[N];
int n, d;
ll dp[N][101][2];
int main() {
	scanf("%s", s + 1);
	cin >> d;
	n = strlen(s + 1);
	dp[0][0][1] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < d; ++j) {
			for (int k = 0; k < 10; ++k) {
				(dp[i][(j + k) % d][0] += dp[i - 1][j][0]) %= mod;
				if (s[i] - '0' == k)
					(dp[i][(j + k) % d][1] += dp[i - 1][j][1]) %= mod;
				if (s[i] - '0' > k)
					(dp[i][(j + k) % d][0] += dp[i - 1][j][1]) %= mod;
			}
		}
	}
	cout << (dp[n][0][0] + dp[n][0][1] + mod - 1) % mod;
}



Measured memory_bytes: 16640
#include<stdio.h>
#include<string.h>
char str[512];
int n;
int dp[500][500];
int solve(int a,int b){
	if(a==b)return 1;
	if(~dp[a][b])return dp[a][b];
	if(str[a]!='m'||str[b-1]!='w')return 0;
	for(int i=a+1;i<b-1;i++){
		if(str[i]=='e'){
			int v=solve(a+1,i)&solve(i+1,b-1);
			if(v)return dp[a][b]=1;
		}
	}
	return dp[a][b]=0;
}
int main(){
	scanf("%s",str);
	n=strlen(str);
	for(int i=0;i<500;i++)
		for(int j=0;j<500;j++)
			dp[i][j]=-1;
	printf("%s\n",solve(0,n)?"Cat":"Rabbit");
}

Measured memory_bytes: 1932
import sys
import numpy as np

#n=int(sys.stdin.readline())
n,r=map(int,sys.stdin.readline().split())
#a=np.array([sys.stdin.readline().split() for i in range(n)],np.int64)

if n>=10:
    print(r)
else:
    print(r+100*(10-n))


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

typedef long long ll ;
typedef deque<int> di ;
typedef deque<ll> dl ;
typedef map<string,int> dict;
typedef complex<double> comd;
typedef pair<int,int> pii;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

  template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}


double EPS = 1e-12;
double add(double a, double b){
  if(abs(a+b) < EPS* (abs(a) + abs(b))) return 0;
  return a+b;
}

struct P{
  double x,y;
  P(){}
  P(double _x,double _y):x(_x),y(_y){}
  P operator + (P p){
    return P(add(x,p.x) ,add(y,p.y));
  }
  P operator - (P p){
    return P(add(x,-p.x) ,add(y,-p.y));
  }
  P operator * (double d){
    return P(x * d,y * d);
  }
  double dot(P p){
    return add(x * p.x,y*p.y);
  }
  double det(P p){
    return add(x*p.y,-y*p.x);
  }
};

double Getslp(double x, double y,double x1, double y1){
  if(fabs(x1- x) < EPS){
    return 0.0;
  }
  return (y1-y)/(x1-x);
}

int n;
P ps[100][4];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  rep(i,n){
    cin >> ps[i][0].x >> ps[i][0].y >> ps[i][1].x >> ps[i][1].y >> ps[i][2].x >> ps[i][2].y  >> ps[i][3].x >> ps[i][3].y ;
    //if(fabs(Getslp(ps[i][0].x,ps[i][0].y,ps[i][1].x,ps[i][1].y) - Getslp(ps[i][2].x,ps[i][2].y,ps[i][2].x,ps[i][2].y)) <= EPS){
    if((ps[i][1]-ps[i][0]).det((ps[i][3]-ps[i][2])) == 0){
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3200
#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;

const double pi = 3.141592653589793;

#define xx          first
#define yy          second
#define mp          make_pair
#define intl        long long
#define filein      freopen("input.txt", "r", stdin)
#define fileout     freopen("output.txt", "w", stdout)
#define debug       cout << "YES" << endl
#define what_is(x)  cout << #x << " is " << x << endl
#define pb          push_back
#define pii         pair<int, int>

//find_by_order(int) and order_of_key(int)
//typedef tree < intl , null_type ,less<intl>,rb_tree_tag,tree_order_statistics_node_update > ordered_set;
const int M = 345678;

int ara[345][345], dp[345][345];
vector< pair<int, pair<int,int> > > vec;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //filein;
    int n;
    cin >> n;
    intl sum = 0;
    for( int i = 1; i <= n; i++ )
    {
        for( int j = 1; j <= n; j++ )
        {
            cin >> ara[i][j];
            dp[i][j] = ara[i][j];

            if( j > i )
            {
                sum += ara[i][j];
                vec.pb( mp( ara[i][j], mp(i,j) ) );
            }
        }
    }
    sort( vec.begin(), vec.end() );
    reverse( vec.begin(), vec.end()  );
    for( int i =1; i <= n; i++ )
    {
        for( int j = 1; j <= n; j++ )
        {
            for( int k = 1; k <= n; k++ )
            {
                if( dp[j][i] + dp[i][k] < dp[j][k] )
                {
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }

    for( int i = 0; i < vec.size(); i++ )
    {
        int d = vec[i].xx, x = vec[i].yy.xx, y = vec[i].yy.yy;
        int rem = 0;
        for( int j = 1; j <= n; j++ )
        {
            if( x != j && y != j )
            {
                if( ara[x][j] + ara[j][y] == d )
                {
                    rem = d;
                    break;
                }
            }
        }
        sum -= rem;
    }
    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 1784
H,W = map(int,input().split())
N = int(input())
L = list(map(int,input().split()))
M = [[] for i in range(H)]
c = 0
x = 0
y = 0
for i in range(N):
  while c < L[i]:
    if x != W:
      M[y].append(i+1)
      c += 1
      x += 1
    else:
      y += 1
      x = 1
      M[y].append(i+1)
      c += 1
  c = 0
for i in range(H):
  if i%2 != 0:
    M[i].reverse()
for j in range(H):
  print(' '.join(map(str,M[j])))


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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

char mat[305][305];
int ans[305][305];

int main() {
	int n,m,k;
	scanf("%d%d%d", &n, &m, &k);

	for(int i = 0; i < n; i++){
		scanf(" %s", mat[i]);
	}

	int cur = 0;
	for(int j = 0; j < m; j++) {
		bool found = false;
		for(int i = 0; i < n; i++) {
			if(mat[i][j] == '#') {
				found = true;
				cur++;
				break;
			}
		}

		if(!found) continue;
		bool first = true;
		for(int i = 0; i < n; i++) {
			if(mat[i][j] == '.') ans[i][j] = cur;
			else {
				if(first) ans[i][j] = cur;
				else ans[i][j] = ++cur;
				first = false;
			}
		}
	}

	for(int j = 1; j < m; j++) {
		for(int i = 0; i < n; i++)
			if(ans[i][j] == 0) ans[i][j] = ans[i][j-1]; 
	}

	for(int j = m-2; j >= 0; j--) {
		for(int i = 0; i < n; i++)
			if(ans[i][j] == 0) ans[i][j] = ans[i][j+1]; 
	}

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++)
			printf("%d%c",ans[i][j], " \n"[j==m-1]);
	}

    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main()
{
	
	int  a,b;
	char op;
	
	for(int i=1;i>0;i++){
	    scanf("%d %c %d", &a,&op,&b);
	if(op=='+'){
	    printf("%d\n",a+b);
	}else if(op=='-'){
	     printf("%d\n",a-b);
	}else if(op=='*'){
	    printf("%d\n",a*b);
	}else if(op=='/'){
	    printf("%d\n",a/b);
	}else if(op=='?'){
	    break;
	}	}

    return 0;
}



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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 3030;



int n, m;
string s;
int a[maxn];
int b[maxn];
ll dp[maxn][maxn];//# ways to fill first i elems, holding j 1's



void add(ll& x, ll y) {
    x %= mod;
    y %= mod;
    x += y;
    x %= mod;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n>>m;
    cin>>s;
    for (int i=0; i<n; i++) {
	a[i]=(s[i]-'0');
	b[i]=i+1;
    }

    for (int i=0; i<m; i++) {
	int l,r; cin>>l>>r;
	--l; --r;
	b[l]=max(b[l],r+1);
    }

    for (int i=1; i<n; i++) {
	b[i]=max(b[i],b[i-1]);
    }

    dp[0][0]=1;
    for (int i=0, j=0; i<n; i++) {
	int ones = 0;
	while (j<b[i]) ones+=a[j++];

	for (int x=0; x<=n; x++) {
	    if (dp[i][x] == 0) continue;
	    int cur=x+ones;

	    //put 1 at ith index
	    if (cur>0) {
		add(dp[i+1][cur-1], dp[i][x]);
	    }

	    // put 0 at ith index
	    if (j-i != cur) {
		add(dp[i+1][cur], dp[i][x]);
	    }
	}
    }

    ll ans = dp[n][0];
    ans %= mod;
    ans += mod;
    ans %= mod;
    cout<<ans<<endl;
  

    return 0;
}


Measured memory_bytes: 70272
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();

		if (a > b) {
			System.out.println("a > b");
		}
		if (a < b) {
			System.out.println("a < b");
		} if (a==b) {
			System.out.println("a == b");

		}

	}

}



Measured memory_bytes: 26316
# ABC 70 B

def resolve():
    a, b, c, d = map(int, input().split())
    ans = 0
    if a <= c and b <= d:
        ans = b - c
    elif a <= c and d <= b:
        ans = d - c
    elif c <= a and b <= d:
        ans = b - a
    else:
        ans = d - a

    if ans < 0:
        print(0)
    else:
        print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3060
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);
		String str=s.next();
		int a=s.nextInt();
		int ans=0;
		for(int i=0;i<a;i++){
			boolean ok=false;
			String val=s.next();
			for(int j=0;j<val.length()+str.length();j++){
				boolean now=true;
				for(int k=0;k<str.length();k++){
					if(val.charAt((j+k)%val.length())!=str.charAt(k))
						now=false;
				}
				if(now)ok=true;
			}
			if(ok)ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

struct XORShift {
    unsigned int x, y, z, w, t;

    XORShift(int seed) {
        mt19937 rnd(seed);
        x = rnd();
        y = rnd();
        z = rnd();
        w = rnd();
        t = 1;
    }

    int rand() {
        t = x ^ (x << 11);
        x = y;
        y = z;
        z = w;
        w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
        return w & 0x7fffffff;
    }
} rnd(rand());

const int N = 26;
const int D = 365;
const double TIMELIMIT = 1.9;
int d;
int c[N];
int s[D][N];

struct STATE {
    int contests[D];
    /*
    int pre[D][N];
    int nxt[D][N];
    */
    int score;
};

STATE state;

void init(STATE& state) {
    state.score = 0;
    int last[N] = {};
    rep(i, D) {
        int mx = -INF;
        int select;
        rep(j, N) {
            if(s[i][j] > mx){
                mx = s[i][j];
                select = j;
            }
        }
        state.contests[i] = select;
        state.score += mx;
        last[select] = i + 1;
        rep(j, N) {
            state.score -= c[j] * (i + 1 - last[j]);
        }
    }
    /*
    fill(state.pre, state.pre + D, 0);
    fill(state.nxt, state.nxt + D, D + 1);
    fill(last, last + N, 0);
    rep(i, D) {
        rep(j, N) {
            state.pre[i][j] = last[j];
        }
        last[state.contests[i]] = i + 1;
    }
    fill(last, last + N, D + 1);
    rep(i, D) {
        rep(j, N) {
            state.pre[D - 1 - i][j] = last[j];
        }
        last[state.contests[D - 1 - i]] = D - i;
    }
    */
}

void SA() {
    init(state);
    double starttemp = 10000.0, endtemp = 1.0;
    int startclock = clock();
    while (true) {
        int nowclock = clock();
        if (nowclock - startclock > TIMELIMIT * CLOCKS_PER_SEC) break;
        STATE newstate = state;
        int d = rnd.rand() % D, cc = rnd.rand() % N;
        newstate.score = 0;
        newstate.contests[d] = cc;
        int last[N] = {};
        rep(i, D) {
            newstate.score += s[i][newstate.contests[i]];
            last[newstate.contests[i]] = i + 1;
            rep(j, N) {
                newstate.score -= c[j] * (i + 1 - last[j]);
            }
        }
        double temp = starttemp + (endtemp - starttemp) *
                                      (nowclock - startclock) /
                                      (TIMELIMIT * CLOCKS_PER_SEC);
        if (exp((newstate.score - state.score) / temp) >
            (rnd.rand() % INF) / (double)INF) {
            state = newstate;
        }
    }
}

signed main() {
    cin >> d;
    rep(i, 26) {
        cin >> c[i];
    }
    rep(i, 365) {
        rep(j, 26) {
            cin >> s[i][j];
        }
    }
    SA();
    rep(i, 365) {
        cout << state.contests[i] + 1 << endl;
    }
    // cout << state.score << endl;
    return 0;
}

Measured memory_bytes: 4324
#include <iostream>

using namespace std;
const int MAXN = 10010;
const int MAXH = 110;
const int MAXW = 110;
int h, w, n;
int a[MAXN];
int squares[MAXH][MAXW];

void solve() {
  int color = 0;
  for (int i=0;i<h;i++) {
    int cur = (i % 2 == 0) ? 0 : w-1;
    int end = (i % 2 == 0) ? w : -1;
    int step = (i % 2 == 0) ? 1 : -1;
    while (cur != end) {
      squares[i][cur] = color + 1;
      a[color]--;
      cur += step;
      if (a[color] == 0) {
        color++;
      }
    }
  }
  for (int i=0;i<h;i++) {
    for (int j=0;j<w;j++) {
      if (j != 0) {
        cout << " ";
      }
      cout << squares[i][j];
    }
    cout << endl;
  }
}

int main() {
  cin >> h >> w;
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> a[i];
  }
  solve();
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)
#define ll long long
const ll mod=1e9+7;


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

  vector<int> c(n,0);
  int g1=-1,g2=1<<20,x,y;

  r(i,m){
    cin>>x>>y;
    g1=max(g1,x);
    g2=min(g2,y);

  }

  int cnt=0;
  //cout<<g1<<" "<<g2<<endl;

  for(int i=1;i<=n;i++){
    if(g1<=i&&i<=g2)cnt++;
  }
  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>                                             
#include <cstdio>                                               
using namespace std;                                            
                                                                
int main(void) {                                                
  int a, b;                                                     
  while (scanf("%d %d",&a,&b) != EOF) {                         
    cout << a+b << endl;                                        
  }                                                             
}                    

Measured memory_bytes: 3116
#include<stdio.h>
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main()
{
  int d,i=2,j=3,N=IN();long a=1l*N*(N+1)-1;
  while(i*i<=N)
  {
    d=N/i;a+=i*(1l*d*d-i*i+d);i+=2;
    if(j*j>N)break;
    d=N/j;a+=j*(1l*d*d-j*j+d);j+=2;
  }
  return printf("%ld\n",a),0;
}

Measured memory_bytes: 1604
import math

output = []

while True:
    depth, width, height = [int(item) for item in input().split(" ")]

    if depth == 0 and width == 0 and height == 0:
        break

    cheeseRadius = math.sqrt((width / 2)**2 + (height / 2)**2)

    inputCount = int(input())

    for lp in range(inputCount):
        entranceRadius = int(input())

        if cheeseRadius < entranceRadius:
            output.append("OK")
        else:
            output.append("NA")

print("\n".join(output))



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

int main() {
  string S; cin >> S;
  sort(S.begin(), S.end());
  
  if(S[0]==S[1] && S[1]!=S[2] && S[2]==S[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807;


//B
int main() {
	ll N;
	scanf("%lld", &N);
	vector<ll> d(N, 0);

	for (ll i = 0; i < N; i++) {
		scanf("%lld", &d[i]);
	}

	ll result = 0;

	for (ll i = 0; i < N; i++) {
		for (ll j = i + 1; j < N; j++) {
			result += d[i] * d[j];
		}
	}

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

}


//A
/*
int main() {
	ll A;
	scanf("%lld", &A);
	ll B;
	scanf("%lld", &B);

	ll result = 0;

	result = max(0LL, A - B * 2);

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

	return 0;
}
*/


Measured memory_bytes: 256
import bisect
n = int(input())
a = []
b = []

for i in range(n):
    m, p = map(int, input().split())
    a.append(m)
    b.append(p)
a.sort()
b.sort()
middle = n // 2
if n % 2:
    print(b[middle] - a[middle] + 1)
else: 
    a_m = ( a[middle] + a[middle - 1] ) / 2
    b_m = ( b[middle] + b[middle - 1] ) / 2
    print(int((b_m - a_m) * 2 + 1))






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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = 998244353;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  string S; cin >> S;
  ll N = S.size();
  ll K; cin >> K; K = min(K, N);

  vector<ll> pos; ll now = 0;
  rep(i,N) {
    if (S[i]=='1') now++;
    else { pos.push_back(now); now = 0; }
  }
  pos.push_back(now);
  vector<ll> spos = pos; repr(i,1,spos.size()) spos[i] += spos[i-1];
  // debug(all(rpos));

  ll A = pos.size(), M = *spos.rbegin();
  ll dp[N+1][M+1] = {}; dp[0][0] = 1;
  rep(i,A) {
    ll imosx[N+1][M+1] = {}, imosxy[N+1][M+1] = {};
    ll fj = i==0 ? 0 : spos[i-1];
    rep(j,N+1) repr(k,fj,M+1) {
      imosx[j][k] += dp[j][k];
      if (k+pos[i]<M+1) imosx[j][k+pos[i]] -= dp[j][k];
      if (k+pos[i]<M+1) imosxy[j][k+pos[i]] += dp[j][k];
    }
    rep(j,N+1) rep(k,M+1) {
      if (k>0) imosx[j][k] += imosx[j][k-1];
      if (j>0&&k>0) imosxy[j][k] += imosxy[j-1][k-1];
      dp[j][k] = (imosx[j][k]+imosxy[j][k]) % MOD;
    }
    // rep(j,N+1) debug(imosx[j],imosx[j]+(M+1)); cout << endl;
    // rep(j,N+1) debug(imosxy[j],imosxy[j]+(M+1)); cout << "------------" << endl;
  }
  // rep(i,N+1) debug(dp[i],dp[i]+(M+1));

  ll result = 0; rep(i,K+1) result = (result+dp[i][M]) % MOD;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 5716
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int gcd(int a, int b) {
  if (a < b) {
    int t = a;
    a = b;
    b = t;
  }

  while (b > 0) {
    int t = b;
    b = a % b;
    a = t;
  }

  return a;
}

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

  vector<int> v;
  for (int i = 0; i < n+1; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }

  sort(v.begin(), v.end(), less<int>());

  int former = v[1];
  int g = v[1]-v[0];
  for (int i = 2; i < n+1; i++) {
    int d = v[i]-former;
    g = gcd(g, d);
    former = v[i];
  }

  cout << g << endl;

  return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	string s;
	cin >> s;
	int N = s.size();
	int a = 0;
	int z = 0;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'A') {
			a = i;
			break;
		}
	}
	for (int i = N - 1; i >= 0; i--) {
		if (s[i] == 'Z') {
			z = i;
			break;
		}
	}
	cout << z - a + 1 << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    int ac=0,wa=0,tle=0,re=0;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        if(s=="AC")
            ac++;
        else if(s=="WA")
            wa++;
        else if(s=="TLE")
            tle++;
        else if(s=="RE")
            re++;
    }
    cout<<"AC"<<" x "<<ac<<endl;
    cout<<"WA"<<" x "<<wa<<endl;
    cout<<"TLE"<<" x "<<tle<<endl;
    cout<<"RE"<<" x "<<re<<endl;
}


Measured memory_bytes: 3624
#include <cstdio>

int
main(int argc, const char *argv[])
{
    int H, W;
    while (scanf("%d%d", &H, &W) != EOF) {
        if (!H && !W) break;
        for (int i = 0; i != H; ++i) {
            for (int j = 0; j != W; ++j) {
                if ((i + j) & 1) putchar('.');
                else putchar('#');
            }
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 2564
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << setw(10) << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

bool can_eternal(ll A, ll B, ll C, ll D){
    // 最初から在庫足りてない
    if(A<B){
        return false;
    }

    // 補充より消費が速い
    if(B>D){
        return false;
    }

    // 以降、A>=B, B<=D

    // AからBをギリギリまで引いた状態
    ll start = A % B;
    ll step = D-B;

    // 次の飲みで終わる
    if(start>C){
        return false;
    }

    if(step==0){
        if(start<=C){
            return true;
        }else{
            return false;
        }
    }

    // 危険ゾーンがない場合とは
    if(B-C<=1){
        return true;
    }

    if(step==1){
        return false;
    }

    ll left = C+1;
    ll right = B; // 含まない

    // 幅が広いので踏む
    if(right - left >= step){
        return false;
    }

    step = gcd(step, B);

    // 幅が広くなくても踏むときは踏む
    // leftの直前まで移動
    ll diff = left - start;
    ll n = diff / step;
    n -= 3; // ちょっと引く・・・
    if(n>0){
        start += step * n;
    }

    // 危険ゾーンの直前まで来た
    while(start < right){
        start += step;
        if(left <= start && start < right){
            return false;
        }
    }

    return true;
}

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

    // input
    ll T;
    cin >> T;

    FOR(i, 0, T){
        ll A, B, C, D;
        cin >> A >> B >> C >> D;
        
        bool can = can_eternal(A, B, C, D);
        if(can){
            p_yes();
        }else{
            p_no();
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
class Array
	def accum
		inject([0]){|a, x| a + [a[-1] + x]}[1..-1]
	end
end

module Memoizable
	def memoize(name)
		original = "__original_#{name}__"
		([Class, Module].include?(self.class) ? self : self.class).class_eval {
			alias_method(original, name)
			private(original)
			cache = {}
			define_method(name){|*args|
				cache[args] ||= send(original, *args)
			}
		}
	end 
end

include Memoizable

m, n = gets.split.map &:to_i

$manju = (1..m).map { gets.to_i }
$manju.sort!.reverse!
$accum = [0] + $manju.accum

$box = (1..n).map { gets.split.map &:to_i }
$box.sort_by!{|capacity, price| -capacity / price.to_f}

def f(i, j)
	return 0 if i >= $manju.size || j >= $box.size

	capacity, price = $box[j]
	return 0 if $manju[i] <= price / capacity.to_f

	n = [capacity, $manju.size - i].min
	used = $accum[i+n] - $accum[i] - price + f(i+n, j+1)
	unused = f(i, j+1)

	used > unused ? used : unused
end

memoize :f

p f(0, 0)

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


int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    LL n, x;
    cin >> n >> x;
    LL addon = x * n;
    vector<LL> loc(n);
    for(LL i = 0; i < n; i++){
        cin >> loc[i];
    }
    reverse(loc.begin(), loc.end());

    vector<LL> psums(n+1);
    psums[0] = 0;
    for(int i = 0; i < n; i++){
        psums[i+1] = psums[i] + loc[i];
    }
    vector<LL> arr;
    for(LL i = 0; i < n; i++){
        if(i == 0){
            arr.push_back(5);
        } else {
            arr.push_back(3 + 2 * i);
        }
    }
    LL best = 1000000000000000000LL;
    for(LL d = 1; d <= n; d++){
        LL ans = x * d;
        for(LL v = 0; v * d < n; v++){
            LL csum = psums[min(n, (v+1) * d)] - psums[v * d];
            if(arr[v] > best / csum){
                ans = best;
                break;
            }
            ans += arr[v] * csum;
            if(ans > best) break;
        }
        best = min(ans, best);
    }
    cout << best + addon << endl;
    return 0;
}

Measured memory_bytes: 5620
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	A, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	B, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	C, _ := strconv.Atoi(sc.Text())

	l := make([]int, N)
	for i := 0; i < N; i++ {
		sc.Scan()
		l[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Ints(l)

	minMp := math.MaxInt32
	for i := 0; float64(i) < math.Pow(4, float64(N)); i++ {
		mp := 0
		lengths := make([]int, 4)
		for j, lItem := range l {
			target := (i & (3 << uint(j*2))) >> uint(j*2)
			if target != 3 && lengths[target] != 0 {
				mp += 10
			}
			lengths[target] += lItem
		}

		out := false
		for j := 0; j < 3; j++ {
			if lengths[j] == 0 {
				out = true
			}
		}

		if out {
			continue
		}

		mp += abs(A - lengths[0])
		mp += abs(B - lengths[1])
		mp += abs(C - lengths[2])
		if minMp > mp {
			minMp = mp
		}
	}
	fmt.Println(minMp)
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
} 

int main(){
    ll n;cin >> n;
    vl a(n);rep(i,n)cin >> a[i];
    ll l;cin >> l;
    vvl v(21,vl(n));
    rep(i,n){
        auto itr=upper_bound(all(a),a[i]+l);
        itr--;
        v[0][i]=itr-a.begin();
        if(i==n-1)v[0][i]=inf;
    }
    rep(j,20){
        rep(i,n){
            if(v[j][i]==inf)v[j+1][i]=inf;
            else v[j+1][i]=v[j][v[j][i]];
        }
    }
    /*rep(j,20){
        rep(i,n){
            cout << v[j][i] <<" ";
        }
        cout << endl;
    }*/
    //exit(0);
    ll q;cin >> q;
    while(q--){
        ll a,b;cin >> a >> b;a--;b--;
        if(a>b)swap(a,b);
        ll ng=0,ok=100000;
        while(abs(ok-ng)>1){
            ll mid=(ok+ng)/2;
            ll t=a;
            rep(i,20){
                if(t==inf)break;
                if(mid&(1<<i)){
                    t=v[i][t];
                }
            }
            if(t>=b)ok=mid;
            else ng=mid;
        }
        cout << ok <<endl;
    }
}

Measured memory_bytes: 21196
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;
int n,d;
int x[100001];
int ans=0;
int main(){
  cin >> n;
  for(int i=0;i<n;i++)cin >> x[i];
  for(int i=0;i<n;i++){
    while(x[i]>1 && x[i]%2==0){x[i]/=2;ans++;}
  }
  cout << ans << endl;
  return 0;
}


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

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


const int MOD = 1000000007;

ll C[200010];
ll D[200010] = {};

int b[110];
int a[110];

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

	bool ans = true;

	for (int i = 0; i < N; i++)
	{
		cin >> b[i];
		if (b[i] > i + 1)
		{
			ans = false;
		}
	}

	if (ans == false)
	{
		cout << -1 << endl;
		return 0;
	}

	int n = N;
	if (ans == true)
	{
		
		//まず今N個要素あるでどんどん削ってく
		while (n >= 1)
		{
			for (int j = n - 1; j >= 0; j--)
			{
				//j + 1が人間の数え方でjはパソコンの数え方
				if (j + 1 == b[j])
				{
					a[n - 1] = b[j];

					for (int k = j; k < n - 1; k++)
					{
						b[k] = b[k + 1];
//						cout << k << endl;
					}

					//後処理
					n--;
					j = -1;
				}
			}
		}
		for (int i = 0; i < N; i++)
		{
			cout << a[i] << endl;
		}
		return 0;
	}
}

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

int n,a[25],ans;
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++){
		int tag = 1;
		for(int j = 1; j < i; j++)
			if(a[j]>a[i]) tag = 0;
		if(tag) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    string s;
    int count = 0;
    cin >> s;
    for (int tmp = 0; tmp < (int)s.size();){
        if (s[tmp++] == '1'){
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

bool compare_by_b(pair<ip, bool> a, pair<ip, bool> b) {
    if(a.first.second != b.first.second){
        return a.first.second < b.first.second;
    }else{
        return a.first.first < b.first.first;
    }
}

int main(){
	int n;
	cin>>n;
	vector<pair<ip,bool>> x(n);
	rep(i,n){
		int a;
		cin>>a;
		x[i].first.first = a;
		x[i].first.second = i;
		x[i].second = false;
	}
	sort(all(x));
	int left = x[n/2-1].first.first;
	int right = x[n/2].first.first;
	for(int i = 0; i<n/2; i++)x[i].second = true;
	sort(all(x),compare_by_b);
	rep(i,n)cout<<((x[i].second)?right:left)<<endl;
	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;

const int N = 2e5 + 123, MOD = 1e9 + 7;
int n, c[N], a[N], m, dp[N], s[N];

void add(int & x, int y) {
	x += y;
	if (x >= MOD) {
		x -= MOD;
	}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> c[i];
		if (c[i] != c[i - 1]) {
			a[++m] = c[i];
		}
	}
	dp[0] = 1;
	for (int i = 1; i <= m; i++) {
		dp[i] = dp[i - 1];
		add(dp[i], s[a[i]]);
		add(s[a[i]], dp[i - 1]);
	}
	cout << dp[m];
}


Measured memory_bytes: 3456
#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 n;
  cin >> n;
  vector<int> a(n+1);
  vector<int> b(n);
  for (int i = 0; i < n+1; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  ll res = 0;
  for (int i = 0; i < n; i++) {
    res += min(a[i], b[i]);
    b[i] = max(0, b[i] - a[i]);
    res += max(0, min(a[i+1], b[i]));
    a[i+1] = max(0, a[i+1] - b[i]);
  }

  cout << res << endl;
}


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

int main() {

  
  long int H, W;
  cin >> H >> W;

  if(H != 1 && W != 1){
  cout << (H * W + 1)  / 2 << endl; // 1つめである25を出力
  }
  else {
    cout << 1 << endl;
  }
}


Measured memory_bytes: 256
# coding: utf-8
N = int(raw_input())
A = map(int, raw_input().split(' '))


def rcount(array):
    if len(array) == 0:
        return 0
    top = array[0]
    length = len(array)

    base = 3**(length - 1)
    if top % 2:
        return 2 * base + rcount(array[1:])
    else:
        return base + 2 * rcount(array[1:])


print rcount(A)


Measured memory_bytes: 2568
#include<iostream>
#include<algorithm>
using namespace std;
int a, b, c, k;
int main()
{
  cin >> a >> b >> c >> k;
  int d = max({a, b, c});
  int e = a + b + c - d;
  for (int i = 0; i < k; i++)
  {
    d *= 2;
    }
    cout << d + e << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

map<ll, int> primeFactor(ll num){
	map<ll, int> ret;
	for(ll i = 2; i * i <= num; i ++){
		while(num%i == 0){
			ret[i] ++;
			num /= i;
		}
	}
	if(num != 1)ret[num] = 1;
	return ret;
}
int main(){

    ll a, b;
    cin >> a >> b;
    map<ll, int> apf = primeFactor(a), bpf = primeFactor(b);
    ll cnt = 0;
    auto aitr = apf.begin(), bitr = bpf.begin();
    while(aitr != apf.end() && bitr != bpf.end()){
        if(aitr->first == bitr->first){
            //cout << aitr->first << endl;
            cnt++;
            aitr++;
            bitr++;
        }
        else if(aitr->first < bitr->first){
            aitr++;
        }
        else{
            bitr++;
        }
    }
    cout << cnt + 1 << endl;

    return 0;
}

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

vector<int> a(101, 0);

int num(int n)
{
  n--;
  int ret = 0;
  for (int i=0; i<(int)(a.size()); i++) {
    if (a[i]>=n) ret++;
  }
  return ret;
}

int main()
{
  ll N;
  scanf("%lld",&N);

  for (int i=2; i<=N; i++) {
    int t = i;
    for (int j=2; j<=t; j++) {
      while (t%j == 0) {
        a[j]++;
        t /= j;
      }
    }
  }

  int ans = 0;
  ans += num(75);
  ans += num(25) * (num(3)-1);
  ans += num(15) * (num(5)-1);
  ans += num(5) * (num(5)-1) * (num(3)-2) / 2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
xlist = []
ulist = []
for _ in range(N):
    x, u = map(str, input().split())
    xlist.append(float(x))
    ulist.append(u)

ans = 0
for i in range(N):
    if ulist[i] == 'JPY':
        ans += xlist[i]
    else:
        ans += 380000.0 * xlist[i]

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9 + 7;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int main() {
    string s; cin >> s;
    int c = 0;
    rep(i, s.size()) {
        if (s[i] == 'x') c++;
    }
    if (c >= 8) cout << "NO" << endl;
    else cout << "YES" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
 
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
 
ll M = pow(10,18);
 
unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
 
int main(int argc, const char * argv[]) {
    unsigned long long N; cin >> N;
    vector<unsigned long long> A(N);
    for(unsigned long long i=0;i<N;i++){
        cin >> A[i];
        if(A[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    
    unsigned long long sum = 1;
    for(unsigned long long i=0;i<N;i++){
        if(M/sum < A[i]){
            cout << -1 << endl;
            return 0;
        }
        sum *= A[i];
    }
  
    if(M < sum){
        cout << -1 << endl;
        return 0;
    }

    
    cout << sum << endl;
    
}



Measured memory_bytes: 4048
n = int(input())
h_list = list(map(int,input().split()))
 
count_max = 0
count = 0
for i in range(n-1):
    if h_list[i] >= h_list[i+1]:
        count += 1
    else:
        count_max = max(count,count_max)
        count = 0
count_max = max(count,count_max)

 
print(count_max)

Measured memory_bytes: 14252
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		long n = Long.parseLong(sc.next());
		long a = Long.parseLong(sc.next());
		long b = Long.parseLong(sc.next());
		System.out.println(n % (a + b) <= a ? n / (a + b) * a + n % (a + b) : n / (a + b) * a + a);
	}
}


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

int main(){
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k<a){
    cout<<k<<endl;
  }else if(k<a+b){
    cout<<a<<endl;
  }else{
    ll d = 2*a + b -k;
    cout<<d<<endl;
  }
  return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll a, b;
  cin >> a >> b;
  ll ans = a + b;
  if (ans >= 10) {
    cout << "error" << endl;
  } else
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.rbegin(), A.rend());
  ll ans = 0;
  ll cur = A[0];
  ll cnt = 1;
  ll ref = 0;
  for (int i = 1; i < N; i++) {
    if (cnt < 2) {
      ans += cur;
    } else {
      ref++;
      cur = A[ref];
      ans += cur;
      cnt = 0;
    }
    cnt++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a;
  int old_a = 0;
  int cnt = 0;
  cin >> n;
  REP(i,n){
    cin >> a;
    if(a==old_a){
      cnt++;
      old_a = 0;
    }else{
      old_a = a;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,x,y) for(ll i=x; i<=y; i++)
#define BIT(t) ((long long 1) << t)
#define PER(i,y,x) for(ll i=y; i>=x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
using namespace std;
typedef long long ll;

ll const MAX = 2e5 + 5;
map<pair<ll,ll>, ll> mp;
vvll g(MAX);
vll anss(MAX, 0);
vll parent(MAX, 0);
vll mx(MAX, 0);

ll f(ll cur, ll m){
	if(mp.count({cur, m}) > 0){
		return mp[{cur, m}];
	}
	ll ans = 1;
	for(auto ch:g[cur]){
		if(ch == parent[cur]) continue;
		if(ch < m){
			ans += f(ch, m);
		}
	}
	return mp[{cur, m}] = ans;
}

void find_parent(ll cur){
	for(auto ch:g[cur]){
		if(ch == parent[cur]) continue;
		parent[ch] = cur;
		mx[ch] = max(mx[cur], cur);
		find_parent(ch);
	}
}

int main(){
	ll n;
	cin >> n;
	REP(i,1,n-1){
		ll a,b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	parent[1] = 0;
	queue<ll> qu;
	qu.push(1);
	find_parent(1);
	while(!qu.empty()){
		ll cur = qu.front();
		qu.pop();
		if(cur > mx[parent[cur]]){
			anss[cur] = anss[parent[cur]] + f(cur, mx[cur]);
		}else{
			anss[cur] = anss[parent[cur]] - f(cur, mx[parent[cur]]) + f(cur, mx[cur]);
		}

		for(auto ch:g[cur]){
			if(ch==parent[cur]) continue;
			qu.push(ch);
		}
	}
	REP(i,2,n){
		cout << anss[i] - 1<< endl;
	}
}

Measured memory_bytes: 51584
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec a(N); cin >> a;
    FOR(i, 1, N) a[i] += a[i - 1];
    int ans = INF;
    REP(i, N - 1) Min(ans, llabs(a[i] - (a[N - 1] - a[i])));
    Out(ans);

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int N, counter, sum;
  int j;
  bool ch;
  cin >> N;
  counter = N;
  sum = 0;
  ch = true;
  for(int i = 0;i<6;i++){
    counter/=10;
    if(counter ==0 &&ch)j=i+1,ch=false;
  }

  // cout << j << endl;
  ch = true;
  for(int i = 0;i<j;i++){
    if(N == pow(10,j-1) && j != 1){
      sum = 10;
      break;
    }
    sum+=N%10;
    N/=10;
  }
  cout << sum << endl;
}


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

using ll = long long;

int main() {
    int m, d; cin >> m >> d;
    int ans = 0;
    for(int i = 1; i <= m; ++i) {
        for(int j = 20; j <= d; ++j) {
            const int d1 = j / 10, d2 = j % 10;
            ans += d2 >= 2 && d1 * d2 == i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
N, M = list(map(int, input().split()))
# roads = [set(list(map(int, input().split()))) for _ in range(M)]

res = {}
for i in range(1, N+1):
    res[i] = 0

# for x, y in roads:
#     res[x] += 1
#     res[y] += 1


for i in range(M):
    x, y = list(map(int, input().split()))
    res[x] += 1
    res[y] += 1

for val in res.values():
    print(val)

Measured memory_bytes: 3060
process.stdin.resume();
var x = '';
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function (input) {
    x += input;
});

process.stdin.on('end', function () {
    var xArray = x.split('\n');
    var output = [];
    for(var i = 0; i < xArray.length; i++) {
        if(0 != xArray[i]) {
            output.push('Case ' + (i + 1) + ': ' + xArray[i]);
        }
    }
    console.log(output.join('\n'));
});

Measured memory_bytes: 19484