akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int dp[100005],used[100005] = {0};
int n,m,trace = 0;
//int value[100005];
//int weight[100005];
vector <int> v[100005];
ll solve(int i)
{
   if(used[i])
    return 0;
   used[i] = 1;
    int sum = 0,mins =0;
    for(int j= 0;j<v[i].size();j++)
    {
     //   cout<<v[i][j]<<" ";
        solve(v[i][j]);
        dp[i] =  max(1+dp[v[i][j]],dp[i]);
    }
    //cout<<endl<<sum;
    return dp[i];
}
int main()
{
   // int t;
    cin>>n>>m;
    int u,w;
    for(int i=1;i<=m;i++)
    {
        cin>>u>>w;
        v[u].push_back(w);
    }
    int maxs = 0;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=n;i++){
        solve(i);
    maxs = max(dp[i],maxs);
    }
    cout<<maxs+1;
   /* for( int i = 1; i <= n ; i++ )
    {

    for(int j=1 ; j <= 3 ; j++ )
    {
        cout<<dp[i][j]<<" ";
    }
    cout<<endl;
    }*/
    /*int maxs = 0,val;
    for(int j = 1 ; j <= 3 ; j++ )
    {
        if(maxs<a[n][j]){
            maxs  = a[n][j];
            val  =j;
        }
    }
    trace[val]++;
    dp[n] = maxs;
    for(int i = n-1;i>=1;i--){
    maxs = 0;
    for(int j = 1 ; j <= 3 ; j++ )
    {
        if(maxs<a[i][j]){
            maxs  = a[i][j];
            val= j;
        }
    }
    trace[val]++;
   // cout<<"trace of current "<<val<<" is : "<<trace[val];
    if(trace[val] < 2 )
    dp[i] = maxs + dp[i+1];
    else
    {
        int out = val;
        trace[val] = 0;
        maxs = 0;
        for(int j=1;j<=3;j++)
        {
            if(out!=j && maxs<a[i][j])
            {
                maxs = a[i][j];
                val  = j;
     //           cout<<"in here ";
            }
        }
        trace[val]++;
        dp[i] = maxs + dp[i+1];
   //     cout<<endl<<"current maxs is "<<maxs;
    }
    cout<<dp[i]<<" ";
    }
    /*
    for(int i=1;i<=n;i++)
    {
        cout<<dp[i]<<" ";
    }
    cout<<endl;*/
    //cout<<solve(1);
   // cout<<dp[1];
}


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



int main() {
	
	
	int n; cin >> n;
	
	vector<int> a(n); rep(i,n) cin >> a[i];
	
	
	ll ans = 0;
	int min = 1000000001;

	rep(i,n-1){
		if(a[i+1] < a[i]){
			ans += a[i] - a[i+1];
			a[i+1] = a[i];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<double,double> mp;
#define inf 1e9


int main(){
	int n;
	cin>>n;
	vector<double> a(n+1,0);
	for(int i=1;i<=n;i++)cin>>a[i];
	vector<double> res(n+1);
	res[0] = 0;
	for(int i=1;i<=n;i++){
	    	double ma = a[i] ;
		for(int j=i-1;j>=0;j--){
			ma = max(ma, res[j] + sqrt( (a[i]+a[j])*(a[i]+a[j]) - (a[i]-a[j])*(a[i]-a[j]) ) );
		}
		res[i] = ma;
	}

	double ans = 0;
	for(int i=0 ; i<=n; i++){
	    ans= max(ans,res[i]+a[i]) ;
	}
	printf("%0.10lf\n",ans);
	return 0;	
}




Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define ll              long long
#define dd              double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define vi              vector<int>
#define vll             vector<long long>
#define vdd             vector<double>
#define vpii            vector<pair<int,int>>
#define vpll            vector<pair<long long,long long>>
#define vvi             vector<vector<int>>
#define vvll            vector<vector<long long>>
#define mii             map<int,int>
#define mll             map<long long,long long>
#define umii            unordered_map<int,int>
#define umll            unordered_map<long long,long long>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep2(i,a,b)     for(int i=a;i<b;i++)
#define rev(i,n)        for(int i=n;i>=0;i--)
#define rev2(i,a,b)     for(int i=a;i>=b;i--)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             9e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define wh(x)           int x; cin>>x; while(x--)
#define fio             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl            '\n'
#define all(x)          x.begin(),x.end()
#define d0(x)           cout <<x<<" "
#define d1(x)           cout <<x<<endl
#define d2(x,y)         cout <<x<<" "<<y<<endl
#define d3(x,y,z)       cout <<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w)     cout <<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define read2(x,y)      cin>>x>>y
#define read3(x,y,z)    cin>>x>>y>>z
#define read4(x,y,z,w)  cin>>x>>y>>z>>w
#define read5(x,y,z,w,a)cin>>x>>y>>z>>w>>a
#define sz(a)           (int)a.size()
#define deb(x)          cout <<#x << " is "<<x<<endl;
const ll mod=1e9+7;
const double PI = 3.14159265359;
const ll MOD=998244353;
void i_o()
{
   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
}

ll help(vll& A){
  ll n=A.size()-1;
 // ll tot=0;
  if(n==0){
    if(A[0]==1){
      return 1;
    }
    return -1;
  }
  if(A[0]!=0) return -1;
  //d1("OK");
  ll x=1,i=0,tot=0,ma=LLONG_MAX/2;
  vll upmax(n+1,1);
  for(i=1;i<=n;i++){
    ll iss=2*x;
    if(iss>ma) iss=ma;
    upmax[i]=iss;
    //tot+=iss;
    if(A[i]>iss){
   //   d1("here");
      return -1;
    }
    x=iss-A[i];
   // deb(x);
  }
  //if(2*x<A[n]) return -1;
  ll prev=A[n];
  tot=A[n];
 // d1("sure");
  for(int i=n-1;i>=0;i--){
    ll x_mi=ceil((dd)(prev+2*A[i])/2.0);
    ll x_ma=min(upmax[i],prev+A[i]);
    if(x_mi>x_ma) return -1;
    tot+=x_ma;
    prev=x_ma;
  }
  return tot;
}
int main(){
  fio
  i_o();
  int n;
  cin>>n;
  vll A(n+1);
  rep(i,n+1) cin>>A[i];
  d1(help(A));
  return 0;
}


Measured memory_bytes: 4792
#!/usr/bin/env python3
from itertools import product
n = int(input())
x = [None] * n
y = [None] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())

m = 0
for i, j in product(range(n), repeat=2):
    if i == j:
        continue
    p = x[j] - x[i]
    q = y[j] - y[i]
    c = 0
    for s, t in product(range(n), repeat=2):
        if s == t:
            continue
        if x[t] - x[s] == p and y[t] - y[s] == q:
            c += 1
    m = max(m, c)

print(n - m)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,x,y,i,j,ans[300005],cnti[300005],cnt,sz,lft,mid,rit;
bool check()
{
	vector<int> tup,tdo;
	for (i=1;i<=n;i++)
	{
		if (tup.empty()||tup.back()<ans[i]) tup.push_back(ans[i]); else *(upper_bound(tup.begin(),tup.end(),ans[i]))=ans[i];
		if (tdo.empty()||tdo.back()<-ans[i]) tdo.push_back(-ans[i]); else *(upper_bound(tdo.begin(),tdo.end(),-ans[i]))=-ans[i];
	}
	return (x==tup.size())&&(y==tdo.size());
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin>>n>>x>>y;
	if (x+y-1>n)
	{
		cout<<-1;
		return 0;
	}
	if (x+y-1==n)
	{
		for (i=1;i<x;i++) cout<<i<<' ';
		for (i=n;i>=x;i--) cout<<i<<' ';
		return 0;
	}
	if (x==1)
	{
		cout<<-1;
		return 0;
	}
	if (y==1)
	{
		cout<<-1;
		return 0;
	}
	cnt=0;sz=0;
	for (i=1;i<=n;i+=y)
	{
		sz++;
		for (j=min(n,i+y-1);j>=i;j--) cnti[sz]++;
	}
	int i=1;
	while (sz<x)
	{
		if (i>sz) break;
		if (cnti[i]>1)
		{
			cnti[i]--;
			sz++;
			cnti[sz]=1;
		}
		else i++;
	}
	for (i=1;i<=n;i+=cnti[sz+1])
	{
		for (j=min(n,i+cnti[sz]-1);j>=i;j--) ans[j]=++cnt;
		sz--;
	}
	if (check())
	{
		for (i=1;i<=n;i++) cout<<ans[i]<<' ';
		return 0;
	}
	lft=n+1-x-y;mid=y-1;rit=x;cnt=0;
	for (i=lft+mid+1;i<=n;i++) ans[i]=++cnt;
	for (i=1;i<=lft;i++) ans[i]=++cnt;
	for (i=lft+mid;i>lft;i--) ans[i]=++cnt;
	if (check()){for (i=1;i<=n;i++) cout<<ans[i]<<' ';return 0;}
	lft=n+1-x-y;mid=x-1;rit=y;cnt=0;
	for (i=lft+1;i<=lft+mid;i++) ans[i]=++cnt;
	for (i=lft;i;i--) ans[i]=++cnt;
	for (i=n;i>lft+mid;i--) ans[i]=++cnt;
	if (check()){for (i=1;i<=n;i++) cout<<ans[i]<<' ';return 0;}
	lft=x-2;mid=y;rit=n+2-x-y;cnt=0;
	for (i=1;i<=lft;i++) ans[i]=++cnt;
	for (i=lft+mid;i>lft;i--) ans[i]=++cnt;
	for (i=n;i>lft+mid;i--) ans[i]=++cnt;
	lft=x-2;mid=y;rit=n+2-x-y;cnt=0;
	for (i=1;i<=lft;i++) ans[i]=++cnt;
	for (i=lft+mid;i>lft;i--) ans[i]=++cnt;
	for (i=n;i>lft+mid;i--) ans[i]=++cnt;
	if (check()){for (i=1;i<=n;i++) cout<<ans[i]<<' ';return 0;}
	lft=n+1-x-y;mid=y;rit=x-1;cnt=0;
	for (i=lft+mid+1;i<=n;i++) ans[i]=++cnt;
	for (i=1;i<=lft;i++) ans[i]=++cnt;
	for (i=lft+mid;i>lft;i--) ans[i]=++cnt;
	if (check()){for (i=1;i<=n;i++) cout<<ans[i]<<' ';return 0;}
	lft=n+1-x-y;mid=x;rit=y-1;cnt=0;
	for (i=lft+1;i<=lft+mid;i++) ans[i]=++cnt;
	for (i=lft;i;i--) ans[i]=++cnt;
	for (i=n;i>lft+mid;i--) ans[i]=++cnt;
	if (check()){for (i=1;i<=n;i++) cout<<ans[i]<<' ';return 0;}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 4368
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define btinpct(x) __builtin_popcountll((x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
typedef pair <ll, ll> pi; typedef pair <ll, pi> spi; typedef pair <pi, pi> dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (300006)
int main()
{
	FAST
	ll n; cin>>n;
	string A; cin>>A;
	ll ans = 0;
	FOR(i,0,9) FOR(j,0,9) FOR(k,0,9) {
		bool f=0, s=0, t=0;
		FOR(ind,0,n-1) {
			if(!f && A[ind]-48==i) {
				f=1;
			} else if(!s && f && A[ind]-48==j) {
				s=1;
			} else if(!t && s && f && A[ind]-48==k) {
				t=1;
			}
		}
		ans += t;
	}
	cout<<ans;
}


Measured memory_bytes: 384
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
B.append(0)
amari = 0
i = 0
ans = 0

for i in range(n + 1):
    if A[i] < amari:
        amari = B[i]
        ans = ans + A[i]
    elif A[i] < B[i] + amari:
        amari = B[i] + amari - A[i]
        ans = ans + A[i]
    else:
        ans = ans + B[i] + amari
        amari = 0

print(ans)


Measured memory_bytes: 18476
#include<cstdio>
using namespace std;
int n,m,sum[100005],A,B,sum1,a[100005],head[100005],cc,ck;
struct sd{int next,to;}seg[200005];
bool chek[100005];
bool flag;
inline void dfs(int v,int fa) {
	if(v==a[2]) {++ck;return;}
	if(chek[v]) return;
	chek[v]=true;
	for(int i=head[v];i;i=seg[i].next) if(seg[i].to!=fa) dfs(seg[i].to,v);
}
inline bool check() {
	for(int i=head[a[1]];i;i=seg[i].next) dfs(seg[i].to,a[1]);
	if(ck==4) return false;return true;
}
inline void addseg(int v,int r) {seg[++cc].next=head[v];head[v]=cc;seg[cc].to=r;}
int main()
{
	scanf("%d%d",&n,&m);for(int i=1;i<=m;++i) {scanf("%d%d",&A,&B);addseg(A,B);addseg(B,A);sum[A]++;sum[B]++;}
	for(int i=1;i<=n;++i) if(sum[i]&1) {printf("No");return 0;}else if(sum[i]==4) a[++sum1]=i;else if(sum[i]>=6) flag=true;
	if(flag) printf("Yes");
	else if(sum1>2||(sum1==2&&check())) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 3584
import sys

sys.setrecursionlimit(1000000)


def main():
    a, b, c, d = map(int, input().split())
    
    max_ab = max(a, b)
    min_ab = min(a,b)
    max_cd = max(c,d)
    min_cd = min(c,d)
    
    # ab ++
    if min_ab >= 0:
        # cd ++
        if min_cd >= 0:
            # ++
            print(max_ab * max_cd)
        # cd +-
        elif max_cd >= 0:
            # ++
            print(max_ab * max_cd)
        # cd --
        else:
            # +-
            print(min_ab * max_cd)
    # ab +-
    elif max_ab >= 0:
        # cd ++
        if min_cd >= 0:
            # ++
            print(max_ab * max_cd)
        # cd +-
        elif max_cd >= 0:
            # ++ or --
            print(max(max_ab * max_cd, min_ab * min_cd))
        # cd --
        else:
            # --
            print(min_ab * min_cd)
    # ab --
    else:
        # cd ++
        if min_cd >= 0:
            # -+
            print(max_ab * min_cd)
        # cd +-
        elif max_cd >= 0:
            # --
            print(min_ab * min_cd)
        # cd --
        else:
            # --
            print(min_ab * min_cd)


main()


Measured memory_bytes: 9164
from fractions import gcd

n = int(input())
a = list(map(int,input().split()))

L = [0]
R = [0]
for i in range(n):
  #左からの累積
  L.append(gcd(L[i],a[i]))
  #右からの累積
  R.append(gcd(R[i],a[-(i+1)]))

R = R[::-1]
ans = []
for i in range(n):
  ans.append(gcd(L[i],R[i+1]))
print(max(ans))

Measured memory_bytes: 16152
#include<bits/stdc++.h>
using namespace std;
#define N 1111116

int n,m,x,mx,mn,k,b,a[N],ans[N];
pair<int,int> q[N];

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	x=read();n=read();
	for (int i=1;i<=n;i++)
		q[i]=make_pair(read(),0);
	m=read();
	for (int i=1;i<=m;i++){
		q[n+i]=make_pair(read(),i);
		a[i]=read();
	}
	sort(q+1,q+n+m+1);
	mn=0;mx=x;k=-1;b=0;
	for (int i=1;i<=n+m;i++){
		mn+=k*(q[i].first-q[i-1].first);
		mn=min(max(mn,0),x);
		mx+=k*(q[i].first-q[i-1].first);
		mx=min(max(mx,0),x);
		b+=k*(q[i].first-q[i-1].first);
		if (!q[i].second) k=-k;
		else ans[q[i].second]=min(max(a[q[i].second]+b,mn),mx);
	}
	for (int i=1;i<=m;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main(){
    string s, t, s1;
    int c = 0;
    cin >> s >> t;
    s1 = s + s;
    for (int i = 0; i < s.size(); i++){
        for (int j = 0; j < t.size(); j++){
            if (s1[j + i] == t[j]){
                c++;
            }
        }
        if (c == s.size()){
            cout << "Yes" << endl;
            return 0;
        }
        c = 0;
    }
    cout  << "No" << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int AB = in.nextInt();
            int BC = in.nextInt();
            int CA = in.nextInt();
            int s = (AB + BC + CA) / 2;
            out.println((int) Math.sqrt(s * (s - AB) * (s - BC) * (s - CA)));
        }

    }
}



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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int dp[105][4][2];
const int ls = 0, eq = 1;
int main(){
    string IN;
    int K;
    cin >> IN >> K;

    vector<int> N;
    for (char &c : IN) N.push_back(c - '0');

    int n = N.size();

    dp[0][0][eq] = 1;

    rep(i, n) {
        int num = N[i];
        rep(j, K) {
            if (num > 0) {
                dp[i+1][j][ls] += dp[i][j][ls] + dp[i][j][eq];
                dp[i+1][j+1][ls] += dp[i][j][ls] * 9 + dp[i][j][eq] * (num-1);
                dp[i+1][j+1][eq] += dp[i][j][eq];
            } else {
                dp[i+1][j][ls] += dp[i][j][ls];
                dp[i+1][j][eq] += dp[i][j][eq];
                dp[i+1][j+1][ls] += dp[i][j][ls] * 9;
            }
        }
    }

    int ans = 0;
    rep(i, n+1) {
        rep(j, 2) ans += dp[i][K][j];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

enum INF(T) = T.max / 3;

bool chmin(t)(ref t a, t b) {
  if (b < a) {
    a = b;
    return true;
  } else {
    return false;
  }
}

void main() {
  int[] NMR = readln.chomp.split.to!(int[]);
  int N = NMR[0],
      M = NMR[1],
      R = NMR[2];
  int[] rs = readln.chomp.split.to!(int[]);
  int[201][201] dp;

  foreach (i, ref col; dp) {
    foreach (j, ref e; col) {
      if (i == j) {
        e = 0;
      } else {
        e = INF!int;
      }
    }
  }

  foreach (_; 0..M) {
    int[] ABC = readln.chomp.split.to!(int[]);
    int A = ABC[0],
        B = ABC[1],
        C = ABC[2];
    A--;
    B--;

    if (dp[A][B] > 0) {
      dp[A][B] = dp[B][A] = C;
    }
  }

  foreach (i; 0..N) {
    foreach (j; 0..N) {
      foreach (k; 0..N) {
        chmin(dp[j][k], dp[j][i] + dp[i][k]);
      }
    }
  }

  int ans = int.max;

  foreach (r; rs.permutations) {
    int t;
    foreach (i; 0..R-1) {
      t += dp[r[i] - 1][r[i+1] - 1];
    }
    chmin(ans, t);
  }

  writeln(ans);
}

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

int findSumOfDigits(int n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int total = 0;
	for (int i = 1; i <= N; i++) {
		int sum = findSumOfDigits(i);
		if (sum >= A && sum <= B) {
			total += i;
		}
	}
	cout << total << endl;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<ll> enum_prime(ll N){
	deque<bool> is_prime(N+1,true);
	vector<ll> P;
	for(ll i=2;i<=N;i++){
		if(is_prime[i]){
			for(ll j=i*i;j<=N;j+=i){
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

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

	auto P=enum_prime(1000000);
	sort(ALL(P));
	int M=P.size();
	
	while(true){
		int N=in();
		if(!N) break;

		int sum = 0;
		for(int i=0;i<M;i++){
			int V=N-P[i];
			if(binary_search(P.begin()+i,P.end(),V)) sum++;
		}
		out(sum);
	}
	return 0;
}



Measured memory_bytes: 4860
from functools import *
import sys
sys.setrecursionlimit(100000)

def acinput():
    return list(map(int, input().split(" ")))


N=input()
a=acinput()

if min(a)==0:
    print(0)
    sys.exit()
res=1

for sa in a:
    res*=sa
    if res>10**18:
        res=-1
        break
        
    
print(res)


Measured memory_bytes: 82028
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}

 
int32_t main()
{
    IOS
    
        int n;
        cin>>n;
        int a[n+1];
        for(int i=0;i<=n;++i)
            cin>>a[i];
        int b[n];
        for(int j=0;j<n;++j)
            cin>>b[j];
        int count=0;
        for(int i=0;i<n;++i)
        {

            b[i]=b[i]-a[i];
            if(b[i]<=0)
            {
                count+=a[i]+b[i];
                continue;
            }
            else
            {
                count+=a[i];
                int temp=a[i+1];
                a[i+1]=max((ll)0,a[i+1]-b[i]);
                count+=temp-a[i+1];

            }
        }
        cout<<count<<endl;

 
 
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
	int S,h,m,s;
	scanf("%d",&S);
	h = S / 60 / 60;
	m = (S - h * 60 * 60) / 60;
	s = S - h * 60 * 60 - m * 60 ;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 1860
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}   
void solve(){
    int n;
    cin >> n;
    if(n == 2){cout << "1\n";return ;}
    int cnt = 1;
    for(int i = 2;i*i <= n-1;++i){
        if((n-1)%i)continue;
        cnt++;
        if(i*i != n-1)cnt++;
    }
    cnt++;
    for(int i = 2;i*i <= n;++i){
        if(n%i)continue;
        int x = n;
        while((x%i) == 0)x /= i;
        if((x%i) == 1)cnt++;
        if(i*i == n)continue;
        x = n;
        while((x%(n/i)) == 0)x /= (n/i);
        if((x%(n/i)) == 1)cnt++;
    }
    cout << cnt << "\n";
}

signed main()
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
        solve();
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...#include <bits/stdc++.h>
 


Measured memory_bytes: 256
from string import*;from itertools import*;b=ascii_lowercase;s=r=input();t=s[::-1];d=0
if len(s)>25:d=-[p*len(list(k))for p,k in groupby(i<j for i,j in zip(t,t[1:]))][0]-2;s,b,r=s[:d],s[d+1:],b[:ord((s*2)[d])-97]
print(-(d<-26)or s+sorted(set(b)-set(r))[0])

Measured memory_bytes: 3768
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int m, n;
	cin >> n >> m;
	print((n - 1)*(m - 1));






	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.printf("%d %d\n", a * b, 2 * a + 2 * b);
		sc.close();
	}
}


Measured memory_bytes: 26188
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



string s;
int n, res = 1<<30, c;

signed main() {
	cin >> s;
	n = s.size();
	reps(i,1,n) if (s[i]!=s[i-1]) c++;
	res = c;
	c = 0;
	repr(i,n-2) if (s[i]!=s[i+1]) c++;
	chmin(res, c);
	cout << res << endl;
}


Measured memory_bytes: 720
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
int main()
{ string s;
int i,j,k;
  bool f=false,f1=false;
    cin>>s;
    k=s.length();
    for (i=0;i<k;i++)
     if (s[i]=='C'){j=i;f=true;break;}
    if (!f){cout<<"No";return 0;}
    for (i=j;i<k;i++)
     if (s[i]=='F') {cout<<"Yes";return 0;}
    cout<<"No";return 0;}

Measured memory_bytes: 256
def main():
    import sys
    from itertools import combinations
    from operator import itemgetter
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    even = []
    odd = []
    for i in range(N):
        if i%2:
            odd.append(A[i])
            even.append(B[i])
        else:
            even.append(A[i])
            odd.append(B[i])

    L = list(range(N))
    ans = 10**9
    for v in combinations(L, N//2):
        ok = 1
        tmp = []
        tmp_odd = []
        tmp_even = []
        for i in range(N):
            if i in v:
                tmp.append(odd[i] * 100)
                tmp_odd.append((odd[i], i))
            else:
                tmp.append(even[i] * 100)
                tmp_even.append((even[i], i))

        tmp_odd.sort(key=itemgetter(0))
        tmp_even.sort(key=itemgetter(0))

        tmp_check = []
        p = [0] * N
        for i in range(N):
            if i%2:
                tmp_check.append(tmp_odd[i//2][0])
                p[tmp_odd[i//2][1]] = i
            else:
                tmp_check.append(tmp_even[i // 2][0])
                p[tmp_even[i // 2][1]] = i
        for i in range(N-1):
            if tmp_check[i] > tmp_check[i+1]:
                ok = 0
                # print(v, tmp_check, odd, even)
                break
        if not ok:
            continue

        for i in range(N):
            tmp[i] += p[i]

        ans_new = 0
        for i in range(N):
            for j in range(i+1, N):
                if tmp[i] > tmp[j]:
                    ans_new += 1
        # print(v, tmp, ans_new, odd, even)
        ans = min(ans, ans_new)

    if ans == 10**9:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 47068
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    [n, m] <- readInts
    xs <- replicateM n $ do
        [a, b] <- readInts
        return (a, b)
    ys <- replicateM m $ do
        [c, d] <- readInts
        return (c, d)
    forM_ [0..(n - 1)] $ \i -> do
        ts <- forM [0..(m - 1)] $ \j -> return $ man (fst (xs !! i)) (fst (ys !! j)) (snd (xs !! i)) (snd (ys !! j))
        print $ minIndex ts + 1
    where
        readInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO [Int]
        man x1 x2 y1 y2 = abs (x1 - x2) + abs (y1 - y2)
        minIndex ss = head $ filter ((== minimum ss) . (ss !!)) [0..]


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);std::cout<<std::fixed<<std::setprecision(10);
    int N;
    cin >> N;
    vector<int> B(N+1);
    B[0] = INT32_MAX;
    B[N] = INT32_MAX;
    REP(i,N-1)cin >> B[i+1];
    int sum = 0;
    REP(i,N)sum += min(B[i],B[i+1]);
    cout <<sum<< "\n";
}

Measured memory_bytes: 256
#include<stdio.h>

int m[2200], n;

int solve(int i, int k)
{
	if (k == 0)
		return 1;
	if (i >= n)
		return 0;
	return solve(i + 1, k) || solve(i + 1, k - m[i]);
} 


int main()
{
	int q, k;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &m[i]);
	scanf("%d", &q);
	for (int i = 0; i < q; i++)
		scanf("%d", &k), printf("%s", solve(0, k) ? "yes\n" : "no\n");
		

}


Measured memory_bytes: 2092
#include <iostream>
#include <cmath>
using namespace std;
int height[101][101];
bool ok[101][101];
int main(){
    for(int xx=0; xx<=100; xx++){
        for(int yy=0; yy<=100; yy++){
            ok[xx][yy] = true;
        }
    }
    int n;
    cin >> n;
    int x[n],y[n],h[n];
    int nonzero = -1;
    for(int i=0; i<n; i++){
        cin >> x[i] >> y[i] >> h[i];
        if(nonzero==-1 && h[i]>0){
            nonzero=i;
        }
    }
    for(int xx=0; xx<=100; xx++){
        for(int yy=0; yy<=100; yy++){
            height[xx][yy] = h[nonzero] + abs(xx-x[nonzero]) + abs(yy-y[nonzero]);
        }
    }
       for(int xx=0; xx<=100; xx++){
            for(int yy=0; yy<=100; yy++){
                for(int i=0; i<n; i++){
                int tmp = height[xx][yy] - abs(xx-x[i]) - abs(yy-y[i]);
                if(tmp <0) tmp = 0;
                if(h[i] != tmp) ok[xx][yy] = false;
                }
             }
        }
    int ansx,ansy,ansh;
    for(int xx=0; xx<=100; xx++){
        for(int yy=0; yy<=100; yy++){
            if(ok[xx][yy]){
                ansx = xx;
                ansy = yy;
                ansh = height[xx][yy];
            }
        }
    }
    cout << ansx << " " << ansy << " "<< ansh << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    ios();
    int n;
    cin >> n;
    vector<pair<ll,ll>> v(n);
    for(auto& i : v){
        cin >> i.first >> i.second;
    }
    sort(all(v), [](auto a, auto b){return a.first + a.second > b.first + b.second;});
    pair<ll,ll> ans(0,0);
    REP(i, n){
        if(i%2 == 0){
            ans.first += v[i].first;
        }else{
            ans.second += v[i].second;
        }
    }
    cout << ans.first - ans.second << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


signed main(void) {
    double t,x;
    cin >> t >> x;
    cout << shosu(10) << t/x << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(int i=a;i<b;i++)
#define rFor(i,a,b) for(int i=a;i>b;i--)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<b>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数

int main() {
  ll a,b,c;
  ci(a>>b>>c);
  if(b-a<2*c)
    For(i,a,b+1)
      co(i);
  else{
    For(i,a,a+c)
      co(i);
    For(i,b-c+1,b+1)
      co(i);
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int W,H;
    cin >> W >>H;
    int map[W+2][H+2],isoutside[W+2][H+2];
    for(int j=0; j<H+2; j++) {
        for(int i=0; i<W+2; i++) {
            map[i][j]=0;
            isoutside[i][j]=0;
        }
    }
    for(int j=1; j<H+1; j++) {
        for(int i=1; i<W+1; i++) {
            cin >> map[i][j];
        }
    }
 
    isoutside[0][0]=1;
    queue<pair<int, int> >q;// キュー q を定義
    q.push(make_pair(0,0));//スタート地点をqにプッシュ
    while(q.empty()==false) {// q が空になるまでループを回す
        pair<int, int> point=q.front();
        q.pop();
        int x=point.first;
        int y=point.second;
        if(x>0 && map[x-1][y]==0 && isoutside[x-1][y]==0) {
            q.push(make_pair(x-1,y));
            isoutside[x-1][y]=1;
        }
        if(x<W+1 && map[x+1][y]==0 && isoutside[x+1][y]==0) {
            q.push(make_pair(x+1,y));
            isoutside[x+1][y]=1;
        }
        if(y>0 && map[x][y-1]==0 && isoutside[x][y-1]==0) {
            q.push(make_pair(x,y-1));
            isoutside[x][y-1]=1;
        }
        if(y<H+1 && map[x][y+1]==0 && isoutside[x][y+1]==0) {
            q.push(make_pair(x,y+1));
            isoutside[x][y+1]=1;
        }
        if(y%2==1 && x<W+1) {
            if(y>0 && map[x+1][y-1]==0 && isoutside[x+1][y-1]==0) {
                q.push(make_pair(x+1,y-1));
                isoutside[x+1][y-1]=1;
            }
            if(y<H+1 && map[x+1][y+1]==0 && isoutside[x+1][y+1]==0) {
                q.push(make_pair(x+1,y+1));
                isoutside[x+1][y+1]=1;
            }
        }
        else if(y%2==0 && x>0) {
            if(y>0 && map[x-1][y-1]==0 && isoutside[x-1][y-1]==0) {
                q.push(make_pair(x-1,y-1));
                isoutside[x-1][y-1]=1;
            }
            if(y<H+1 && map[x-1][y+1]==0 && isoutside[x-1][y+1]==0) {
                q.push(make_pair(x-1,y+1));
                isoutside[x-1][y+1]=1;
            }
        }
    }
    int total=0;
    for(int j=1; j<H+1; j++) {
        for(int i=1; i<W+1; i++) {
            int count=0;
            if(map[i][j]==1) {
                count=6;
                if(isoutside[i-1][j]==0)count--;
                if(isoutside[i+1][j]==0)count--;
                if(isoutside[i][j-1]==0)count--;
                if(isoutside[i][j+1]==0)count--;
                if(j%2==1 && isoutside[i+1][j-1]==0)count--;
                if(j%2==1 && isoutside[i+1][j+1]==0)count--;
                if(j%2==0 && isoutside[i-1][j-1]==0)count--;
                if(j%2==0 && isoutside[i-1][j+1]==0)count--;
            }
            total+=count;
        }
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 3228
a=[]
for i in range(3):
    tmp=list(map(int,input().split()))
    a.append(tmp)
n=int(input())
b=[]
for i in range(n):
    tmp=int(input())
    b.append(tmp)
if a[0][0] in b:
    if a[0][1] in b:
        if a[0][2] in b:
            print("Yes")
            exit()
    if a[1][1] in b:
        if a[2][2] in b:
            print("Yes")
            exit()
    if a[1][0] in b:
        if a[2][0] in b:
            print("Yes")
            exit()
if a[0][1] in b:
    if a[1][1] in b:
        if a[2][1] in b:
            print("Yes")
            exit()
if a[0][2] in b:
    if a[1][2] in b:
        if a[2][2] in b:
            print("Yes")
            exit()
    if a[1][1] in b:
        if a[2][0] in b:
            print("Yes")
            exit()
if a[1][0] in b:
    if a[1][1] in b:
        if a[1][2] in b:
            print("Yes")
            exit()
if a[2][0] in b:
    if a[2][1] in b:
        if a[2][2] in b:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 38384
N, A, B=map(int, input().split())

def fun(x):
  s=list(str(x))
  wa=0
  for p in s:
    wa+=int(p)
  return wa
ans=0
for i in range(1,N+1):
  tmp=fun(i)
  if A<=tmp and tmp<=B:
    ans+=i

print(ans)

Measured memory_bytes: 3060
N = int(input())
H = [int(n) for n in input().split()]
m = H[N-1]
ans = 'Yes'
for i in range(0, N-1)[::-1]:
    if H[i] > m+1:
        ans = 'No'
        break
    elif H[i] == m+1:
        m = H[i]-1
    else:
        m = H[i]
print(ans)


Measured memory_bytes: 14396
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	int n;
	cin >> n;
	cin >> str;
	int ans = 0;
	for (int len = 1; len < str.length(); len++)
	{
		int l = 0, r = len;
		int cnt = 0;
		while (r < str.length())
		{
			if (str[l++] == str[r++]) cnt++;
			else cnt = 0;
			ans = max(ans, min(len, cnt));
		}
	}
	cout << ans << endl;
	return 0;
}

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

ans = [0 for _ in range(N)]

sign = 1
for a in A:
    ans[0] += sign * a
    sign *= -1


for i in range(1, N):
    ans[i] = 2 * A[0] - ans[i - 1]

    t = A.pop(0)
    A.append(t)

print(*ans)


Measured memory_bytes: 20408
n = int(input())
a_list = sorted([int(x) for x in input().split()], reverse=True)

if a_list[-1] == 0:
    print(0)
    exit()

ans = 1
s = 10 ** 18
for a in a_list:
    ans *= a
    if ans > s:
        ans = -1
        break
print(ans)

Measured memory_bytes: 21716
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int a[101] = {0};

//qsort(a, 3, sizeof(int), sort_inc);
int sort_inc(const void *a, const void *b)
{
    return (*(int*)a - *(int*)b);
}
int sort_dec(const void* a, const void* b)
{
    return (*(int*)b - *(int*)a);
}

int main()
{
	int N = 0, i = 0, alice = 0, bob = 0;
	int ans = 0;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	qsort(a, N, sizeof(int), sort_dec);
	for (i = 0; i < N; i++) {
		if ((i & 1) == 1) {
			bob += a[i];
		} else {
			alice += a[i];
		}
	}
	ans = alice - bob;
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using ll = long long;
using pll = pair<ll,ll>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using ld = long double;
using ui = unsigned int;
using ull = unsigned long long;
using ui128 = __uint128_t;
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define setio(x) freopen(x ".in","r",stdin); freopen(x ".out","w",stdout)
const int MN = 1e6 + 2, LOG = 17, INF = 1e8, MOD = 998244353, BASE = 131;
char s[MN];
pii read () {
	scanf ("%s",s);
	int n = strlen(s);
	int mn = 0, sum = 0;
	for (int i = 0; i < n; i++) {
		sum += s[i] == '(' ? 1 : -1;
		mn = min(mn,sum);
	}
	return {sum,mn};
}
int main () {
	int n;
	scanf ("%d",&n);
	vector<pii> v(n);
	for (auto &au : v) au = read();
	sort(all(v),[](const pii &a, const pii &b){return max(-a.second,-a.first-b.second) < max(-b.second,-b.first-a.second);});
	int sum = 0;
	for (auto &au : v) {
		if (sum + au.second < 0) return !printf ("No\n");
		sum += au.first;
	}
	if (sum == 0) printf ("Yes\n");
	else printf ("No\n");
	return 0;
}



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

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }



int main(){
    LL n, k;
    cin >> n >> k;
    vector<LL> a(n);
    vector<LL> b(n+1);
    for(LL i = 0; i < n; ++i){
        cin >> a[i];
        b[i+1] = b[i] + a[i];
    }
    vector<LL> c;
    for(LL i = 0; i < n+1; ++i){
        for(LL j = i; j < n+1; ++j){
            c.push_back(b[j] - b[i]);
        }
    }
    LL ans = 0;
    for(LL r = 40; r >= 0; --r){
        LL mask = ((1LL << 41) - 1) - ((1LL << (r+1)) - 1);
        LL cnt = 0;
        for(LL i = 0; i < c.size(); ++i){
            if(((c[i] & mask) & ans) != ans) continue;
            if(c[i] & (1LL << r)) ++cnt;
        }
        if(cnt >= k){
            ans |= (1LL << r);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 6388
from itertools import permutations
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

L = list(permutations(range(1,N+1)))
L.sort()

for i in L:
  if i == P:
    a = L.index(i)
  if i == Q:
    b = L.index(i)

print(abs(a-b))



Measured memory_bytes: 8052
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static int ans;
	static int[] parent;//union-find用
	static int[] rank;//union-find用

	public static void main(String[] args) throws IOException {
		//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//		String W	 = in.readLine();
		//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] B = new int[N-1];
		for(int i = 0; i<N-1; i++) {
			B[i]=sc.nextInt();
			if(i>0) {
				ans+=Integer.min(B[i], B[i-1]);
			}else {
				ans+=B[i];
			}
		}
		ans+=B[N-2];

				System.out.println(ans);
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}

	//Union-Find用の配列を要素数nで初期化
	static void ufInit(int n){
		parent = new int[n];
		rank = new int[n];
	}

	//Union-Findの要素の最上位の親（グループ名）を返す
	static int ufFind(int a) {
		if(parent[a]==a) {
			return a;
		}else {
			return ufFind(parent[a]);
		}
	}

	//Union-Find木を連結する
	static void ufUnite(int a, int b) {
		a = parent[a];
		b = parent[b];

		if(a==b) {
			return;
		}
		if(rank[a] > rank[b]){
			parent[b]=a;
		}else {
			parent[a]=b;
			if(rank[a]==rank[b]) {
				rank[b]++;
			}
		}
	}

	static boolean ufSame(int a, int b) {
		return ufFind(a)==ufFind(b);
	}
}


Measured memory_bytes: 36152
#include <iostream>
#include <vector>
#include <array>
#include <cmath>
#include <string>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {

  int A, P; std::cin >> A >> P;

  std::cout << std::floor((double)((3*A)+P)/2.) << std::endl;

  return 0;
}

Measured memory_bytes: 256