akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

int main(){
//type
  string s;
  cin >> s;

//solve
  rep(i,3){
    if(s[i]=='7'){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
#define MAX(a,b) ((a)>(b))?(a):(b)
#define MIN(a,b) ((a)<(b))?(a):(b)
using namespace std;


int main() {
	int n,p,q,r,max=-1,w;
	int i,j;
	int c;
	int *sum;
	int p_under;
	int p_over;
	bool flag=false;
	scanf("%d%d",&n,&q);
	sum=(int *)malloc(sizeof(int)*n);
	scanf("%d",&w);
	max=sum[0]=w;
	for(i=1; i<n; ++i) {
		scanf("%d",&w);
		max=MAX(w,max);
		sum[i]=sum[i-1]+w;
	}
	if(q==1) {
		printf("%d\n",sum[n-1]);
		return 0;
	}
	p=max;
	p_over=sum[n-1];
	p_under=0;
	while(1) {
		i=0;
		for(c=0; c<q-1; ++c) {
			for(j=0; i+j<n; ++j) {
				if(i==0) {
					if(sum[j]>p) {
						i=j;
						j=0;
						break;
					}
				} else {
					if(sum[i+j]-sum[i-1]>p) {
						i+=j;
						j=0;
						break;
					}
				}
			}
			if(i+j==n-1 && c<q-2) {
				if(p==max || flag) {
					printf("%d\n",p);
					return 0;
				}
				p_over=MIN(p_over,p);
				if(flag) {
					++p;
				} else {
					p=(p_under+p_over)/2;
				}
			}
		}
		r=sum[n-1]-sum[i-1];
		if(r==p) {
			printf("%d\n",p);
			return 0;
		} else if (!flag) {
			if(r<p) {
				p_over=MIN(p_over,p);
				p=(p_over+p_under)/2;
			} else if(r>p) {
				if(p_over-p_under<=10 || r-p<=10 ) {
					flag=true;
					p_under=MAX(p_under,p);
					++p;
				} else {
					p_under=MAX(p_under,p);
					p=(p_under+p_over)/2;
				}
			}
		} else {
			if(r>p) {
				++p;
			} else {
				printf("%d\n",p);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int maxn=5e5+10;
ll gcd(ll a, ll b){return (b==0)?a:gcd(b, a%b);}
bool isPrime(ll n) {
    if(n<=3){
        return n>1;
    }
    if(n%6!=1&&n%6!=5){
        return false;
    }
    ll sqr=sqrt(n);
    for(ll i=5;i<=sqr;i+=6){
        if(n%i==0||n%(i+2)==0){
            return false;
        }
    }
    return true;
}
int dis[4][2]={0,1,0,-1,1,0,-1,0};
 
ll a[200005];
ll b[200005];
 int main()
 {
 	ll n;cin>>n;
 	ll sum=0;
 	memset(b,0,sizeof(b));
 	for(ll i=0;i<n;i++)
 	{
 		cin>>a[i];
 		b[a[i]]++;
	}
	 for(ll i=0;i<=n;i++)
	 if(b[i]>1)
	 sum+=(b[i]-1)*b[i]/2;
	 for(ll i=0;i<n;i++)
	 {
	 	ll ans=sum;
	 	if(b[a[i]]>1)
	 	{
	 		ll temp=b[a[i]];
	 		ans-=(temp-1)*temp/2;
	 		if(temp-2)
	 		ans+=(temp-2)*(temp-1)/2;
		 }
		 cout<<ans<<endl;
	 }
} 



Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/

typedef long long ll;
int Q, H, S, D, N;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> Q >> H >> S >> D >> N;

    D = min(min(Q * 8, H * 4), min(D, S * 2));
    S = min(min(Q * 4, H * 2), S);
    H = min(Q * 2, H);

    ll ans = 1LL * N / 2 * D;
    if (N % 2) ans += S;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
//0. a+b = a^b + 2*(a&b)
//1. for the first 1->0, then just find the max
long long a[305];
long long b[105], c[105], d[105];
long long power[105];

long long getMaxn(int start){
    long long res = 0;
    for(int i = start; i >= 1; i--){
        //printf("i = %d, %lld\n",i,power[i-1]);
        if(d[i]) res += power[i-1];
        else res += power[i-1]*c[i];
    }
    return res;
}

void printB(int n,long long t[]){
    for(int i = n; i >= 1; i--) printf("%lld",t[i]);
    printf("\n");
}

int main(){
    power[0] = 1;
    for(int i = 1; i <= 60; i++) power[i] = power[i-1]*2ll;
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) scanf("%lld",&a[i]);
    long long xSum = 0;
    for(int i = 3; i <= n; i++) xSum ^= a[i];
    long long aSum = a[1]+a[2]-xSum;
    if(aSum<0 || aSum%2) printf("-1\n");
    else if((a[1]^a[2])==xSum) printf("0\n");
    else{
        long long pre = a[1];
        aSum /= 2;
        int ok = 1;
        for(int i = 1; i <= 50; i++){ 
            b[i] = a[1]%2, c[i] = aSum%2, d[i] = xSum%2;
            if(c[i]&&d[i]) ok = 0;
            a[1] /= 2, aSum /= 2, xSum /= 2;
        }
        if(!ok) printf("-1\n");
        else{
            long long ans = 0;
            long long base = 0;
            for(int i = 50; i >= 1; i--){
                if(i!=50) base += b[i+1]*power[i];
                if(!c[i]){
                    if(!d[i]){
                        if(b[i]){
                            //printf("i = %d, base = %lld\n",i,base);
                            long long cur = base+getMaxn(i-1);
                            if(ans<cur) ans = cur;
                            break;
                        }
                        else continue;
                    }
                    else{
                        if(b[i]){
                            //printf("i = %d, base0 = %lld\n",i,base);
                            long long cur = base+getMaxn(i-1);
                            if(ans<cur) ans = cur;
                        }
                        else continue;
                    }
                }
                else{
                    if(b[i]) continue;
                    else break;
                }
            }
            if(ans!=0) printf("%lld\n",pre-ans);
            else printf("-1\n");
        }
    }
    return 0;
}


Measured memory_bytes: 1728
antennas = []
5.times do
  antennas << gets.chomp.to_i
end
k = gets.chomp.to_i
min = antennas.min

def determine(antennas, min, k)
  return 'Yay!' if antennas.empty?

  max = antennas.delete(antennas.max)
  return ':(' if max - min > k

  determine(antennas, min, k)
end
puts determine(antennas, min, k)


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 998244353
#define N 200005  //check the limits, man
string str;
vector<ll> num;
vi odd;
ll po[N];
ll check(int a,int n)
{
    ll z=0;
    int i,j,f;
    rep(i,a)
    {
        if(str[i])
            z+=po[a-i-1];
    }
    string ar;
    ar.resize(n);
    f=0;
    for(i=0;i<n;i+=a)
    {
        for(j=i;j<i+a;j++)
            ar[j]=(f^str[j-i]);
        f^=1;
    }
    z%=M;
    if(ar<=str)
        z++;
    return z;
}
int main()
{
    int n,i,s,m,x,j;
    in(n);
    llin(str);
    rep(i,n)
        str[i]-='0';
    po[0]=1;
    lp(i,1,n)
        po[i]=(po[i-1]+po[i-1])%M;
    x=1,m=n;
    while(m%2==0)
       x*=2,m/=2;
    for(i=1;i<=m;i+=2)
        if(m%i==0)odd.pb(x*i);
    s=odd.size();
    num.resize(s,0);
    rep(i,s)
        num[i]=check(odd[i],n);
    rep(i,s)
    {
        lp(j,i+1,s)
        {
            if(odd[j]%odd[i]==0)
                num[j]+=(M-num[i]);
        }
    }
    ll ans=0;
    rep(i,s)
        num[i]*=odd[i],num[i]%=M,ans+=num[i];
    ans*=2;
    llout(ans%M);
}


Measured memory_bytes: 2308
#include <iostream>
int main(){
  int height, width;
  int a,b,ans;
  int h,w;
  std::cin >> height >> width;
  std::cin >> h >> w;
  a = height - h;
  b = width - w;
  ans = a * b;
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  LL N; cin >> N;
  vector<LL> A(N), S(N); cin >> A;
  S[N-1] = 0;
  for (int i = N - 2; i >= 0; --i) S[i] = (S[i + 1] + A[i + 1]) % kMod;

  LL sum = 0;
  for (int i = 0; i < N; ++i) {
    sum += A[i] * S[i];
    sum %= kMod;
  }
  cout << sum << endl;
}


Measured memory_bytes: 6416
n,m=map(int,input().split())
h=list(map(int,input().split()))
a=list([1 for _ in range(n)])

for _ in range(m):
  b,c= map(int,input().split())
  if h[b-1]<h[c-1]:
    a[b-1]=0
  elif h[b-1]==h[c-1]:
    a[b-1]=0
    a[c-1]=0
  else:
    a[c-1]=0
print(sum(a))


Measured memory_bytes: 20116
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef priority_queue<ll, vl> decendingQueue;              //降順
typedef priority_queue<ll, vl, greater<ll>> ascendingQueue; //昇順
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 9 * 1e18;
const ll MOD = 1e9 + 7;

void solve(long long N, std::vector<long long> p) {
  vl a(N);
  vl b(N);
  rep(n, 0, N) {
    a[n] = (n + 1) * 20000;
    b[N - n - 1] = (n + 1) * 20000;
  }

  rep(n, 1, N) { a[p[n] - 1] += n; }

  rep(n, 0, N) {
    cout << a[n];
    if (n != N - 1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }

  rep(n, 0, N) {
    cout << b[n];
    if (n != N - 1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
}

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


Measured memory_bytes: 1152
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for w in range(n):
   if l[w][2]>0:
     k=w
     break
for x in range(101):
  for y in range(101):
    a=l[k][2]+abs(l[k][0]-x)+abs(l[k][1]-y)
    c=0
    for z in range(n):
      if max((a-abs(l[z][0]-x)-abs(l[z][1]-y)),0)==l[z][2]:c+=1
      if c==n:
        print(x,y,a)

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

int main() {
    int l, r, d, ans;
    cin >> l >> r >> d;
    ans = 0;
    for (int i=l; i<=r; i++){
        if( i % d ==0){
            ans += 1;
        }
    }
cout << ans <<endl;

}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <tuple>
 
using namespace std;
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "YES" : "NO")
#define mod(a, b) (b + (a % b)) % b
#define MOD (int)1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

void add_self (int& a, int b){ a += b; if (a >= MOD) a -= MOD; }
//-------------------------------------------------------------------------------------------------------//

void solve(){
    int n;
    cin >> n;
    vector <vi> a(n, vi(26, 0));
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        for(int j = 0; j < sz(s); j++){
            a[i][s[j] - 'a'] += 1;
        }
    }
    sort(all(a));
    a.push_back({-1, -1, -1, -1, -1, -1, -1, -1, -1, -1});
    ll ans = 0, k = 1;
    for (int i = 0; i < n; i++) {
        if(a[i] == a[i + 1]){
            ans += k;
            k++;
        }
        else k = 1;
    }
    cout << ans;
}
 
int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}


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

using namespace std;

const int N = 200005;
const int mod = 1e9 + 7;

int n;
int all;
int res;
int a[N], b[N];
int lim[N];
int prd[N];
int bit[N];
int bit2[N];

int binPow(int x, int y) {
	if (!y) return 1; 
	int ret = binPow(x, y >> 1);
	ret = 1LL * ret * ret % mod; 
	if (y & 1) ret = 1LL * ret * x % mod;
	return ret;
}

void upd(int x, int y) {
	for (; x <= n; x += x & -x) bit[x] = (bit[x] + y) % mod;
}

int get(int x) {
	int ret = 0;
	for (; x > 0; x -= x & -x) ret = (ret + bit[x]) % mod;
	return ret;
}

void upd2(int x) {
	for (; x <= n; x += x & -x) bit2[x]++;
}

int get2(int x) {
	int ret = 0;
	for (; x > 0; x -= x & -x) ret += bit2[x];
	return ret;
}

int get(int l, int r) { return get(r) - get(l - 1); }

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i], b[a[i]]++;
	}
	for (int i = n - 1; i >= 1; --i) b[i] += b[i + 1] - 1;
	for (int i = n; i >= 1; --i) {
		if (b[i] <= 0) {
			cout << 0; return 0;
		}
	}
	all = 1;
	for (int i = 1; i <= n; ++i) all = 1LL * all * b[i] % mod;
	int cur = 1;
	for (int i = 1; i <= n; ++i) {
		if (b[i] == 1) cur = i; lim[i] = cur;
	}
	prd[0] = 1;
	for (int i = 1; i <= n; ++i) {
		if (b[i] == 1) prd[i] = prd[i - 1];
		else prd[i] = 1LL * prd[i - 1] * (b[i] - 1) % mod * binPow(b[i], mod - 2) % mod;
	}
	for (int i = 1; i <= n; ++i) {
		res = (res + 1LL * prd[a[i]] * get(lim[a[i]], a[i]) % mod * all) % mod; 
		upd(a[i], binPow(prd[a[i]], mod - 2));
	}
	memset(bit, 0, sizeof bit);
	long long cnt = 0;
	for (int i = n; i >= 1; --i) {
		res = (res - 1LL * prd[a[i]] * get(lim[a[i]], a[i] - 1) % mod * all) % mod; 
		if (res < 0) res += mod;
		cnt += get2(a[i] - 1);
		upd(a[i], binPow(prd[a[i]], mod - 2));		
		upd2(a[i]);
	}
	res = 1LL * res * binPow(2, mod - 2) % mod;
	res = (res + cnt % mod * all) % mod;
	cout << res;
}

Measured memory_bytes: 4992
{-# OPTIONS_GHC -O #-}

import Control.Monad
import Control.Monad.ST
import Data.List
import Control.Monad.Trans.State.Strict
import Data.Char (isSpace)
import Data.Maybe (fromJust)
import qualified Data.ByteString.Lazy.Char8 as B

import Data.Array.ST
import Data.Array.Unboxed

type Parser a = StateT B.ByteString Maybe a

parseInt :: Parser Int
parseInt = StateT (B.readInt . B.dropWhile isSpace)

parseInt3 :: Parser (Int,Int,Int)
parseInt3 = liftM3 (,,) parseInt parseInt parseInt

parse :: Parser ((Int,Int,Int), [(Int,Int,Int)])
parse = do
    (n,ma,mb)<-parseInt3
    abcs<-replicateM n parseInt3
    return ((n,ma,mb),abcs)

main=do
    ((n,ma,mb),abcs)<-fromJust.evalStateT parse <$> B.getContents
    let dp = fdp n abcs :: UArray (Int,Int) Int
--    print $ filter (\((_,_),c)->c<5000) $ assocs dp
    print $ solve n ma mb dp
--
fdp n abcs = runSTUArray $ do
    dp <- newArray ((0,0),(10*n,10*n)) 5000 :: ST s (STUArray s (Int,Int) Int)
    writeArray dp (0,0) 0
    forM_ [((a,b,c),(i,j))|(a,b,c)<-abcs, i<-[n*10-a,n*10-a-1..0], j<-[n*10-b,n*10-b-1..0]] $ \((a,b,c),(i,j)) -> do
        ka <- readArray dp (i,j)
        when (ka<5000) $ do
            kb <- readArray dp (i+a, j+b)
            writeArray dp (i+a,j+b) (min kb (c+ka))
    return dp
--
solve n ma mb dp
    | ar < 5000 = ar
    | otherwise = -1
    where
        ca = takeWhile (\c->c*ma<=10*n && c*mb<=10*n) [1..]
        ar = minimum $ map (\c -> dp ! (c*ma,c*mb)) ca


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

int n;
const int maxn=5000;
int a[maxn];
int sum,mx;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) 
	scanf("%d",&a[i]),sum+=a[i],mx=max(mx,a[i]);
	if(sum-mx>mx) printf("Yes\n");else printf("No\n"); 
	return 0;
}

Measured memory_bytes: 256
A,B=input().split()
A=int(A)
B=int(B)
price1_min=A/0.08
price1_max=(A+1)/0.08
price2_min=B/0.1
price2_max=(B+1)/0.1

if price2_min>=price1_max or price1_min>=price2_max:
    print(-1)

else:
    price=max(price1_min,price2_min)
    if price==int(price):
        print(int(price))
    else:
        print(int(price)+1)
    
    

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

int main() {
	// your code goes here
	setprecision(30);
	int n,i,j;
	cin>>n;
	double p[n];
	for(i=0;i<n;i++)cin>>p[i];
	double dp[n+1][n+1],ans=0.0;
	dp[1][0]=1.0-p[0];
	dp[1][1]=p[0];
	for(i=2;i<=n;i++)
	{
		for(j=0;j<=i;j++)
		{
			dp[i][j]=dp[i-1][j]*(1.0-p[i-1]);
			if(j>0)dp[i][j]+=dp[i-1][j-1]*p[i-1];
		}
	}
	for(i=n/2+1;i<=n;i++)ans+=dp[n][i];
	printf("%0.15lf\n",ans);
	return 0;
	
}

Measured memory_bytes: 70272
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll h, w, n;
  cin >> h >> w >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  vector<vector<ll>> ans(h, vector<ll>(w));

  ll now = 1;
  REP(i, h) {
    if (i % 2 == 0) {
      REP(j, w) {
        ans[i][j] = now;
        --a[now - 1];
        if (a[now - 1] == 0) now++;
      }
    } else {
      REPR(j, w - 1) {
        ans[i][j] = now;
        --a[now - 1];
        if (a[now - 1] == 0) now++;
      }
    }
  }
  REP(i, h) {
    REP(j, w) { cout << ans[i][j] << " "; }
    cout << endl;
  }
  return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a%3==0||b%3==0||(a+b)%3==0){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
}

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

#define rep(i, a, b) for (int i=a; i <b; i++)
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef vector< int > vi;

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

int main() {
    int n, x;
    scanf("%d %d", &n, &x);
    vector<int> ary(n);
    for(int i=0; i<n; i++) {
        scanf("%d", &ary[i]);
    }
    for(int i=0; i<n; i++) {
            ary[i] = abs(ary[i] - x);
    }
    sort(ary.begin(), ary.end());
    int ans = ary[0];
    for(int i=1; i<n-1; i++) {
        ans = gcd(ary[i], ans);
    }

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

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

int main() {
  int p=0;
  vector<int> vec(3);
  for(int i=0;i<3;i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  for(int i = 0;i<2;i++){
    if(vec.at(i) == vec.at(i+1)){
      p = 1;
      break;
    }
  }
  if(!p){
    cout << "No" << endl;
  }else if(vec.at(0) == vec.at(2)){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int D = in.nextInt();
        int N = in.nextInt();
        double d = Math.pow(100,D);
        int a = (int)d;
        int ans = a * N;
        if(N == 100)
            ans += a;
        System.out.println(ans);
    }
}

Measured memory_bytes: 22228
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int n,m;
	int ans=0;
	scanf("%d%d",&n,&m);
	if(n>=2){
		ans+=(n-1)*n/2;
	}
	if(m>=2){
		ans+=(m-1)*m/2;
	}
	printf("%d\n",ans);
	return 0;
} 

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,k;cin>>n>>k;

  int p = 1;
  for(int i=0;i<n;i++){
    int sa = p*2;
    int sb = p+k;
    if(sa<sb)p=sa;
    else p=sb;
  }
  cout<<p<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;
int num[200001];

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

    int N, K;
    cin >> N >>K;

    vector<int> a;
    REP(i, N){
        int x;
        cin >> x;
        x--;
        num[x]++;
    }
    REP(i, N){
        if(num[i] != 0) a.pb(num[i]);
    }
    sort(All(a));
    int ans = 0;
    REP(i, max(0, (int)a.size()-K)){
        ans += a[i];
    }
    cout << ans << "\n";


    return 0;
}


Measured memory_bytes: 2168
#include <cstdio>
#include <string>

using namespace std;

int main() {
	long a, b;
	string sum;
	
	while (scanf("%ld %ld", &a, &b) != EOF) {
	    sum = to_string(a + b);
	    
	    printf("%d\n", sum.size());
	}
	
	return 0;
}

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

ans = 0
while True:
    if all([True if A[i]%2 ==0 else False for i in range(len(A))]) == False:
        break
    A = [A[i]/2 for i in range(len(A))]
    ans += 1

print(ans)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    map<char,int> m;
    vc<char> c = {'M','A','R','C','H'};
    rep(i,n){
        string s; cin >> s;
        m[s[0]]++;
    }
    ll ans = 0;
    rep(i,5){
        rng(j,i+1,5){
            rng(k,j+1,5){
                ans += 1LL*m[c[i]]*m[c[j]]*m[c[k]];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

using namespace std;
int main() {

	int m, d;
	cin >> m >> d;
	int ans = 0;

	



	for (int i = 22; i <= d; i++)
	{

		int d10 = i / 10;
		int d1 = i % 10;
		
		if (d1 < 2) continue;

		
			if (2 <= d10 * d1 && m >= d10 * d1) ans++;
		


		
	}




	cout << ans;


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
	long double N, K, Y; cin >> N >> K;
	long double F = 0;
	for (int X = 1; X <= N; X++) {
		for (Y = X; Y < K; Y *= 2) {
		}
		F += 1 /(Y*N/X);
	}
	cout <<fixed<<setprecision(15)<< F << endl;
}

Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner s = new Scanner(System.in);
		String str = s.nextLine();
		int cnt = 0;
		for (int i = 0; i < str.length(); i++) {
			if (str.charAt(i) == '2')
				cnt++;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>
#define MAX 100000

typedef struct {
  int time;
  char name[10];
} P;

int n, head=0, tail;

int isEmpty(P []);
P dequeue(P []);
void enqueue(P [], P );

main()
{
  int i, q, time=0;
  P Q[MAX], x;

  scanf("%d %d", &n, &q);
  for(i=0; i<n; i++) scanf("%s %d", Q[i].name, &Q[i].time);

  tail = n;

  while(!isEmpty(Q))
    {
      if(q >= Q[head].time && Q[head].time != 0)
	{
	  time = time + Q[head].time;
	  printf("%s %d\n", Q[head].name, time);
	  if(head + 1 == MAX) head = 0;
	  else head++;
	}
      else
	{
	  Q[head].time -= q;
	  time += q;
	  x = dequeue(Q);
	  enqueue(Q, x);
	}
    }

  return 0;  
}

int isEmpty(P Q[])
{
  if(tail == head) return 1;
  else return 0;
}

P dequeue(P Q[])
{
  P x;
  x = Q[head];

  if(head + 1 == MAX) head = 0;
  else head++;

  return x;
}

void enqueue(P Q[], P x)
{
  Q[tail] = x;
  if(tail + 1 == MAX) tail = 0;
  else tail++;
}

Measured memory_bytes: 2160
import java.util.*;

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

        char[] s = sc.nextLine().toCharArray();
        char[] t = sc.nextLine().toCharArray();

        int ans = 0;
        if(s[0] == t[0]) ans++;
        if(s[1] == t[1]) ans++;
        if(s[2] == t[2]) ans++;

        System.out.println(ans);


        return;
    }
}

Measured memory_bytes: 23508
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int n,i;
    cin >> n;
    vector<long long> t(n);
    for(i = 0;i < n;++i){
        cin >> t.at(i);
    }
    long long ans = t.at(0);
    long long temp1,temp2,temp3;
    for(i = 1;i < n;++i){
        if(ans > t.at(i)){
            temp1 = ans;    temp2 = t.at(i);
        }else{
            temp1 = t.at(i);    temp2 = ans;
        }
        while(temp1%temp2){
            temp3 = temp1%temp2;
            temp1 = temp2;
            temp2 = temp3;
        }
        ans = temp2*(ans/temp2)*(t.at(i)/temp2);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int num_of_keta(int x) {
  int ret = 0;

  do {
    ret++;
    x /= 10;
  }while(x);

  return ret;
}

int main() {
  int x, y;

  while(cin >> x >> y) {
    std::cout << num_of_keta(x+y) << std::endl;
  }
}

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

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll t,i,x,j,y,z,k,n;

cin>>n>>k;		ll a[n];
rep(i,0,n,1){
	cin>>a[i];
}
sort(a,a+n);
i=n-1;
while(k--){
	i--;
}
// ce(i)
k=0;
while(i>=0){
	k+=a[i];
	i--;
}
ce(k)
}


Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;


int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll q;
    cin >> q;
    ll s=(1<<n);
    vector<ll> b(s);
    
    for(ll i=0;i<(s);i++){
        ll sum=0;
        rep(j,n){
            if(i&(1<<j)){
                sum+=a[j];
            }
        }
        b[i]=sum;
    }
    sort(b.begin(),b.end());
    while(q--){
        ll m;
        cin >> m;
        ll l=-1;
        ll r=s;
        while(r-l>1){
            ll mi=(l+r)/2;
            if(b[mi]<=m) l=mi;
            else r=mi;
        }
        if(b[l]==m) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
} 


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

int main(){
	int a,b,t;
	cin>>a>>b>>t;
	int num=0;int time=a;
	while(time<t+0.5){
		num+=b;
		time+=a;
	}
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;
const int N = 2019;

long long int power(long long int x,long long int y,long long int p) 
{ 
	long long int res = 1;	 
	x = x % p; 
	while (y > 0) 
	{ 
		if (y & 1) 
			res = (res*x) % p; 
		y = y>>1; 
		x = (x*x) % p; 
	} 
	return res; 
} 

void solve(){
    lli a,b,n; cin>>a>>b>>n;
    lli ans = ((a*min(n,b-1))/b) - (a*(min(b-1,n)/b));
    cout<<ans;
    return;
}
int main(){
    fastIO;
    lli t = 1; 
    // cin>>t;
    NA(i,0,t) solve();
    return 0;
}

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

int main()
{
	int N;
	cin >> N;
	
	int sum = 0, max = 0, tmp;
	for (int i = 0; i < N; ++i)
	{
		cin >> tmp;
		sum += tmp;
		if (tmp > max) max = tmp;
	}
	
	cout << sum - max / 2;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    Int y, x;
} p_t;


int main() {
    Int k, x;
    cin >> k >> x;
    dump(k * 500 >= x ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  string s; cin >> s;
  int n = s.size();

  map<char,int> cnt;
  int ans = 0;
  REP(i,n) {
    char hand = s[i], myhand = 'g';
    if (cnt['p'] < cnt['g']) myhand = 'p';

    if (hand == 'g' && myhand == 'p') ans++;
    else if (hand == 'p' && myhand == 'g') ans--;

    cnt[myhand]++;
  }
  COUT(ans);

  return 0;
}

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

#define ll long long
#define fr first
#define se second
#define pb push_back

using namespace std;

const long long N = 1e5 + 7;

ll res, n, m, cnt, ans , a , b , sum , mx = -1e9 , mn, c , d;
int main()
{
    cin >> n;
    cnt = 100;
    while( cnt < n ){
        cnt+=cnt/100;
        ans ++;
    }
    cout << ans;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <time.h>

#define		N	101

int find_length(int a, int cur_length);

int		conn[N][N];
int		used[N];

int main()
{
    int		i, j;
    int		a, b;
    int		n;
    int		max_length, length;
    time_t	start_time, t;

    while(1)
    {
	start_time = time(NULL);
	for(j = 0; j < N; j++)
	{
	    for(i = 0; i < N; i++)
	    {
		conn[j][i] = 0;
	    }
	}

	scanf("%d", &n);
	if (n == 0)
	{
	    break;
	}
	for(int i = 0; i < n; i++)
	{
	    scanf("%d %d", &a, &b);
	    conn[a][b] = 1;
	    conn[b][a] = 1;
	}

	for(a = 0; a < N; a++)
	{
	    used[a] = 0;
	}

	max_length = 0;
	for(a = 0; a < N; a++)
	{
	    length = find_length(a, 1);
	    if (length > max_length)
	    {
		max_length = length;
	    }
	    if (time(NULL) - start_time > 1)
	    {
		break;
	    }
	}
	printf("%d\n", max_length);
    }
}


int find_length(int a, int cur_length)
{
    int		b;
    int		length, max_length;

    used[a] = 1;
    max_length = cur_length;
    for(b = 0; b < N; b++)
    {
	if (conn[a][b] == 1 && used[b] != 1)
	{
	    length = find_length(b, cur_length+1);
	    if (length > max_length)
	    {
		max_length = length;
	    }
	}
    }
    used[a] = 0;

    return max_length;
}

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

const ll MAX_N = 212345;
ll MOD = ll(1000000000+7);
ll fac2[MAX_N];

void init(){
    fac2[0] = 1ll;
    for(int i=1;i<MAX_N;i++){
        fac2[i] = (fac2[i-1]*2ll)%MOD;
    }
}

int main(void)
{
    init();
    ll N;
    cin >> N;
    map<pair<ll, ll>, pair<int, int>> umap;
    // pair<int, int> zpair = {0, 0};
    ll zero = 0;
    for(int i=0;i<N;i++){
        ll a, b;
        cin >> a >> b;
        if(a==0 && b==0){
            zero++;
            continue;
        }
        // if(a==0){
        //     zpair.first++;
        //     continue;
        // }
        // if (b==0){
        //     zpair.second++;
        //     continue;
        // }
        if(make_pair(a, b) < make_pair(0ll, 0ll)){
            a = -a;
            b = -b;
        }
        ll d = gcd(abs(a), abs(b));
        a /= d;
        b /= d;
        if(b>0){
            umap[{a, b}].first += 1;
        }else{
            umap[{-b, a}].second += 1;
        }
    }
    // ll answer = (fac2[zpair.first] + fac2[zpair.second] - 1ll) % MOD;
    ll answer = 1ll;
    for(auto& item:umap){
        answer *= (fac2[item.second.first]+fac2[item.second.second]-1ll) % MOD;
        answer %= MOD;
    }
    cout << (answer + zero -1 + MOD) % MOD << endl;

    return 0;
}

Measured memory_bytes: 17756
n=int(input())
h=list(map(int,input().split()))
c=[0]*n
c[1]=abs(h[0]-h[1])
for i in range(2,n):
    c[i]=min(c[i-2]+abs(h[i]-h[i-2]),c[i-1]+abs(h[i]-h[i-1]))
print(c[n-1])

Measured memory_bytes: 13980
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>

int main()
{
    int a,b,k,i;
    scanf("%d %d %d",&a,&b,&k);
    if(2*k>=b-a+1)
    {
        for(i=a; i<=b; i++)
            printf("%d\n",i);
    }
    else
    {
        for(i=a; i<=a+k-1; i++)
            printf("%d\n",i);
        for(i=b-k+1; i<=b; i++)
            printf("%d\n",i);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a,b;
  cin >> a >> b;
  if (a > b) {
    cout << ">" << endl;
  } else if (a < b) {
    cout << "<" << endl;
  } else {
    cout << "=" << endl;
  }
}

Measured memory_bytes: 256
#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() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<char>> blocks(H, vector<char>(W));
  rep(i, H) {
    rep(j, W) {
      cin >> blocks.at(i).at(j);
    }
  }

  int ans = 0;
  for (int row = 0; row < (1 << H); row++) {
    for (int col = 0; col < (1 << W); col++) {
      int count = 0;
      for (int i = 0; i < H; i++) {
        if ((row >> i) & 1) continue;
        for (int j = 0; j < W; j++) {
          if ((col >> j) & 1) continue;
          if (blocks.at(i).at(j) == '#') count++;
        }
      }
      if (count == K) ans++;
    }
  }

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

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int q; cin >> q;
    vector<set<int>> st(26);
    vector<int> ans;
    for(int i = 0; i < n; i++) st[s[i]-'a'].insert(i); 
    for(int i = 0; i < q; i++){
        int qy; cin >> qy;
        if(qy == 1){
            int a; cin >> a;
            char b; cin >> b;
            a--;
            st[s[a]-'a'].erase(a);
            s[a] = b;
            st[b-'a'].insert(a);
        }
        else {
            int l,r; cin >> l >> r;
            l--;r--;
            int cnt = 0;
            for(int j = 0; j < 26; j++){
                auto itr = st[j].lower_bound(l);
                if(itr != st[j].end() && *itr <= r) cnt++;
            }
            ans.push_back(cnt);
        }
    }
    for(auto p:ans) cout << p << endl;
    return 0;
}

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

typedef long long ll;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    bool ans=false;
    while(n){
        if(n%10==7){
            ans=true;
            break;
        }
        n/=10;
    }
    if(ans)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3652
splitOnZero :: Integral a => [a] -> [a]
splitOnZero = f []
    where
        f ys [] = reverse $ filter (/=0) ys
        f ys (0 : xs) = f (0 : ys) xs
        f [] (x : xs) = f [x] xs
        f (y : ys) (x : xs) = f (x + y : ys) xs

maxPairs :: Integral a => [a] -> a
maxPairs = sum . fmap (`div` 2) . splitOnZero

main :: IO ()
main = getLine >> getContents >>= print . maxPairs . fmap (read :: String -> Int) . lines


Measured memory_bytes: 5884
//Algo 2

import java.util.Scanner;

public class Main {
	
	public static int maxProfit1(int n, int[] R) {
		
		int max = R[1] - R[0];
		
		for (int i = 0; i < n; i++) {
		
			for (int j = i + 1; j < n; j++) {
				
				if ((R[j] - R[i]) > max) { 
					max = R[j] - R[i]; 
					}
				
				//System.out.println(max);
			
			} }
		
		return max;
	
	}
	
	public static int maxProfit2(int n, int[] R) {
		int min = R[0];
		int max = R[1] - R[0];
		for (int i = 1; i < n; i++) {
			//System.out.println(max);
			max = (R[i] - min) > max ? R[i] - min : max;
			if (min > R[i]) min = R[i];
		}
		return max;
	}
	
	
	
	public static void main(String[] args) {
		
		Scanner s = new Scanner(System.in);
		
		int n = s.nextInt();
		int[] R = new int[n];
		for (int i = 0; i < n; i++) {
			R[i] = s.nextInt();
		}
		
		//System.out.println(maxProfit1(n, R));
		System.out.println(maxProfit2(n, R));
		
		
	}
	

}


Measured memory_bytes: 100948
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int W[110];
int main()
{
	int N;
	cin >> N;
	int sum1 = 0, sum2 = 0;
	for (int i = 0; i < N; i++) {
		cin >> W[i];
		sum2 += W[i];
	}
	int ans = mod;
	for (int i = 0; i < N; i++) {
		sum1 += W[i];
		sum2 -= W[i];
		ans = min(ans,abs(sum1 - sum2));
	}
	cout << ans << endl;
}


Measured memory_bytes: 3576
n = int(raw_input())
 
d = [99999 for i in range(n)]
G = [0 for i in range(n)]
M = [[0 for i in range(n)] for j in range(n)]
 
def BFS(s):
    for e in range(n):
        if M[s][e] == 1:
            if d[e] > d[s] + 1:
                d[e] = d[s]+1
                BFS(e)
 
for i in range(n):
    G = map(int, raw_input().split())
    for j in range(G[1]):
        M[G[0]-1][G[2+j]-1] = 1
 
d[0] = 0
for s in range(n):
        BFS(s)
for s in range(n):
    if d[s] == 99999:
        d[s] = -1
for s in range(n):
    print'{0} {1}'.format(s+1, d[s])

Measured memory_bytes: 6472
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  $h = explode(" ", trim(fgets(STDIN)));
  
  $dp = [];

  $dp[0]=0;
  $dp[1]=abs($h[1]-$h[0]);
  for($i=2;$i<$n;$i++){
    $j1=abs($h[$i-1]-$h[$i])+$dp[$i-1];
    $j2=abs($h[$i-2]-$h[$i])+$dp[$i-2];
    $dp[$i]=min($j1, $j2);
  }
  echo $dp[$n-1];

Measured memory_bytes: 18932
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int H, W;
int bo[210][210];
ll d[210][210];

void BFS(int x, int y) {
    for (int i = 0; i < H; i++) {
        fill(d[i], d[i] + W + 10, llmax);
    }
    queue<pii> que;
    d[x][y] = 0;
    que.push(pii(x, y));
    while (que.size() > 0) {
        pii p = que.front();
        int xx = p.first;
        int yy = p.second;
        que.pop();
        for (int i = 0; i < 4; i++) {
            int xxx = xx + dx[i];
            int yyy = yy + dy[i];
            if (xxx >= 0 && xxx < H && yyy >= 0 && yyy < W) {
                if (d[xxx][yyy] == llmax && bo[xxx][yyy] > 0) {
                    d[xxx][yyy] = d[xx][yy] + 1;
                    que.push(pii(xxx, yyy));
                }
            }
        }
    }
}

int main() {
    cin >> H >> W;
    int st[2];
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        char mark[5] = {'#', '.', '@', '$', '%'};
        for (int j = 0; j < W; j++) {
            for (int k = 0; k < 5; k++) {
                if (s[j] == mark[k]) {
                    bo[i][j] = k;
                    if (k == 4) {
                        st[0] = i;
                        st[1] = j;
                    }
                }
            }
        }
    }
    BFS(st[0], st[1]);
    ll pri = llmax;
    ll sol = llmax;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (bo[i][j] == 2) {
                pri = d[i][j];
                //cout << pri << " aaa" << endl;
            } else if (bo[i][j] == 3) {
                //cout << d[i][j] << endl;
                if (d[i][j] < sol) {
                    sol = d[i][j];
                }
            }
        }
    }
    if (pri < sol) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int power(int m)
{
	int mul=2;
	for(int i=2;i<=m;i++)
		mul*=2;
	return(mul);
}

bool check(int a[], vi v[], int n, int m, int p[])
{
	for(int i=0;i<m;i++)
	{
		int k=0;
		for(int j=0;j<v[i].size();j++)
		{
			if(a[v[i][j]-1]==1)
				k++;
		}
		k=k%2;
		if(p[i]!=k)
			return(false);
	}
	return(true);
}

int32_t main()
{
	int n,m;
	cin>>n>>m;
	vi v[m];
	int p[m];
	for(int i=0;i<m;i++)
	{
		int x;
		cin>>x;
		for(int j=0;j<x;j++)
		{
			int y;
			cin>>y;
			v[i].pb(y);
		}
	}
	for(int i=0;i<m;i++)
		cin>>p[i];
	int ans=0;
	for(int i=0;i<power(n);i++)
	{
		int a[n];
		for(int j=0;j<n;j++)
		{
			 if ((i & (1 << j)) != 0)
				a[j]=1;
			else
				a[j]=0;
		}
		if(check(a,v,n,m,p))
			ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256